summaryrefslogtreecommitdiff
path: root/odoo/modules/db.py
diff options
context:
space:
mode:
authorMartin Trigaux <mat@odoo.com>2019-04-23 12:53:20 +0000
committerMartin Trigaux <mat@odoo.com>2019-06-11 12:04:08 +0000
commit8f88570ca18061716fd6e246b9d16aa2cbc24f3a (patch)
treec4903942817c08eb92a26b60600e878013de84a0 /odoo/modules/db.py
parent2843dcfaa07ef98e0d44d33a24270a308a2b97ad (diff)
[FIX] base: proper removal of xmlid after update
Context: After a module update, the records present in ir_model_data table but not in self.pool.loaded_xmlids are considered as no longer needed and should be removed. An exception is done with noupdate=true entries. Bug 1: Entries with noupdate=NULL are not considered in the evaluation and are ignored while it may be worth deleting. Bug 2: Some records with their external id being automatically created are not present in self.pool.loaded_xmlids and may get removed after updating a module. By a lucky coincidence, bug 1 make it so that records targeted by bug 2 are ignored and not deleted (the "automagically" created ir.model.data often lack a noupdate value). Fix Bug 1: Use a COALESCE to find both records with noupdate=NULL and noupdate=false Fix Bug 2: Depends on the source of the generated external id: - ir.model: The entries created through _reflect_model were not loaded in self.loaded_xmlids Use the proper ORM method _update_xmlids that correctly populates self.pool.loaded_xmlids - ir.model.category: The categories were generated when the db was initalised, doing SQL was not avoidable. Create the categories in noupdate to avoid it being considered for removal. - ir.property: Are always created in noupdate in data files but in stock_account it was manually created without being in noupdate closes odoo/odoo#32881 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com> Co-authored-by: Raphael Collet <rco@odoo.com>
Diffstat (limited to 'odoo/modules/db.py')
-rw-r--r--odoo/modules/db.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/odoo/modules/db.py b/odoo/modules/db.py
index 3a432f0fecb..b917718fdb6 100644
--- a/odoo/modules/db.py
+++ b/odoo/modules/db.py
@@ -108,8 +108,8 @@ def create_categories(cr, categories):
(name, parent_id) \
VALUES (%s, %s) RETURNING id', (categories[0], p_id))
c_id = cr.fetchone()[0]
- cr.execute('INSERT INTO ir_model_data (module, name, res_id, model) \
- VALUES (%s, %s, %s, %s)', ('base', xml_id, c_id, 'ir.module.category'))
+ cr.execute('INSERT INTO ir_model_data (module, name, res_id, model, noupdate) \
+ VALUES (%s, %s, %s, %s, %s)', ('base', xml_id, c_id, 'ir.module.category', True))
else:
c_id = c_id[0]
p_id = c_id