[FIX] models: do not delete ir.model.fields in _field_create (#13565)
Following 5c5d0865b9, apparently unused records
are simply deleted after updating existing ones. This causes an issue when a
module is installed or upgraded. The inspection of `ir.model.fields` records
is based on a *partial* registry (not all modules loaded); therefore records
will be deleted and recreated afterwards. This triggers inconsistencies in
other models that refer to `ir.model.fields`, like server actions, base action
rules, mail templates, etc.: many2one fields will be set to null!
This commit is contained in:
committed by
Christophe Simonis
parent
be8bbc2396
commit
16a0b3b249
+1
-6
@@ -443,7 +443,7 @@ class BaseModel(object):
|
||||
raise UserError(_("Serialization field `%s` not found for sparse field `%s`!") % (f.serialization_field, k))
|
||||
vals['serialization_field_id'] = serialization_field_id[0]
|
||||
|
||||
col = cols.pop(k, None)
|
||||
col = cols.get(k)
|
||||
if not col:
|
||||
cr.execute('select nextval(%s)', ('ir_model_fields_id_seq',))
|
||||
id = cr.fetchone()[0]
|
||||
@@ -472,11 +472,6 @@ class BaseModel(object):
|
||||
cr.execute(query, vals)
|
||||
break
|
||||
|
||||
# remove ir_model_fields that should not be there
|
||||
if cols:
|
||||
ids = tuple(col['id'] for col in cols.itervalues())
|
||||
cr.execute("DELETE FROM ir_model_fields WHERE id IN %s", (ids,))
|
||||
|
||||
self.invalidate_cache(cr, SUPERUSER_ID)
|
||||
|
||||
@api.model
|
||||
|
||||
Reference in New Issue
Block a user