[imp] modified meaning of operation 5 on o2m to delete the pointed rows if on delete cascade
bzr revid: nicolas.vanhoren@openerp.com-20110629162746-dn0tosycss4a0cne
This commit is contained in:
parent
36d98cb14f
commit
fa19ca6e47
|
@ -525,7 +525,13 @@ class one2many(_column):
|
|||
# Must use write() to recompute parent_store structure if needed
|
||||
obj.write(cr, user, [act[1]], {self._fields_id:id}, context=context or {})
|
||||
elif act[0] == 5:
|
||||
cr.execute('update '+_table+' set '+self._fields_id+'=null where '+self._fields_id+'=%s', (id,))
|
||||
reverse_rel = obj._all_columns.get(self._fields_id)
|
||||
assert reverse_rel, 'Trying to unlink the content of a o2m but the pointed object does not have a m2o'
|
||||
# if the pointed object has on delete cascade, just delete it
|
||||
if reverse_rel.column.ondelete == "cascade":
|
||||
obj.unlink(cr, user, obj.search(cr, user, [(self._fields_id,'=',id)], context), context)
|
||||
else:
|
||||
cr.execute('update '+_table+' set '+self._fields_id+'=null where '+self._fields_id+'=%s', (id,))
|
||||
elif act[0] == 6:
|
||||
# Must use write() to recompute parent_store structure if needed
|
||||
obj.write(cr, user, act[2], {self._fields_id:id}, context=context or {})
|
||||
|
|
Loading…
Reference in New Issue