[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
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user