Automatically loading company, party and product records for testing

When I’m testing, I need to manually create the company, the parties for a test and the product records or anything else.

Is there a way to automate this, for example, importing from XML?

It makes no sense to import business data using code.

You can create your own scripts (ie. using proteus) to load demo data.

You can find the script that loads data for demo.tryton.org here:

https://hg.tryton.org/tryton-tools/file/93a228fc7e69/tryton_demo.py

For testing / evaluation I’m using an sqlite database. Thus after first set-up I can just copy the database-backup into place.
(You might be interested in my demo, which I created for others: Regionalkollektiv, e brief readme is included in the archive).

I don’t know if there is any way to import “DEMO” type data to test the product.

I’ve just installed the software on a server I own and I’d like to import some data into it for testing and see how it really works on my server.

As it is online in the Tryton Demo, I would like to have that test data to be able to test the product.

What happens is that I don’t know if this is possible or, on the contrary, it cannot be.

You can run the tryton_demo.py script or you can download the demo backup.

Ok I gave in. But how exactly should I proceed?

I first download the files to a directory and execute this instruction or how could it be done?

The tryton_demo.py is a script based on proteus. So you must have it installed with trytond.

The script has an --help option but basically you can run it like

$ tryton_demo.py -c <path to trytond.conf> -d <database name>

The execution can take a while.

I get “command not found”.
I assume it won’t be installed.

Try

$ python tryton_demo.py -c <path to trytond.conf> -d <database name>

Hi htgoebel,

I get this error:

Traceback (most recent call last):
File “tryton_demo.py”, line 13, in
from proteus import Model, Wizard
ModuleNotFoundError: No module named ‘proteus’

After installing Proteus I get this error. Do you know what it is?

File “tryton_demo.py”, line 1014, in
main(options.database, options.modules, options.demo_password,
File “tryton_demo.py”, line 933, in main
customers, suppliers = setup_party(config, modules)
File “tryton_demo.py”, line 71, in setup_party
us, = Country.find([(‘code’, ‘=’, ‘US’)])
ValueError: not enough values to unpack (expected 1, got 0)

You need to install proteus in your testing environment.

  • When using a checkout of the Tryton mono repository:

    pip install -e /path/to/mono-repo/proteus 
    
  • When not using a checkout of the Tryton mono repository (replace 6.0 with the series you are using):

    pip install proteus=6.0.*
    

Thank you for answering so quickly.

Catching up a bit…

What does it mean “using a checkout of the Tryton mono repository”.
To install it I have used the command: $pip install proteus without specifying any version. This is incorrect?

Without knowing how you installed Tryton, one can not tell.

  • Not specifying the version only works if you installed Tryton recently — check that the X.Y version of both trytond and proteus match.
  • What do you want to test? Just how Tryton works, or do you have a development environment?
  • Did you at all use pip to install trytond? Do you use a Python virtual environments? Packages comming with you Linux distribution?

Our idea is to understand how the software works and see the possibilities it has for us and for our clients.
That’s the idea. In addition to doing a Test, it is to see if it helps us to work since this software had not heard much.

Anyway I tell you, I have it installed on Ubuntu and I have installed it with PIP and I want to dump the “DEMO” data to see how and where they are placed and get an idea of general operation on our servers.

Also see the possibilities we have with the different modules that exist. See what can be done in general after all.

I have installed:
Proteus: 6.8.0
Trytond = 6.8.2
Tryton = 6.8.1

And it gives the error that I put in the previous post.
I couldn’t answer you yesterday because I had a restriction of 17 posts in 24 hours and yesterday I reached the maximum.

Thanks for the help.

It seems the script did not import the countries.
Have you activate some modules on the database prior to running the script? Because the script is supposed to be run on clean database which was just initialized with:

$ trytond-admin -c <config> -d <database name> --all

So basically the operations are:

$ createdb demo
$ TRYTOND_DATABASE_URI=postgresql:// trytond-admin -d demo --all
$ TRYTOND_DATABASE_URI=postgresql:// tryton_demo.py -d demo

TRYTOND_DATABASE_URI replace the configuration to connect to the database.

PS: the demo script is more an internal tool to setup the demo sever than a practical tool for everyone

After installing a clean and new system, I have only activated the sales module and I still get this error when importing:

/usr/lib/python3/dist-packages/apport/report.py:13: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import fnmatch, glob, traceback, errno, sys, atexit, imp, stat
Traceback (most recent call last):
  File "tryton_demo.py", line 1014, in <module>
    main(options.database, options.modules, options.demo_password,
  File "tryton_demo.py", line 933, in main
    customers, suppliers = setup_party(config, modules)
  File "tryton_demo.py", line 71, in setup_party
    us, = Country.find([('code', '=', 'US')])
ValueError: not enough values to unpack (expected 1, got 0)

If I don’t install any module, it doesn’t give an error but it only dumps the users and little else.

Do you know if I would need to have something else configured so that I don’t get this error?

You have to load the countries with the import_countries.py script and also the currencies with import_currencies.py.

Where do I find the content of that file?