[FIX] base: ensure existing ir.model.constraint xmlids are loaded
When we load a module and the SQL constraints exist both in the table
and in `ir_model_constraint` we need to ensure the xmlid is loaded.
Otherwise the record in `ir_model_constraint` is removed.
Since 4c9968397b we skip returning
existing non-updated constraint records in `_reflect_constraint`. This
leads to them being removed by the ORM. At the end of the load the ORM
sees the record in `ir_model_data` but not in the xmlid pool, thus it
removes it.
closes odoo/odoo#162105
X-original-commit: b5670c7f0d35d13affee2ae93158556346b7dd23
Signed-off-by: Christophe Simonis (chs) <chs@odoo.com>
This commit is contained in:
@@ -1873,9 +1873,11 @@ class IrModelConstraint(models.Model):
|
||||
conname = '%s_%s' % (model._table, key)
|
||||
module = constraint_module.get(key)
|
||||
record = self._reflect_constraint(model, conname, 'u', cons_text(definition), module, message)
|
||||
xml_id = '%s.constraint_%s' % (module, conname)
|
||||
if record:
|
||||
xml_id = '%s.constraint_%s' % (module, conname)
|
||||
data_list.append(dict(xml_id=xml_id, record=record))
|
||||
else:
|
||||
self.env['ir.model.data']._load_xmlid(xml_id)
|
||||
if data_list:
|
||||
self.env['ir.model.data']._update_xmlids(data_list)
|
||||
|
||||
|
||||
@@ -736,7 +736,7 @@ class TestCustomFields(TestCommonCustomFields):
|
||||
|
||||
# create a non-computed field, and assert how many queries it takes
|
||||
model_id = self.env['ir.model']._get_id('res.partner')
|
||||
query_count = 44
|
||||
query_count = 48
|
||||
with self.assertQueryCount(query_count):
|
||||
self.env.registry.clear_cache()
|
||||
self.env['ir.model.fields'].create({
|
||||
|
||||
Reference in New Issue
Block a user