odoo/upgrade-util#287
Created by Sanchit Gupta (sagu)
Blocked
- Merge method
- Review
-
CI
- ci/runbot: Test upgrades between stable versions
- ci/upgrade_enterprise: Test upgrades for enterprise master
- label
- odoo-dev:master-mark_noupdate_flag-sagu
- head
- 75b0d78db9b7016712c0f6c196545fe4808330a9
odoo/upgrade-util | |
---|---|
master | #287 missing r+ |
[FIX] util/records:Mark records noupdate
If particular xml don't have noupdate marked but parent data
node have noupdate in that case from update_records_from_xml creating record as noupdate false
which is causing issue in future upgrade because it going for delete. For preventing such case adding noupdate flag to record and inherit created record acccoring to this commit by that //data
node or that xml node
itself.
use case:
client db don't have the documents.document_internal_folder
xmlid which is created when migrated to 18.0 from this script with noupdate false and because data node have noupdate true but particular xml don't have noupdate that is why it created as noupdate false and other inherit records also with noupdate and after migrating from onwards version related to that mail.alias records xml creating according to this
and later on version in 18.3 if related inherit model is changed but still some how use case of those records for preventing in that case.
before upgrade
timer_test_document_test=# select * from ir_model_data where name like '%document_internal_folder%'
;
id | create_uid | create_date | write_date | write_uid | res_id | noupdate | name | module | model
----+------------+-------------+------------+-----------+--------+----------+------+--------+-------
(0 rows)
before fix
timer_test_document_test=# select * from ir_model_data where name like '%document_internal_folder%'
;
id | create_uid | create_date | write_date | write_uid | res_id | noupdate | name | module | model
-------+------------+----------------------------+----------------------------+-----------+--------+----------+-------------------------------------+-----------+--------------------
39576 | | 2025-06-19 13:38:37.987267 | 2025-06-19 13:38:37.987267 | | 20 | f | document_internal_folder_mail_alias | documents | mail.alias
39577 | | 2025-06-19 13:38:37.987267 | 2025-06-19 13:38:37.987267 | | 20 | f | document_internal_folder | documents | documents.document
after fix
timer_test_document_test=# select * from ir_model_data where name like '%document_internal_folder%'
;
id | create_uid | create_date | write_date | write_uid | res_id | noupdate | name | module | model
-------+------------+----------------------------+----------------------------+-----------+--------+----------+-------------------------------------+-----------+--------------------
39576 | | 2025-06-19 13:41:40.343454 | 2025-06-19 13:41:40.343454 | | 20 | t | document_internal_folder_mail_alias | documents | mail.alias
39577 | | 2025-06-19 13:41:40.343454 | 2025-06-19 13:41:40.343454 | | 20 | t | document_internal_folder | documents | documents.document
Traceback (most recent call last):
File "/home/odoo/src/odoo/saas-18.3/odoo/service/server.py", line 1396, 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.3/odoo/tools/func.py", line 83, in locked
return func(inst, *args, **kwargs)
File "/home/odoo/src/odoo/saas-18.3/odoo/orm/registry.py", line 167, in new
load_modules(
File "/home/odoo/src/odoo/saas-18.3/odoo/modules/loading.py", line 509, in load_modules
env['ir.model.data']._process_end(registry.updated_modules)
File "/tmp/tmp2ipekce9/migrations/base/0.0.0/pre-models-no-model-data-delete.py", line 108, in _process_end
return super(IrModelData, self)._process_end(modules)
File "/home/odoo/src/odoo/saas-18.3/odoo/addons/base/models/ir_model.py", line 2589, in _process_end
self._process_end_unlink_record(record)
File "/home/odoo/src/odoo/saas-18.3/addons/website/models/ir_model_data.py", line 35, in _process_end_unlink_record
return super()._process_end_unlink_record(record)
File "/home/odoo/src/odoo/saas-18.3/odoo/addons/base/models/ir_model.py", line 2518, in _process_end_unlink_record
record.unlink()
File "/home/odoo/src/odoo/saas-18.3/odoo/orm/models.py", line 3913, in unlink
cr.execute(SQL(
File "/home/odoo/src/odoo/saas-18.3/odoo/sql_db.py", line 422, in execute
self._obj.execute(query, params)
psycopg2.errors.ForeignKeyViolation: update or delete on table "mail_alias" violates foreign key constraint "documents_document_alias_id_fkey" on table "documents_document"
DETAIL: Key (id)=(40) is still referenced from table "documents_document".
upg-2987024
opw-4874805