Migration from 3.6 to 6.2

thanks, yes thats an good idea. Now I can modify the custom modules, reload the modules with docker exec -it trytond bash -c "trytond-admin --config /etc/tryton/trytond.conf --all" and test the changes.

Now I am stuck with this error:

  File "/trytond/wsgi.py", line 79, in dispatch_request
    return endpoint(request, **request.view_args)
  File "/trytond/protocols/dispatcher.py", line 45, in rpc
    request, database_name, *request.rpc_params)
  File "/trytond/protocols/dispatcher.py", line 62, in login
    database_name, user, parameters, context=context)
  File "/trytond/security.py", line 31, in login
    pool = _get_pool(dbname)
  File "/trytond/security.py", line 18, in _get_pool
    pool.init()
  File "/trytond/pool.py", line 160, in init
    lang=lang, activatedeps=activatedeps)
  File "/trytond/modules/__init__.py", line 423, in load_modules
    _load_modules(update)
  File "/trytond/modules/__init__.py", line 388, in _load_modules
    load_module_graph(graph, pool, update, lang)
  File "/trytond/modules/__init__.py", line 270, in load_module_graph
    pool.setup()
  File "/trytond/pool.py", line 236, in setup
    cls.__post_setup__()
  File "/trytond/model/modelview.py", line 203, in __post_setup__
    for button in cls._buttons:
    AttributeError: type object \'party.address\' has no attribute \'_buttons\'

btw is there any better option to test my custom modules? Right now I always start the tryton client and check the errors reported there.

which version is the trytond, and the party module?

trytond (server): 5.0.63
trytond-party: 5.0.5
Tryton (client): 5.0.33

For me it looks like some module is extending party.address and override __setup__ method without calling super().__setup__ so the _buttons attribute is not set by ModelView.

I found this in the custom module company_name/party.py:

class Address(metaclass=PoolMeta):
    __name__ = 'party.address'

I do understand python, but I am not yet sure how inheritance is working for tryton.

figured it out, indeed super().__setup__() was missing. Now I am stuck with the next error beeing:

  File "/trytond/wsgi.py", line 79, in dispatch_request
    return endpoint(request, **request.view_args)
  File "/trytond/protocols/dispatcher.py", line 45, in rpc
    request, database_name, *request.rpc_params)
  File "/trytond/protocols/dispatcher.py", line 62, in login
    database_name, user, parameters, context=context)
  File "/trytond/security.py", line 34, in login
    user_id = User.get_login(loginname, parameters)
  File "/trytond/res/user.py", line 643, in get_login
    count_ip = LoginAttempt.count_ip()
  File "/trytond/res/user.py", line 827, in count_ip
    & (table.create_date >= cls.delay())))
  File "/trytond/backend/postgresql/database.py", line 67, in execute
    cursor.execute(self, sql, args)
    psycopg2.ProgrammingError: column a.ip_network does not exist
LINE 1: ...\'*\') FROM "res_user_login_attempt" AS "a" WHERE (("a"."ip_ne...

The field ip_network is defined in trytond/trytond/res/user.py. So it seems you are missing the migration step which adds the field to the database. This is done via:

trytond-admin -d DB --all

If this doesnā€™t work, a missing or wrong super call in __setup__ or __register__ could make such problems.

I think there is something wrong with my setup. When I try to run the suggested command I get an error:

OSError: Database "mydatabase.sqlite" doesn't exist!

Usually this means the config file is not found. This helps:

trytond-admin -d DB --all -c /path/to/trytond.conf

Its the same as you did here: migration from 3.6 to 6.2 - #6 by looooo

thanks for the help. now I get this error with the command:
trytond-admin -d mydatabase --all -c /etc/tryton/trytond.conf

psycopg2.ProgrammingError: relation "ir_configuration_id_seq" already exists

It looks like your database connection via Tryton detects no configuration table and tries to install a new base setup. This speaks for different owners of the database tables (OwnerA) and the database connection (OwnerB) in trytond.conf.

  1. It is good to make a backup of the original database without owner, via psql. E.g.:

    sudo su postgres -c "pg_dump -d <orig_db> -B -Fp -O -f /tmp/orig_db.sql"
    
  2. Then create a new database with user postgres, but set OwnerB via psql:

    sudo su postgres -c "psql"
    CREATE DATABASE new_db OWNER Ownerb;
    
  3. Connect to the new database with psql using the same database connection parts as given in trytond.conf: user (, host, port). E.g.:

    psql -U OwnerB new_db
    -- Restore the Backup:
    \i /tmp/orig_db.sql
    ā€¦
    
  4. If the manual connection via psql works and you can select * from ir_configuration_id_seq;, then Tryton will also be able to connect correctly.

thanks again for the help. I tried these steps:

  1. works
  2. docker creates already a database called mydatabase with owner tryton. I think itā€™s ok to skip this step.
  3. when I do this step:
    \i /tmp/orig_db.sql

I get an error that there is no user ā€œpostgresā€.

So I need to run this before:
CREATE ROLE postgres WITH LOGIN PASSWORD '***' SUPERUSER;

then loading the dump works, but I am not sure if that is what we want as there are now also two users: postgres and tryton.

  1. when i run select * from ir_configuration_seq; I get this error: ERROR: relation "ir_configuration_seq" does not exist

The tables must be owned by the user used by trytond.
So probably the best is to restore your backup with owner like with pg_restore --no-owner but using the same user as trytond.

how do I set the user for trytond. I see it only in the trytond.conf:
database] uri = postgresql://tryton:********@db:5432/mydatabase

Did you create the backup with

sudo su postgres -c "pg_dump -d <orig_db> -B -Fp -O -f /tmp/orig_db.sql"

The -O (--no-owner) option is important here, it doesnā€™t set ownerships.

The exact message would be good. is the only one error at the end about GRANT, or is the error many times. If it is once at the end, just ignore it.

This I wouldnā€™t recommend.

In this case tryton is the user.

I use this command to create the dump:

PGPASSWORD=$DB_PASSWORD pg_dump -U $DB_USER -h $DB_HOST -d $DB_NAME -B -Fp -O -f /modified/dump.sql
ERROR:  role "postgres" does not exist
GRANT

I think itā€™s at the ned, but I am not sure.

Just ignore it. It is always in my restores, too.

Donā€™t forget to connect for restore with the tryton user from your trytond.conf. In your case:

psql -U $DB_USER $DB_NAME
-- Restore the Backup:
\i /modified/dump.sql

yes I did it like this.

itā€™s strange. In the postgres-container when I do:
select * from ir_configuration_seq; I get this error: ERROR: relation "ir_configuration_seq" does not exist

which seems to be right.

but with trytond-admin -d mydatabase --all -c /etc/tryton/trytond.conf I get

psycopg2.ProgrammingError: relation "ir_configuration_id_seq" already exists

so what database it trytond trying to connect?

Typo, its select * from ir_configuration_id_seq;

And look up the owner e.g. with \ds ir_configuration_id_seq. It must be $DB_USER which must be tryton following your trytond.conf fileā€¦

the output of:

select * from ir_configuration_id_seq;
 last_value | log_cnt | is_called 
------------+---------+-----------
          1 |       0 | t

the output of:

\ds ir_configuration_id_seq
 Schema |          Name           |   Type   | Owner  
--------+-------------------------+----------+--------
 public | ir_configuration_id_seq | sequence | tryton

so this seems to be correct, right?

but still I am a bit confused. To update the database with trytond-admin ir_configuration_id_seq should not be stored in the database, right?