summaryrefslogtreecommitdiff
path: root/odoo/modules
diff options
context:
space:
mode:
authorDamien Bouvy <dbo@odoo.com>2020-01-30 15:32:13 +0000
committerDamien Bouvy <dbo@odoo.com>2020-01-31 12:06:46 +0000
commitc643be7679921026a87ff307d57b38c174ec439e (patch)
treecb8ef482293113e95050e92ecfdc3cae08ae726b /odoo/modules
parenteaccecd6cc2e21753240b44a42a2040d82de0fe1 (diff)
[IMP] base: ensure correct inheritance chain in registry
When removing a custom model, it remained listed in the base classes (normally `base` and also possibly a list of mixins; e.g. `mail.thread` or `mail.activity.mixin`) list of inheriting classes, possibly causing a crash when trying to reload the registry. This commit ensures that any custom model is removed from its parent class `_inherit_children` set; it will be re-added automatically during the call to `_build_model` if the custom model still exists. Co-Authored-By: Raphaƫl Collet <rco@odoo.com>
Diffstat (limited to 'odoo/modules')
-rw-r--r--odoo/modules/registry.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/odoo/modules/registry.py b/odoo/modules/registry.py
index dc03d0b24d3..ddb1631ec51 100644
--- a/odoo/modules/registry.py
+++ b/odoo/modules/registry.py
@@ -183,6 +183,13 @@ class Registry(Mapping):
""" Add or replace a model in the registry."""
self.models[model_name] = model
+ def __delitem__(self, model_name):
+ """ Remove a (custom) model from the registry. """
+ del self.models[model_name]
+ # the custom model can inherit from mixins ('mail.thread', ...)
+ for Model in self.models.values():
+ Model._inherit_children.discard(model_name)
+
def descendants(self, model_names, *kinds):
""" Return the models corresponding to ``model_names`` and all those
that inherit/inherits from them.