diff --git a/odoo/addons/base/models/ir_model.py b/odoo/addons/base/models/ir_model.py index e3f3f1ff137aa..70695640a8364 100644 --- a/odoo/addons/base/models/ir_model.py +++ b/odoo/addons/base/models/ir_model.py @@ -1425,12 +1425,14 @@ def safe_write(records, fname, value): records.invalidate_cache([fname]) for selection in self: - Model = self.env[selection.field_id.model] # The field may exist in database but not in registry. In this case # we allow the field to be skipped, but for production this should # be handled through a migration script. The ORM will take care of # the orphaned 'ir.model.fields' down the stack, and will log a # warning prompting the developer to write a migration script. + Model = self.env.get(selection.field_id.model) + if Model is None: + continue field = Model._fields.get(selection.field_id.name) if not field or not field.store or not Model._auto: continue