Hi everyone,
I'm using Odoo.sh to build my custom module, but I've encountered an issue with tests.
At first, I thought the problem was with my code. However, after completely removing everything and restarting from a fully empty branch (0 commits), I noticed that the following command works perfectly on a blank database:
odoo-bin --test-enable --stop-after-init --log-level=test
But if I install the Contacts module (via the app installation interface) and rerun the same test command:
odoo-bin --test-enable --stop-after-init --log-level=test
I immediately get many errors like this:
odoo.sql_db: bad query: b'INSERT INTO "res_users" ("active", "company_id", "create_date", "create_uid", "login", "partner_id", "write_date", "write_uid") VALUES (true, 1, '2025-02-15 00:04:13.125900', 1, 'u1', 578, '2025-02-15 00:04:13.125900', 1) RETURNING "id"' ERROR: null value in column "notification_type" of relation "res_users" violates not-null constraint DETAIL: Failing row contains (58, 1, 578, t, 2025-02-15 00:04:13.1259, u1, null, null, 1, 1, null, null, 2025-02-15 00:04:13.1259, null, null, null, null, null).
Example traceback:
odoo.addons.base.tests.test_base: ERROR: TestGroups.test_remove_groups Traceback (most recent call last): File "/home/odoo/src/odoo/odoo/addons/base/tests/test_base.py", line 209, in test_remove_groups u1 = self.env['res.users'].create({'login': 'u1', 'name': 'U1'}) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<decorator-gen-32>", line 2, in create File "/home/odoo/src/odoo/odoo/api.py", line 479, in _model_create_multi return create(self, [arg]) ^^^^^^^^^^^^^^^^^^^ File "/home/odoo/src/odoo/odoo/addons/base/models/res_users.py", line 1901, in create users = super(UsersView, self).create(new_vals_list) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<decorator-gen-30>", line 2, in create File "/home/odoo/src/odoo/odoo/api.py", line 480, in _model_create_multi return create(self, arg) ^^^^^^^^^^^^^^^^^ File "/home/odoo/src/odoo/odoo/addons/base/models/res_users.py", line 1602, in create return super(UsersImplied, self).create(vals_list) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<decorator-gen-28>", line 2, in create File "/home/odoo/src/odoo/odoo/api.py", line 480, in _model_create_multi return create(self, arg) ^^^^^^^^^^^^^^^^^ File "/home/odoo/src/odoo/odoo/addons/base/models/res_users.py", line 706, in create users = super(Users, self).create(vals_list) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<decorator-gen-0>", line 2, in create File "/home/odoo/src/odoo/odoo/api.py", line 480, in _model_create_multi return create(self, arg) ^^^^^^^^^^^^^^^^^ File "/home/odoo/src/odoo/odoo/models.py", line 4975, in create records = self._create(data_list) ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/odoo/src/odoo/odoo/models.py", line 5159, in _create cr.execute(SQL( File "/home/odoo/src/odoo/odoo/sql_db.py", line 354, in execute res = self._obj.execute(query, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ psycopg2.errors.NotNullViolation: null value in column "notification_type" of relation "res_users" violates not-null constraint DETAIL: Failing row contains (58, 1, 578, t, 2025-02-15 00:04:13.1259, u1, null, null, 1, 1, null, null, 2025-02-15 00:04:13.1259, null, null, null, null, null).
The error seems to be caused by a missing value in the notification_type column when inserting a new user.
Is there an issue with the Contacts module, or am I doing something wrong?
I'm using Odoo 18 on Odoo.sh with the latest revision.
Thanks in advance for your help!