Skip to content

Commit 52bdb16

Browse files
rco-odooalexis-via
authored andcommitted
[FIX] base: prevent crash when removing a model on module upgrade
Fix backported from v16 to v14
1 parent 1bbabff commit 52bdb16

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

odoo/addons/base/models/ir_model.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1425,12 +1425,14 @@ def safe_write(records, fname, value):
14251425
records.invalidate_cache([fname])
14261426

14271427
for selection in self:
1428-
Model = self.env[selection.field_id.model]
14291428
# The field may exist in database but not in registry. In this case
14301429
# we allow the field to be skipped, but for production this should
14311430
# be handled through a migration script. The ORM will take care of
14321431
# the orphaned 'ir.model.fields' down the stack, and will log a
14331432
# warning prompting the developer to write a migration script.
1433+
Model = self.env.get(selection.field_id.model)
1434+
if Model is None:
1435+
continue
14341436
field = Model._fields.get(selection.field_id.name)
14351437
if not field or not field.store or not Model._auto:
14361438
continue

0 commit comments

Comments
 (0)