diff options
| author | Raphael Collet <rco@odoo.com> | 2020-11-18 13:01:07 +0000 |
|---|---|---|
| committer | Raphael Collet <rco@odoo.com> | 2020-11-19 11:11:41 +0000 |
| commit | 1022ed23e461a12415e3467b00e844851803ff1d (patch) | |
| tree | 7d54d318d9d4f007f2798c5d89a30e440bc6e67c /odoo | |
| parent | 1fe9a5c886fcef34a5113fd77d74550c99a8a305 (diff) | |
[FIX] core: update of custom models in registry
When removing custom models from the registry, one also has to remove
indirect references to those model. One such reference is the name of
the custom model in its parent models' `_inherit_children`.
Not removing that reference causes a crash when one of the parent models
is extended: the parent model will make its children models recompute
some of their attributes (see method `_build_model_attributes`).
closes odoo/odoo#62002
X-original-commit: 07404bf5e93878b26468e2944c69885bbc688e57
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Diffstat (limited to 'odoo')
| -rw-r--r-- | odoo/addons/base/models/ir_model.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/odoo/addons/base/models/ir_model.py b/odoo/addons/base/models/ir_model.py index b8b43fcae39..db0a0130857 100644 --- a/odoo/addons/base/models/ir_model.py +++ b/odoo/addons/base/models/ir_model.py @@ -414,9 +414,13 @@ class IrModel(models.Model): def _add_manual_models(self): """ Add extra models to the registry. """ # clean up registry first - custom_models = [name for name, model_class in self.pool.items() if model_class._custom] - for name in custom_models: - del self.pool[name] + for name, Model in list(self.pool.items()): + if Model._custom: + del self.pool.models[name] + # remove the model's name from its parents' _inherit_children + for Parent in Model.__bases__: + if hasattr(Parent, 'pool'): + Parent._inherit_children.discard(name) # add manual models cr = self.env.cr cr.execute('SELECT * FROM ir_model WHERE state=%s', ['manual']) |
