[FIX] ir.model.fields: better unlink
When droping a column, remove also the relation table in case of custom m2m field. The relation table needs to be dropped otherwise an unremovable constraint to the targetted table is kept (and anyway is not needed anymore).
This commit is contained in:
parent
6b274e4451
commit
6af3193d17
|
@ -312,6 +312,14 @@ class ir_model_fields(osv.osv):
|
|||
if column_name and (result and result[0] == 'r'):
|
||||
cr.execute('ALTER table "%s" DROP column "%s" cascade' % (model._table, field.name))
|
||||
model._columns.pop(field.name, None)
|
||||
|
||||
# remove m2m relation table for custom fields
|
||||
# we consider the m2m relation is only one way as it's not possible
|
||||
# to specify the relation table in the interface for custom fields
|
||||
# TODO master: maybe use ir.model.relations for custom fields
|
||||
if field.state == 'manual' and field.ttype == 'many2many':
|
||||
rel_name = self.pool[field.model]._all_columns[field.name].column._rel
|
||||
cr.execute('DROP table "%s"' % (rel_name))
|
||||
return True
|
||||
|
||||
def unlink(self, cr, user, ids, context=None):
|
||||
|
|
Loading…
Reference in New Issue