From 7affe69117b1b0f252e5cad0ca2523e8a217fbb2 Mon Sep 17 00:00:00 2001 From: Adrian Torres Date: Tue, 5 Nov 2019 10:33:38 +0000 Subject: [PATCH] [FIX] base: avoid triggering recomputation when deleted selection In 6b048a8b8 most issue with trigger causing error when uninstalling a module were solved. But there was a particular case if the current uninstallation of modules there was an update of `ir.model.fields.selection` to be removed. The unlink of `ir.model.fields.selection` would cause a `setup_models` call that would add all removed triggers back and possibly down the line cause an trigger recomputation error. With this changeset, we do as is already done for ir.model.fields and do not re-initialize the registry during module uninstallation. opw-2098915 closes #39796 closes odoo/odoo#39824 X-original-commit: 0ccf2ab8e7f3edabb2d3d4c17a20829de21cca49 Signed-off-by: Adrian Torres (adt) --- odoo/addons/base/models/ir_model.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/odoo/addons/base/models/ir_model.py b/odoo/addons/base/models/ir_model.py index 34928a421ac..c441929a3ef 100644 --- a/odoo/addons/base/models/ir_model.py +++ b/odoo/addons/base/models/ir_model.py @@ -1179,8 +1179,11 @@ class IrModelSelection(models.Model): result = super().unlink() - # setup models; this re-initializes model in registry - self.pool.setup_models(self._cr) + # Reload registry for normal unlink only. For module uninstall, the + # reload is done independently in odoo.modules.loading. + if not self._context.get(MODULE_UNINSTALL_FLAG): + # setup models; this re-initializes model in registry + self.pool.setup_models(self._cr) return result