[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:
Goffin Simon
2017-03-15 09:17:53 +01:00
parent 8adc2ef440
commit 9f9657c04b
+3
View File
@@ -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()