Skip to content

Conversation

vval-odoo
Copy link
Contributor

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 |
+-------+-------------+--------------------------------+--------+----------------+------------------------------------+

upg-3124720
tbg

@robodoo
Copy link
Contributor

robodoo commented Sep 11, 2025

Pull request status dashboard

@vval-odoo vval-odoo force-pushed the master-rename_model_update_m2m_ir_model_fields-vval branch from 7b97661 to b5b616e Compare September 12, 2025 13:43
@KangOl
Copy link
Contributor

KangOl commented Sep 12, 2025

upgradeci retry with always only hr

1 similar comment
@aj-fuentes
Copy link
Contributor

upgradeci retry with always only hr

@aj-fuentes
Copy link
Contributor

Could you rebase this branch to ensure we don't get errors in the CI?

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 because the `column1` is referring to a column
whose name is already overwritten, and to a crash because the returned foreign
keys list is empty but accessed at [0].

[tbg](https://upgrade.odoo.com/odoo/tbg/2156)
@vval-odoo vval-odoo force-pushed the master-rename_model_update_m2m_ir_model_fields-vval branch from b5b616e to d040340 Compare September 24, 2025 11:37
Copy link
Contributor

@KangOl KangOl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 this pull request may close these issues.

4 participants