Adjusting the Invoice Template

I am new to Tryton and now try to understand how I can customize the invoice template. At the moment, I am trying to get along with 5.0, which is what came with Debian. Is there a way to get a good idea about what kind of variables or so are available?

Also, there are lots of “Sequences” - which are basically being used to create all kinds of numbers, right? Are there any conventions for those sequences that I should follow?

It is probably better to start with a more recent version because you may miss some new feature that people here will assume you have. Debian has back-port for more recent series see https://tryton-team.pages.debian.net/

You can read the code. Or you can also browse the models fromAdministration → Models → Models.

Yes the sequence model has the purpose to create sequential numbering.

No Tryton does not care about the schema used for the sequence. Indeed the numbers stored on document are never used for any programmatic purpose.

Hi Cedric,

thank you for the help so far! I am trying to follow your advice and installed tryton-6.0 from this private repo, but now, my database is broken:

tryton_50=# ALTER TABLE "account_payment_sepa_message" ALTER COLUMN "message" TYPE BYTEA USING message::BYTEA;
ERROR:  relation "account_payment_sepa_message" does not exist
tryton_50=# UPDATE project_work SET status = db_id FROM ir_model_data WHERE module = 'project' AND fs_id = 'work_open_status' AND state = 'opened';
 UPDATE project_work SET status = db_id FROM ir_model_data WHERE module = 'project' and fs_id = 'work_done_status' AND state = 'done';
ERROR:  relation "project_work" does not exist
LINE 1: UPDATE project_work SET status = db_id FROM ir_model_data WH...
               ^
ERROR:  relation "project_work" does not exist
LINE 1: UPDATE project_work SET status = db_id FROM ir_model_data WH...
               ^
tryton_50=# UPDATE project_work SET status = db_id FROM ir_model_data WHERE module = 'project' AND fs_id = 'work_open_status' AND state = 'opened';
 UPDATE project_work SET status = db_id FROM ir_model_data WHERE module = 'project' and fs_id = 'work_done_status' AND state = 'done';q^C
tryton_50=# 
\q

Furthermore, trying to run trytond-admin yields a strange traceback:

