upgrade-util icon indicating copy to clipboard operation
upgrade-util copied to clipboard

[FIX] util/models: Fix upgradeError

Open sagu-odoo opened this issue 1 month ago • 15 comments

There are two model A and B and there is x many2many field in A model which is manual and relation with B. Now, B model is removed. So, For that relation table is droped but the field will there and in relation model _unknown will be set https://github.com/odoo/upgrade-util/blob/25cb37389b527f442acfbb704e07769d69b11b9f/src/util/models.py#L242.

As the field belongs to A. So, table will be recreated from here as it checks only table is there or not and after that from here env variable it have in gone and below menitoned traceback will raise.

To Fix removing M2m field and added into migration report

Traceback (most recent call last):
  File "/home/odoo/src/odoo/19.0/odoo/service/server.py", line 1509, in preload_registries
    registry = Registry.new(dbname, update_module=update_module, install_modules=config['init'], upgrade_modules=config['update'], reinit_modules=config['reinit'])
  File "/home/odoo/src/odoo/19.0/odoo/tools/func.py", line 88, in locked
    return func(inst, *args, **kwargs)
  File "/home/odoo/src/odoo/19.0/odoo/orm/registry.py", line 185, in new
    load_modules(
  File "/home/odoo/src/odoo/19.0/odoo/modules/loading.py", line 580, in load_modules
    model._register_hook()
  File "/tmp/tmpkw62chtg/migrations/base/0.0.0/pre-models-ir_model_relation.py", line 49, in _register_hook
    raise util.MigrationError("The following m2m relations have respawn:\n%s" % back_m2m)
odoo.upgrade.util.exceptions.UpgradeError: The following m2m relations have respawn:
 - x_res_partner_uom_category_rel via uom.category

upg-3191893 opw-5175564

sagu-odoo avatar Nov 03 '25 13:11 sagu-odoo

Pull request status dashboard

robodoo avatar Nov 03 '25 13:11 robodoo

Hello @odoo/upgrade , could you please review the pr ?.

Thanks in advance

sagu-odoo avatar Nov 06 '25 05:11 sagu-odoo

Thanks for the review. I found that there is a TBG for this (link). Since we are removing the table, the related fields should also be removed and should be added into migration report. This will ensure the upgrade does not get blocked, and if any of those fields are still used somewhere in a view, we can fix it at that time. This way, the user can at least proceed to test the other flows.

sagu-odoo avatar Nov 06 '25 08:11 sagu-odoo

Hello @jjmaksoud , could you please have a look a another look ?.

Thanks

sagu-odoo avatar Nov 12 '25 09:11 sagu-odoo

the related fields should also be removed and should be added into migration report

Yes this would be a better alternative for manual m2ms

jjmaksoud avatar Nov 12 '25 11:11 jjmaksoud

I have made the changes. could you Please have a look ?.

sagu-odoo avatar Nov 13 '25 07:11 sagu-odoo

upgradeci retry with base

sagu-odoo avatar Nov 13 '25 13:11 sagu-odoo

upgradeci retry with always only base

jjmaksoud avatar Nov 13 '25 13:11 jjmaksoud

could you please have a another look?. If still anything left do let me know :(

sagu-odoo avatar Nov 17 '25 09:11 sagu-odoo

Another ticket open with same issue OPW : 5288808

py
Traceback (most recent call last):
  File "/home/odoo/src/odoo/19.0/odoo/service/server.py", line 1514, in preload_registries
    registry = Registry.new(dbname, update_module=update_module, install_modules=config['init'], upgrade_modules=config['update'], reinit_modules=config['reinit'])
  File "/home/odoo/src/odoo/19.0/odoo/tools/func.py", line 88, in locked
    return func(inst, *args, **kwargs)
  File "/home/odoo/src/odoo/19.0/odoo/orm/registry.py", line 186, in new
    load_modules(
  File "/home/odoo/src/odoo/19.0/odoo/modules/loading.py", line 586, in load_modules
    model._register_hook()
  File "/tmp/tmpfmydwi5l/migrations/base/0.0.0/pre-models-ir_model_relation.py", line 49, in _register_hook
    raise util.MigrationError("The following m2m relations have respawn:\n%s" % back_m2m)
odoo.upgrade.util.exceptions.UpgradeError: The following m2m relations have respawn:
 - x_account_move_line_uom_category_rel via uom.category

higo-odoo avatar Nov 24 '25 10:11 higo-odoo

Can you please reword the commit message, now that you remove the manual m2m fields linked to the removed model?

KangOl avatar Nov 24 '25 11:11 KangOl

in commit message already done but forgot to add in description updated there also ..

sagu-odoo avatar Nov 24 '25 11:11 sagu-odoo

The title is still wrong: you are not preventing the removal of manual relation tables anymore.

KangOl avatar Nov 24 '25 12:11 KangOl

I missed this. done

sagu-odoo avatar Nov 24 '25 12:11 sagu-odoo

@KangOl , could you please have a look ?. ;(

sagu-odoo avatar Nov 27 '25 08:11 sagu-odoo