How to add fields to frepple object (example)

95 views
Skip to first unread message

Michael N

unread,
Jul 26, 2020, 4:55:00 PM7/26/20
to frePPLe users
Hello!

For example, we need to add fields to the Customer object:
Address, Region, City, Priority, URL

(Win-7 64x, PostgreSQL 12.1, frepple 6.5.9)


we follow the instructions: 
1) Find the INSTALLED_APPS section in the djangosettings.py file and add a custom application, for example USRCRM
2) Create an application folder and first create an __init__.py file in it
3) Create file attributes.py and add description of attributes

registerAttribute(
    "freppledb.input.models.Customer",  # Class we are extending
    [
        (
            "address",  # Field name in the database
            _("address"),  # Human readable label of the field
            "string",  # Type of the field.
            True,  # Is the field editable?
            True,  # Should the field be visible by default?
        ),
...
 (
            "priority",  # Field name in the database
            _("priority"),  # Human readable label of the field
            "integer",  # Type of the field.
            True,  # Is the field editable?
            True,  # Should the field be visible by default?
        ),
        (
            "url",  # Field name in the database
            _("url"),  # Human readable label of the field
            "url",  # Type of the field.
            True,  # Is the field editable?
            True,  # Should the field be visible by default?
        ),
...
Here you see fields of type "string", "integer" and one field is derived type "url".
If you look into the description of the getAttributeFields function of the file (… boot / __ init __ . py), then you will not find the description of the url field. Therefore, the description for the url field must be added:

How to add a derived field:

3.1. Add another node to the getAttributeFields function:

        elif fieldtype == "url":

            result.append(

                GridFieldUrl(

                    field_name,

                    title=label,

                    initially_hidden=hidden or initially_hidden,

                    editable=editable,

                )

            )

3.2 In the same file, add a cycle node to the add_extra_model_fields function:

          elif fieldtype == "url":

            field = models.URLField(

                label, null=True, blank=True, db_index=True, editable=editable

            )

In the file ... django / db / models / fields / __ init__.py there is a URLFIelg class that describes our derived field with a validator to check whether the values are filled in, so do not forget to add the field import here:

from django.db.models.fields import URLField


3.3. Open the report.py file and add the class:


 class GridFieldUrl(GridField):

    formatter = "url"

    extra = '"formatoptions":{"defaultValue":""}'

    width = 80


don't forget to add to import:

from django.db.models.fields import CharField, AutoField, URLField


4)  frepplectl makemigrations..........OK!

5)  frepplectl migrate.......................OK!

6)  frepplectl runwebserver..............OK!


addurl.jpg



I wish everyone a good job!

Message has been deleted

Jming Zhang

unread,
Mar 18, 2021, 8:42:16 PM3/18/21
to frePPLe users
Hi Michael,
Thank you for you work.
I follow the your instruction to add my own field,but I can't run the commit "frepplectl.py makemigrations" or "frepplectl.py makemigrations my_app", it also results in an error "django.db.utils.OperationalError: FATAL:  database "scenario1" does not exist".
I just add some new fields in the my_app from frepple, then  run the commit "frepplectl makemigrations".
if I run the "frepplectl.py migrate"
then 
"Operations to perform:
  Apply all migrations: admin, auth, common, contenttypes, execute, input, metrics, odoo, output, reportmanager
Running migrations:
  No migrations to apply.
  Your models have changes that are not yet reflected in a migration, and so won't be applied.
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them."


Thank you for your time!

Jianming

qxping

unread,
Jun 3, 2021, 3:15:50 AM6/3/21
to frePPLe users
Hi,
When I try to install the latest 6.14 on Windows 7, an error comes ( as attached). 
And the same error to run migrate tool. 
Thanks for the support. 

Regards,
Kevin


0603_1.jpg
0603_2.jpg

Johan De Taeye

unread,
Jun 4, 2021, 2:49:21 PM6/4/21
to freppl...@googlegroups.com

Hi Kevin,

 

Weird, I haven’t seen this error before and the 6.14 installer works fine for me.

 

I don’t know what’s causing the problem, but here are some questions and suggestions:

  • Try installing in a custom folder, without any space in the path name.
  • Does the same happen with older releases?
  • Does it happen also when you choose to “install only for me” (rather than “install for anyone using this computer”)?

 

Johan De Taeye

Mob: +32 477.385.362

Skype: jdetaeye

Visit us at https://frepple.com

--
You received this message because you are subscribed to the Google Groups "frePPLe users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to frepple-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/frepple-users/tencent_EC2AC599AA4EB3EFFC6E12AF%40qq.com.

Michael N

unread,
Jun 7, 2021, 4:54:52 AM6/7/21
to frePPLe users
hello!
Try to install the base and application separately. For migration, try to transfer the database using the pg_dump utility 
(also available in PgAdmin).
To do this, first create a new database, get SQL-bakup from the old database and restore to the new database, ...
img0112.png
... then in the configuration file (djangosettings.py) you can change the default database to a new one.
пятница, 4 июня 2021 г. в 21:49:21 UTC+3, Johan De Taeye:

qxping

unread,
Jun 8, 2021, 10:20:00 AM6/8/21
to frePPLe users
Hi,
I tried to install Postgres Database and application separately, yet found the same error when creating database schema. 
It is also weird since I didn’t install python under c:\develop\python38\...

------------------ Original ------------------
From: Michael N <par...@gmail.com>
Date: Mon,Jun 7,2021 4:54 PM
To: frePPLe users <freppl...@googlegroups.com>
Subject: Re: Error when installing Frepple 6.14 community

hello!
Try to install the base and application separately. For migration, try to transfer the database using the pg_dump utility 
(also available in PgAdmin).
To do this, first create a new database, get SQL-bakup from the old database and restore to the new database, ...
原文图片

0608_1.jpg

qxping

unread,
Jun 8, 2021, 2:45:21 PM6/8/21
to frePPLe users
Hi Johan,
I tried to install in a customer field and chose to “install only for me”, but the same error when creating database schema. Please find the attached snapshot. 
Same error when I tried to install version 6.13.0.  But no such error for earlier version like 6.11.0.


------------------ Original ------------------
From: Johan De Taeye <jdet...@frepple.com>
Date: Thu,Jun 3,2021 8:22 PM
To: frepple-users <freppl...@googlegroups.com>
Subject: Re: RE: Error when installing Frepple 6.14 community
0605_1.jpg

Michael N

unread,
Jun 9, 2021, 3:04:03 PM6/9/21
to frePPLe users
let's try the installation again:
- try using a separate installation - create some directory on the disk in the root for installation, for example C:\frepple\614
- check the path to PostgreSQL in the system, the path should be in the environment variable of Windows  
- check the operating system user has rights to work with the Postgres directory
- Go to the directory with the Postgres installation and in the data-directory create a separate folder for the tablespace of your database.
- Start PgAdmin and create a tablespace in it and point it to the path of the folder that you created for the database tablespace.
- before that, you must already have a frepple-user with administrator rights - which will be the owner of the database
- create a database using the postgres-template, with frepple as owner and specify a new tablespace for the database
- install frepple to the directory C:\frepple\614, during installation do not forget to remove the "install Postgess" flag
- when installing, specify the database name, user and password

Regards,

вторник, 8 июня 2021 г. в 21:45:21 UTC+3, qxp...@gmail.com:
Reply all
Reply to author
Forward
0 new messages