[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) <rco@openerp.com>
Signed-off-by: Christophe Simonis <chs@odoo.com>
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user