[FIX] base_action_rule: ignore uninstalled models

Before this commit, creating a base_action_rule with model X from module
A and then uninstalling module A would make the database crash because
the algorithm would look for an uninstalled model during the Registry
reinitialization.

i.e. Install project and base_action_rule, create a base_action_rule
depending on model project.task, try to uninstall Project -> BOOM!

This is fixed by checking if the model obtained is None, in which case
we log a warning (for cleanup) and skip to the next iteration (continue)

opw-777301
This commit is contained in:
Adrian Torres
2017-10-24 13:36:41 +02:00
parent b26e0b9292
commit 38f1875e0b
@@ -317,7 +317,15 @@ class BaseActionRule(models.Model):
# retrieve all actions, and patch their corresponding model
for action_rule in self.with_context({}).search([]):
Model = self.env[action_rule.model]
Model = self.env.get(action_rule.model)
# Do not crash if the model of the base_action_rule was uninstalled
if Model is None:
_logger.warning("Action rule with ID %d depends on model %s" %
(action_rule.id,
action_rule.model))
continue
if action_rule.kind == 'on_create':
patch(Model, 'create', make_create())