[FIX] uninstall: unlink of many2one fields having one2many dependencies

The revision
ea9ef7c39d
introduced a regression:
many2one fields having one2many depending on it declared before
the declaration of the many2one itself were not unlinked
during a module uninstall.

As a result, the column in the table was not dropped,
and the table itself was not deleted either, not even truncated.

Therefore, when you tried to reinstall the module, you had data
left.

The check of the one2many dependencies must not be performed
during an uninstall. Anyway, this wasn't blocking the uninstall
of the modules,
it was just preventing the field  to be deleted, that's all.

opw-710291
This commit is contained in:
Denis Ledoux
2017-03-06 13:02:39 +01:00
parent 8092ee8c6a
commit eaddb7caff
+2 -4
View File
@@ -141,10 +141,8 @@ class ir_model(osv.osv):
for model in self.browse(cr, user, ids, context):
if model.state != 'manual':
raise UserError(_("Model '%s' contains module data and cannot be removed!") % (model.name,))
# prevent screwing up fields that depend on these models' fields
for model in self.browse(cr, user, ids, context=context):
model.field_id._prepare_update()
# prevent screwing up fields that depend on these models' fields
model.field_id._prepare_update()
self._drop_table(cr, user, ids, context)
res = super(ir_model, self).unlink(cr, user, ids, context)