From 85c3fd8b73b9eddd4c9035a6d9c8196a2c70c6ae Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Mon, 6 Jul 2020 09:20:48 +0000 Subject: [PATCH] [FIX] core: do not mark `ir.model*` unique fields as modified These field combinations [1] are actually secondary keys. They are unique and represent the record identity. Marking them as modified had a nasty side-effect: on some models, there is a m2o to an ir.model and a stored related to ir.model/model that will be recomputed at each model reflection. This can take some time on big tables. Moreover, some other stored fields may depend on those ir.model/model related store, which adds useless time lost at recomputing unchanged values. [1] ir.model/model, ir.model.fields/{model,name} and ir.model.selection/{field_id,name} closes odoo/odoo#54126 X-original-commit: db013a01ca4e10640ac33a59466c9cb5746e3698 Signed-off-by: Raphael Collet (rco) Signed-off-by: Christophe Simonis --- odoo/addons/base/models/ir_model.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/odoo/addons/base/models/ir_model.py b/odoo/addons/base/models/ir_model.py index 05505d4a604..776007f990c 100644 --- a/odoo/addons/base/models/ir_model.py +++ b/odoo/addons/base/models/ir_model.py @@ -383,7 +383,7 @@ class IrModel(models.Model): ids = upsert(self.env.cr, self._table, cols, rows, ['model']) for row, id_ in zip(rows, ids): model_ids[row[0]] = id_ - self.pool.post_init(mark_modified, self.browse(ids), cols) + self.pool.post_init(mark_modified, self.browse(ids), cols[1:]) # update their XML id module = self._context.get('module') @@ -1032,7 +1032,7 @@ class IrModelFields(models.Model): ids = upsert(cr, self._table, cols, rows, ['model', 'name']) for row, id_ in zip(rows, ids): field_ids[row[:2]] = id_ - self.pool.post_init(mark_modified, self.browse(ids), cols) + self.pool.post_init(mark_modified, self.browse(ids), cols[2:]) # update their XML id module = self._context.get('module') @@ -1208,7 +1208,7 @@ class IrModelSelection(models.Model): rows = [key + val for key, val in expected.items() if existing.get(key) != val] if rows: ids = upsert(cr, self._table, cols, rows, ['field_id', 'value']) - self.pool.post_init(mark_modified, self.browse(ids), cols) + self.pool.post_init(mark_modified, self.browse(ids), cols[2:]) # update their XML ids module = self._context.get('module')