Update 6.0 > 7.0: console commands fail

Hello, I tried this and got an error:

(my-database) [my-machine]:~/TRYTON/my-database$ trytond-console -c trytond.conf -d my-database
Tryton 7.0.0, Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
>>> Invoice = pool.get('account.invoice')
>>> invoices = Invoice.search([('state', 'in', ['posted', 'paid'])])
Traceback (most recent call last):
  File "/usr/lib/python3.10/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<console>", line 1, in <module>
  File "/my-home-dir/TRYTON/my-database/lib/python3.10/site-packages/trytond/model/modelsql.py", line 1793, in search
    cursor.execute(*select)
  File "/my-home-dir/TRYTON/my-database/lib/python3.10/site-packages/trytond/backend/postgresql/database.py", line 68, in execute
    cursor.execute(self, sql, args)
psycopg2.errors.UndefinedColumn: column a.posted_by does not exist
LINE 1: ..., "a"."payment_term_date" AS "payment_term_date", "a"."poste...
                                                             ^

>>> 

What’s my mistake?

Cheers,
Wolf

Before you executed this command, did you do a trytond-admin -d ... - c .... --all -vv?

You are missing the column posted_by in the database. This column should be added automatically when doing the upgrade.

Thanks for your quick support.

No, I did not. I did now, but now get another error, which leads to the assumption that I do not execute the instructions as I should: I copied them line by line into trytond-console. Guess this is not how it is supposed to work.

Instructions say “using the following trytond-console script” - but they do not tell me how that’s done. Guess you know…

Cheers,
Wolf

You started right by using the trytond-console command. You can copy the commands line by line, but you must keep the indentation.

For example with https://discuss.tryton.org/t/migration-from-6-8-to-7-0 there is a for-loop. So for the lines which are indented you also must copy the (4 spaces) in front of them as well.

When you have copied the last line of the for-loop, you also have to press to add the empty line as shown and get the for-loop executed.

Also at the top-right corner of the code, when you hover with the mouse there, a icon pops up. Click it to copy the whole part and you can paste it directly into your console. You have only press for the last command to be executed.

Alright - thank you for being so clear and dummy-proof. That’s what I need.

The process started, but throws after a few seconds:

trytond.model.modelstorage.DomainValidationError: The value "3300 - Verbindlichkeiten aus Lieferungen und Leistungen" for field "Payment Lines" in "Lief-2022-24" of "Invoice" is not valid according to its domain. - 

Nevertheless, I can start new tryton, some simple actions worked. Should I try to fix the error?

I will try to do my best :sweat_smile: to keep you all on board.

Ok, so nothing is stored. The code only fills some caches so it shouldn’t be a huge problem. But it shows a inconsistency in your database.

It has something to do with payment lines of an invoice. Probably after you posting or paying the invoice you made some changes. Wild guess something with your accounts?

When you know what the problem is, you probably have to make the changes directly into the database instead of through Tryton because Tryton will not allow you to make changes to the posted or payed invoice.