Tryton_demo.py usage in Debian 10

I’ve got from https://hg.tryton.org/tryton-tools/file/tip/tryton_demo.py to fill a demo database.
Is there any “home page” for tryton_demo.py ? Is it included in some stable package?

$ python tryton_demo.py --help
Traceback (most recent call last):
File "tryton_demo.py", line 4, in <module>
from dateutil.relativedelta import relativedelta
ImportError: No module named dateutil.relativedelta

(I have already tryton-proteus installed)

No this is an internal tool of the Tryton project. It is not versioned. All you can expect is that it works with the latest series.

It requires the python-dateutil package.

Previously I did try to run directly with
./tryton_demo.py
(and gave same error)
I see now that the bug begins with same script at its first line:
#!/usr/bin/env python
it should be:
#!/usr/bin/env python3

Where is there some more documentation about tryton_demo.py ? I want to know how to list all available modules (with this script or any other tool) and if specified database must exist, should exist, must not exist and/or it fills an already deployed database with trytond-admin

There is no documentation because as I said it is an internal tool.

You must check in the code.

It must exist and initialized with trytond-admin but with no module activated.

Once I’ve created and initialized database:
$ wget https://hg.tryton.org/tryton-tools/raw-file/tip/tryton_demo.py
$ python3 tryton_demo.py -c $ConfigFile -d $DemoDatabase

/usr/lib/python3/dist-packages/ldap3/utils/ciDict.py:30: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  class CaseInsensitiveDict(collections.MutableMapping):
Traceback (most recent call last):
  File "tryton_demo.py", line 968, in <module>
    config_file=options.config_file)
  File "tryton_demo.py", line 874, in main
    from trytond.modules.country.scripts.import_countries import do_import
ModuleNotFoundError: No module named 'trytond.modules.country.scripts'

The tip version of the script will only work on latest released series (currently 5.4)

You should use an older version. Probably it will work with the following commands:

$ wget https://hg.tryton.org/tryton-tools/raw-file/effe927cf4a0/tryton_demo.py
$ python3 tryton_demo.py -c <config_file> -d <db_name>

Aleady tried with /hg.tryton.org/tryton-tools/raw-file/effe927cf4a0/tryton_demo.py but got another error:

/usr/lib/python3/dist-packages/ldap3/utils/ciDict.py:30: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  class CaseInsensitiveDict(collections.MutableMapping):
Traceback (most recent call last):
  File "tryton_demo.py", line 955, in <module>
    config_file=options.config_file)
  File "tryton_demo.py", line 892, in main
    setup_product(config, activated, company=company)
  File "tryton_demo.py", line 302, in setup_product
    unit, = Uom.find([('name', '=', 'Unit')])
ValueError: not enough values to unpack (expected 1, got 0)

Which language this you have for the admin user? If you have a diferent language than ‘en’ it will fail to find the Unit values. So you have two options here:

  • Change the admin language to ‘en’
  • Update the script to use our language names.

admin user has “ca” as user language in its preferences.
If I change it to “en” will this distort units seen by user?

Other way; I don’t know in tryton_demo.py line 302 what to change to adopt localized units.

Easiest way is:

  1. Set admin language to “en”
  2. Run the demo script
  3. Set admin language back to “ca” (or whatever you prefer)

Tried with “en” for admin. (Process really spends many time!)
New result (I don’t know if it’s an error or a warning):

class CaseInsensitiveDict(collections.MutableMapping):
Field action of 131@ir.ui.menu not updated (id: menu_location_form), because it has changed since the last update

Those are some warnings but the processs ended correctly.
You should be able to see the demo data on your database.

Yes, this worked by applying tryton_demo.py just after initializing database with trytond-admin and not customizing anything in until this script completes.

Once this is done, I’ve done following:

  1. customized “admin” account
  2. enabled the rest of modules available (tryton_demo.py only enables ~50% of tryton-modules-all)
  3. Assigned all permissions to demo_* accounts except main “Administration”

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.