From 9f9657c04b9ec1e7151f562f74b61efc92df58fa Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Tue, 14 Mar 2017 16:56:17 +0100 Subject: [PATCH] [FIX] base: unlinking ir.model.constraint When unlinking an ir.model, all the ir.model.constraint linked to this ir.model must be removed to avoid to call unexisting model. In stable version, the right fix would be to put an attribute ondelete=cascade on the field model of ir.model.constraint. In 10.0, the ir.model.constraint are created with module = the module where the related field has been declared. But when unlinking the ir.model in function _module_data_uninstall, the related ir.model.constraint to remove were chosen according to the removed modules. So with models declaring constraints on inherited fields, some problems occured because the model could be removed and not all the related constraints. opw:716032 --- odoo/addons/base/ir/ir_model.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/odoo/addons/base/ir/ir_model.py b/odoo/addons/base/ir/ir_model.py index 8627046790d..5e610641989 100644 --- a/odoo/addons/base/ir/ir_model.py +++ b/odoo/addons/base/ir/ir_model.py @@ -133,6 +133,9 @@ class IrModel(models.Model): # prevent screwing up fields that depend on these models' fields model.field_id._prepare_update() + imc = self.env['ir.model.constraint'].search([('model', 'in', self.ids)]) + imc.unlink() + self._drop_table() res = super(IrModel, self).unlink()