trytond-admin -c /etc/tryton/trytond.conf -d tryton_50 --all
Traceback (most recent call last):
  File "/bin/trytond-admin", line 21, in <module>
    import trytond.admin as admin
  File "/usr/lib/python3/dist-packages/trytond/admin.py", line 11, in <module>
    from trytond import backend
  File "/usr/lib/python3/dist-packages/trytond/backend/__init__.py", line 21, in <module>
    _module = importlib.import_module(_modname)
  File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/usr/lib/python3/dist-packages/trytond/backend/postgresql/__init__.py", line 4, in <module>
    from .database import (
  File "/usr/lib/python3/dist-packages/trytond/backend/postgresql/database.py", line 20, in <module>
    from psycopg2.sql import SQL, Identifier
ModuleNotFoundError: No module named 'psycopg2.sql'

Come to think of it, the errors about non-existing relationships might be due to modules which I have not yet activated, and I can ignore those - right?

As for the psycopg2.sql module, I have no idea - I can import it just fine from the command line. :frowning: I have already re-installed the python3-psycopg2 package, but to no avail.

As a consequence, my Tryton server doesn’t start anymore.

When upgrading to a new series, you have to follow all the steps between series from Migration - Tryton Discussion

You need at least psycopg 2.7.0, see trytond depends on psycopg 2.7.0 (#11328) · Issues · Tryton / Tryton · GitLab

Thank you! I had tried to execute the migration steps all the way from 5.0 to 6.0. That’s how I got to the various SQL errors mentioned above. The last step in the upgrade should have been to run trytond-admin, but that failed because of the psycopg2 problem. But the bigger problem is, why can I import psycopg2.sql easily from the command line, while trytond-admin cannot?

$ bpython
bpython version 0.21 on top of Python 3.9.2 /usr/bin/python3
>>> import psycopg2.sql as ps
>>> dir(ps)
['Composable', 'Composed', 'DEFAULT', 'Identifier', 'Literal', 'NULL', 'PY3', 'Placeholder', 'SQL', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_form
atter', 'ext', 'string', 'string_types']
>>> ps.__file__
'/usr/lib/python3/dist-packages/psycopg2/sql.py'

This is the system-provided psycopg2, which is of version 2.8.6-2. IOW, it should work, but still doesn’t.

Maybe you have psycopg2cffi installed which will be used than but it is no more compatible.

Yes - that’s a dependency for python3-sqlalchemy-utils.

After de-installing this, trytond-admin worked, but still threw an error, due to some SQL problem:

# trytond-admin -v -c /etc/tryton/trytond.conf -d tryton_50 --all
current settings:  ['Binary', 'Decimal', 'RLock', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'chain', 'connect', 'datetime', 'defaultdict', 'json', 'logging', 'os', 'repeat', 'sys', 'time', 'warnings'] 

path:  ['/usr/bin', '/usr/lib/python39.zip', '/usr/lib/python3.9', '/usr/lib/python3.9/lib-dynload', '/usr/local/lib/python3.9/dist-packages', '/usr/lib/python3/dist-packages', '/usr/lib/python3.9/dist-packages']
477356 140435340674880 [2022-03-22 23:46:00,618] WARNING py.warnings /usr/lib/python3/dist-packages/trytond/backend/postgresql/database.py:258: UserWarning: The path specified in the URI will be overridden
  warnings.warn("The path specified in the URI will be overridden")

477356 140435340674880 [2022-03-22 23:46:00,695] WARNING py.warnings /usr/lib/python3/dist-packages/genshi/template/interpolation.py:34: DeprecationWarning: Flags not at the start of the expression '[uU]?[rR]?("""|\\\'\\\'\\' (truncated)
  token_re = re.compile('%s|%s(?s)' % (

477356 140435340674880 [2022-03-22 23:46:00,985] WARNING py.warnings /usr/lib/python3/dist-packages/pygal/_compat.py:23: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working
  from collections import Iterable

477356 140435340674880 [2022-03-22 23:46:01,154] WARNING py.warnings /usr/lib/python3/dist-packages/zeep/loader.py:5: DeprecationWarning: defusedxml.lxml is no longer supported and will be removed in a future release.
  from defusedxml.lxml import fromstring

Traceback (most recent call last):
  File "/bin/trytond-admin", line 23, in <module>
    admin.run(options)
  File "/usr/lib/python3/dist-packages/trytond/admin.py", line 53, in run
    pool.init(update=options.update, lang=list(lang),
  File "/usr/lib/python3/dist-packages/trytond/pool.py", line 164, in init
    restart = not load_modules(
  File "/usr/lib/python3/dist-packages/trytond/modules/__init__.py", line 438, in load_modules
    _load_modules(update)
  File "/usr/lib/python3/dist-packages/trytond/modules/__init__.py", line 406, in _load_modules
    load_module_graph(graph, pool, update, lang)
  File "/usr/lib/python3/dist-packages/trytond/modules/__init__.py", line 238, in load_module_graph
    cls.__register__(module)
  File "/usr/lib/python3/dist-packages/trytond/ir/sequence.py", line 128, in __register__
    cursor.execute(*table.update(
  File "/usr/lib/python3/dist-packages/trytond/backend/postgresql/database.py", line 82, in execute
    cursor.execute(self, sql, args)
psycopg2.errors.UndefinedColumn: column b.code does not exist
LINE 1: ...CT "b"."id" FROM "ir_sequence_type" AS "b" WHERE ("b"."code"...

I’ll double-check whether I missed some of the SQL upgrades, although I doubt it.

It looks like you run the after migration query of Migration from 5.8 to 6.0
So now you have lost the data which prevent a clean upgrade.

So I should just drop the database and start over - right?

Nevermind, I am starting over. :frowning:

Thanks for your help so far!

Yes as you lost data. Or you can start over from a backup.