# Adjusting the Invoice Template

**URL:** https://discuss.tryton.org/t/adjusting-the-invoice-template/5111
**Category:** User
**Created:** [March 21, 2022, 6:41pm UTC](https://discuss.tryton.org/t/adjusting-the-invoice-template/5111 "2022-03-21T18:41:36Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Toni](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/t/8797f3/32.png) [@Toni](https://discuss.tryton.org/u/Toni)
#### Post date: [March 21, 2022, 6:41pm UTC](https://discuss.tryton.org/t/adjusting-the-invoice-template/5111/1 "2022-03-21T18:41:36Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [March 21, 2022, 11:58pm UTC](https://discuss.tryton.org/t/adjusting-the-invoice-template/5111/2 "2022-03-21T23:58:14Z")

</div>

> [@Toni](#):
>
> I am trying to get along with 5.0, which is what came with Debian

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/](https://tryton-team.pages.debian.net/)

> [@Toni](#):
>
> Is there a way to get a good idea about what kind of variables or so are available?

You can read the code. Or you can also browse the models from[Administration → Models → Models](https://demo6.2.tryton.org/#demo6.2/model/ir.model;name=%22Administration%20%2F%20Models%22&views=%5B35%2C34%5D).

> [@Toni](#):
>
> Also, there are lots of “Sequences” - which are basically being used to create all kinds of numbers, right?

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

> [@Toni](#):
>
> Are there any conventions for those sequences that I should follow?

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.

---

<div class="post-metadata">

### Author: ![Toni](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/t/8797f3/32.png) [@Toni](https://discuss.tryton.org/u/Toni)
#### Post date: [March 22, 2022, 7:18pm UTC](https://discuss.tryton.org/t/adjusting-the-invoice-template/5111/3 "2022-03-22T19:18:56Z")

</div>

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:

```auto
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:

```auto
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. ☹ I have already re-installed the python3-psycopg2 package, but to no avail.

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

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [March 22, 2022, 11:29pm UTC](https://discuss.tryton.org/t/adjusting-the-invoice-template/5111/4 "2022-03-22T23:29:38Z")

</div>

When upgrading to a new series, you have to follow all the steps between series from [Migration — Tryton Documentation](https://discuss.tryton.org/c/migration/6)

> [@Toni](#):
>
> `ModuleNotFoundError: No module named 'psycopg2.sql'`

You need at least psycopg 2.7.0, see [trytond depends on psycopg 2.7.0 (#11328) · Issues · Tryton / Tryton · GitLab](https://bugs.tryton.org/issue11328)

---

<div class="post-metadata">

### Author: ![Toni](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/t/8797f3/32.png) [@Toni](https://discuss.tryton.org/u/Toni)
#### Post date: [March 22, 2022, 11:37pm UTC](https://discuss.tryton.org/t/adjusting-the-invoice-template/5111/5 "2022-03-22T23:37:08Z")

</div>

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?

```auto
$ 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.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [March 22, 2022, 11:39pm UTC](https://discuss.tryton.org/t/adjusting-the-invoice-template/5111/6 "2022-03-22T23:39:32Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Toni](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/t/8797f3/32.png) [@Toni](https://discuss.tryton.org/u/Toni)
#### Post date: [March 22, 2022, 11:48pm UTC](https://discuss.tryton.org/t/adjusting-the-invoice-template/5111/7 "2022-03-22T23:48:29Z")

</div>

> [@ced](#):
>
> psycopg2cffi

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:

```auto
# 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.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [March 22, 2022, 11:54pm UTC](https://discuss.tryton.org/t/adjusting-the-invoice-template/5111/8 "2022-03-22T23:54:47Z")

</div>

It looks like you run the after migration query of [https://discuss.tryton.org/t/migration-from-5-8-to-6-0/3603](https://discuss.tryton.org/t/migration-from-5-8-to-6-0/3603)  
So now you have lost the data which prevent a clean upgrade.

---

<div class="post-metadata">

### Author: ![Toni](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/t/8797f3/32.png) [@Toni](https://discuss.tryton.org/u/Toni)
#### Post date: [March 22, 2022, 11:55pm UTC](https://discuss.tryton.org/t/adjusting-the-invoice-template/5111/9 "2022-03-22T23:55:54Z")

</div>

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

Nevermind, I am starting over. ☹

Thanks for your help so far!

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [March 23, 2022, 7:57am UTC](https://discuss.tryton.org/t/adjusting-the-invoice-template/5111/10 "2022-03-23T07:57:28Z")

</div>

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