odoo/upgrade-util#319
Created by Victor Valet (vval)
Merged
at 85c5a6c0d3087d1a098983bafdbe93e525e8a520
Statuses:
- ci/runbot: Test upgrades between stable versions
- ci/upgrade_enterprise: Test upgrades for enterprise master
- label
- odoo-dev:master-rename_model_update_m2m_ir_model_fields-vval
- head
- d0403406898878443f522693c70eab763a938161
- merged
- 6 days ago by Upgrade, Christophe Simonis (chs)
odoo/upgrade-util | |
---|---|
master | #319 |
[FIX] util/pg: fix rename_model with m2m fields
In the case of renamed model being referenced in a many2many table (for having or being referenced in a m2m field), related ir_model_fields.column1
(and 2) aren't updated. However, the m2m tables column names themselves are properly updated. This lead to an error here from here because the column1
is referring to a column whose name is already overwritten, and to a crash here because the returned foreign keys list is empty but accessed at [0].
2025-09-07 09:59:00,226 27 ERROR db_3124720 odoo.addons.base.maintenance.migrations.base.0.0.0.pre-fix-fk: One of the table/field was missing x_hr_contract_x_employee_deduction_line_e2bef_rel.hr_contract_id / hr_version.id
2025-09-07 09:59:00,231 27 WARNING db_3124720 odoo.modules.loading: Transient module states were reset
2025-09-07 09:59:00,231 27 ERROR db_3124720 odoo.registry: Failed to load registry
2025-09-07 09:59:00,231 27 CRITICAL db_3124720 odoo.service.server: Failed to initialize database `db_3124720`.
Traceback (most recent call last):
File "/home/odoo/src/odoo/saas-18.4/odoo/service/server.py", line 1410, in preload_registries
registry = Registry.new(dbname, update_module=update_module, install_modules=config['init'], upgrade_modules=config['update'])
File "<decorator-gen-6>", line 2, in new
File "/home/odoo/src/odoo/saas-18.4/odoo/tools/func.py", line 89, in locked
return func(inst, *args, **kwargs)
File "/home/odoo/src/odoo/saas-18.4/odoo/orm/registry.py", line 175, in new
load_modules(
File "/home/odoo/src/odoo/saas-18.4/odoo/modules/loading.py", line 564, in load_modules
registry.init_models(cr, list(models_to_check), {'models_to_check': True, 'update_custom_fields': True})
File "/home/odoo/src/odoo/saas-18.4/odoo/orm/registry.py", line 742, in init_models
self.check_foreign_keys(cr)
File "/home/odoo/src/odoo/saas-18.4/odoo/orm/registry.py", line 881, in check_foreign_keys
conname = sql.get_foreign_keys(cr, table1, column1, table2, column2, ondelete)[0]
IndexError: list index out of range
vval_3124720_indexoutofrange> select id,model,name,state,column1,column2 from ir_model_fields where relation_table = 'x_hr_contract_x_employee_deduction_line_e2bef_rel'
+-------+-------------+--------------------------------+--------+----------------+------------------------------------+
| id | model | name | state | column1 | column2 |
|-------+-------------+--------------------------------+--------+----------------+------------------------------------|
| 12342 | hr.contract | x_studio_many2many_field_Ydvmh | manual | hr_contract_id | x_employee_deduction_line_e2bef_id |
+-------+-------------+--------------------------------+--------+----------------+------------------------------------+