From 31ba0fb41b5b468558e10acff096dfbbf2b720cd Mon Sep 17 00:00:00 2001 From: Adrian Torres Date: Tue, 21 Nov 2017 11:13:24 +0100 Subject: [PATCH] [FIX] ir_module_module: unlink uninstalled modules (#21111) Before this revision, unlinking a module which has been uninstalled at least once would raise an Exception because base_module_uninstall contains a field model_id which is required. The unlink method of ir_module_module would try to set this field to NULL which is of course a constraint violation. This is fixed by manually unlinking the respective base_module_uninstall records before the unlinking of the ir_module_module record itself Fixes #20720 DO NOT FORWARD-PORT --- odoo/addons/base/module/module.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/odoo/addons/base/module/module.py b/odoo/addons/base/module/module.py index 920929a14d2..6fe4bbf525e 100644 --- a/odoo/addons/base/module/module.py +++ b/odoo/addons/base/module/module.py @@ -305,6 +305,14 @@ class Module(models.Model): if module.state in ('installed', 'to upgrade', 'to remove', 'to install'): raise UserError(_('You try to remove a module that is installed or will be installed')) self.clear_caches() + # Installing a module creates entries in base.module.uninstall, during + # the unlink process of ir.module.module we try to update the + # base.module.uninstall table's module_id to null, which violates a + # non-null constraint, effectively raising an Exception. + # V11-only !!DO NOT FORWARD-PORT!! + self.env['base.module.uninstall'].search( + [('module_id', 'in', self.ids)] + ).unlink() return super(Module, self).unlink() @staticmethod