They come from the country
and currency
modules.
You can do the importing from the console commands documented:
Loading and updating countries and subdivisions
Loading and updating currencies
Also you can incorporate the loading of those scripts in the demo script with some function like the load_zips
showed in my talk on TUB2023 at 27:43 minute.
No, this not needed, the scripts are coming with the modules itself. When you install the country
and currency
module, those scripts should be callable from the command line using the provided information @acaubet provided.
Thanks for answering both of you.
From the command line and trying one of them I get this error:
File "/home/npc/.local/bin/trytond_import_countries", line 5, in <module>
from trytond.modules.country.scripts.import_countries import run
File "/home/npc/.local/lib/python3.8/site-packages/trytond/modules/country/scripts/import_countries.py", line 12, in <module>
import pycountry
ModuleNotFoundError: No module named 'pycountry'
That’s a missing dependency, just install it. I think you will get more of these.
Indeed it is not necessary since Use import scripts to load countries and currencies (f403c9f8b2c7) · Commits · Tryton / Tools · GitLab
But of course pycountry package must be installed.
After installing pycountry with the instruction:
$ sudo apt-get install python3-pycountry
And try again to import the data, now I get the following error:
/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)
Did you run the trytond_import_countries
script?
Looking at tryton_demo.py · 4dbc09c5392f5dd6feafccb41f214be26f2b1807 · Tryton / Tools · GitLab, did you provide the country
module to the arguments? The country
module is not added by default.
Thanks friends, we are getting closer.
After installing the countries and currencies, I now get this error:
/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 122, in setup_party
party, = Party.find([('name', '=', name)])
ValueError: not enough values to unpack (expected 1, got 0)
During handling of the above exception, another exception occurred:
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 126, in setup_party
party.avatar = get_avatar('saber.jpg')
File "tryton_demo.py", line 21, in get_avatar
with open(os.path.join(AVATAR_DIR, name), 'rb') as fp:
FileNotFoundError: [Errno 2] No such file or directory: 'avatars/saber.jpg'
Ha yes the script except to find some pictures in an avatars
directory if you activate the party_avatar
module.
I’m sorry for so many questions, but there are many unknowns.
after install “$ pip install trytond-party-avatar”, I keep getting the error.
As I said if you activate party_avatar
module then the script expect to find avatars in the avatars
directory. So you must create such directory and fill it if you activate the module.
Again this script is really not for new comers, it is an internal tool to build our demo service.
Okay, but is there any way to know where the directory is created and if you have content to be able to dump it or just leave it? Since there is nothing 100% automated to be able to test with sample data?
This would really help the community a lot so that people who don’t know the software would be interested in having it. On the other hand, if there is not something automated where people can see that data, it will be more difficult for people to continue.
Thank you
I put my folder on https://www.tryton.org/~demo/avatars/
As I said earlier, there is https://www.tryton.org/~demo/
Despite everything, I continue with the process.
Now I get this error, I understand that it may be some company data that is missing too, right?
File "tryton_demo.py", line 1014, in <module>
main(options.database, options.modules, options.demo_password,
File "tryton_demo.py", line 939, in main
company, = Company.find([
ValueError: not enough values to unpack (expected 1, got 0)
I guess you are running multiple times the script on the same database and some run has failed at some point. So the data are inconsistent for the script (which can not use transaction).
If the script fails at any time, you must restart the process with a clean database.
I have deleted the Database and recreated it.
It goes through here and then gives this error:
Update countries
Update subdivisions
Update subdivisions parent
Update currencies
File "tryton_demo.py", line 1014, in <module>
main(options.database, options.modules, options.demo_password,
File "tryton_demo.py", line 946, in main
setup_account(config, activated, company)
File "tryton_demo.py", line 252, in setup_account
root_template, = AccountTemplate.find([
ValueError: not enough values to unpack (expected 1, got 0)
You should give which command line options you are using.
But also which version of each packages and which configuration.
I am dumping the file: “tryton_demo.py”
$ python3 tryton_demo.py -c /etc/tryton/trytond.conf -d
Is this what you mean ced?