Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][BUG] When migrating the rma module from v15 to v16 #395

Open
pleirb opened this issue Jun 19, 2024 · 4 comments · Fixed by #396
Open

[16.0][BUG] When migrating the rma module from v15 to v16 #395

pleirb opened this issue Jun 19, 2024 · 4 comments · Fixed by #396
Assignees
Labels

Comments

@pleirb
Copy link

pleirb commented Jun 19, 2024

After the update in the migrations folder of the rma module I receive this error when migrating from odoo 15 to 16

`2024-06-19 16:35:16,697 1 INFO mig odoo.modules.migration: module rma: Running migration [16.0.1.4.0>] post-migration
2024-06-19 16:35:16,716 1 INFO mig OpenUpgrade: rma: post-migration script called with version 15.0.1.3.0
2024-06-19 16:35:16,760 1 ERROR mig odoo.sql_db: bad query: INSERT INTO "stock_rule" ("action", "active", "auto", "company_id", "create_date", "create_uid", "delay", "group_propagation_option", "location_dest_id", "location_src_id", "name", "picking_type_id", "procure_method", "propagate_cancel", "propagate_carrier", "route_id", "sequence", "warehouse_id", "write_date", "write_uid") VALUES ('pull', true, 'manual', 1, '2024-06-19 16:35:15.665919', 1, 0, 'propagate', NULL, 9, '{"en_US": "Ofi: Cliente"}', NULL, 'make_to_stock', false, false, 30, 20, 1, '2024-06-19 16:35:15.665919', 1) RETURNING "id"
ERROR: null value in column "picking_type_id" of relation "stock_rule" violates not-null constraint
DETAIL: Failing row contains (90, 1, {"en_US": "Ofi: Cliente"}, 20, 1, 1, t, 2024-06-19 16:35:15.665919, pull, 2024-06-19 16:35:15.665919, null, propagate, null, null, 9, null, 0, 1, f, make_to_stock, null, 30, null, manual, f).

2024-06-19 16:35:16,760 1 ERROR mig OpenUpgrade: rma: error in migration script /odoo_env/src/OCA/rma/rma/migrations/16.0.1.4.0/post-migration.py: null value in column "picking_type_id" of relation "stock_rule" violates not-null constraint
DETAIL: Failing row contains (90, 1, {"en_US": "Ofi: Cliente"}, 20, 1, 1, t, 2024-06-19 16:35:15.665919, pull, 2024-06-19 16:35:15.665919, null, propagate, null, null, 9, null, 0, 1, f, make_to_stock, null, 30, null, manual, f).

2024-06-19 16:35:16,760 1 ERROR mig OpenUpgrade: null value in column "picking_type_id" of relation "stock_rule" violates not-null constraint
DETAIL: Failing row contains (90, 1, {"en_US": "Ofi: Cliente"}, 20, 1, 1, t, 2024-06-19 16:35:15.665919, pull, 2024-06-19 16:35:15.665919, null, propagate, null, null, 9, null, 0, 1, f, make_to_stock, null, 30, null, manual, f).

Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/openupgradelib/openupgrade.py", line 2296, in wrapped_function
version,
File "/odoo_env/src/OCA/rma/rma/migrations/16.0.1.4.0/post-migration.py", line 13, in migrate
route_vals = wh._create_or_update_route()
File "/odoo_env/src/odoo/addons/stock/models/stock_warehouse.py", line 480, in _create_or_update_route
self._find_existing_rule_or_create(rules_list)
File "/odoo_env/src/odoo/addons/stock/models/stock_warehouse.py", line 610, in _find_existing_rule_or_create
self.env['stock.rule'].create(rule_vals)
File "", line 2, in create
File "/odoo_env/src/odoo/odoo/api.py", line 414, in _model_create_multi
return create(self, [arg])
File "/odoo_env/src/odoo/odoo/addons/base/models/ir_fields.py", line 670, in create
recs = super().create(vals_list)
File "", line 2, in create
File "/odoo_env/src/odoo/odoo/api.py", line 415, in _model_create_multi
return create(self, arg)
File "/odoo_env/src/odoo/odoo/models.py", line 3975, in create
records = self._create(data_list)
File "/odoo_env/src/odoo/odoo/models.py", line 4158, in _create
[tuple(row) for row in rows],
File "/odoo_env/src/odoo/odoo/sql_db.py", line 321, in execute
res = self._obj.execute(query, params)
psycopg2.IntegrityError: null value in column "picking_type_id" of relation "stock_rule" violates not-null constraint
DETAIL: Failing row contains (90, 1, {"en_US": "Ofi: Cliente"}, 20, 1, 1, t, 2024-06-19 16:35:15.665919, pull, 2024-06-19 16:35:15.665919, null, propagate, null, null, 9, null, 0, 1, f, make_to_stock, null, 30, null, manual, f).
`

@pleirb pleirb added the bug label Jun 19, 2024
@pleirb pleirb changed the title [BUG] When migrating the rma module from v15 to v16 [16.0][BUG] When migrating the rma module from v15 to v16 Jun 19, 2024
@pleirb
Copy link
Author

pleirb commented Jun 19, 2024

If I delete the migrations folder (which was added 2 weeks ago by @mt-software-de and @victoralmau) of the rma module, the migration from 15 to 16 is done correctly

@mt-software-de
Copy link
Contributor

mt-software-de commented Jun 19, 2024

The commit what was used was cherry-picked from v14.
And was not ready to merge yet.

But to help here, the fields rma_in_type_id and/or rma_out_type_id not set on the warehouse, the are used and mandatory to create the new rules for the rma proc run.

Within the migration we have to ensure, that those fields are set.
Therefor _create_or_update_sequences_and_picking_types needs to be called at the migration.
This would then create the missing stock.picking.type.
But to ensure that no other stock.picking.type is changed, we have to overwrite _get_picking_type_update_values and checking the context value rma_post_init_hook. Like it is done in

def _get_routes_values(self):

if self.env.context.get("rma_post_init_hook"):

@pedrobaeza
Copy link
Member

We will check it soon. Thanks for the extra info, Michael.

@pleirb
Copy link
Author

pleirb commented Jun 19, 2024

Thanks @mt-software-de I have configured all the warehouses so that the rma_loc_id, rma_in_type_id and rma_out_type_id fields have a value and after running the migration again this error no longer occurs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants