[FIX] membership: remove membership line when deleting invoice

Apply the same behaviour as the unlink done on account.invoice.line.
This should properly be implemented with a ondelete=cascade but this is not
possible in stable version as it requires an update.
This commit is contained in:
Antonio Espinosa
2016-02-04 14:48:47 +01:00
committed by Martin Trigaux
parent a3ec5a35a5
commit d036e3be1a
+11
View File
@@ -488,6 +488,16 @@ class Invoice(osv.osv):
member_line_obj.write(cr, uid, mlines, {'date_cancel': today})
return super(Invoice, self).action_cancel(cr, uid, ids, context=context)
# TODO master: replace by ondelete='cascade'
def unlink(self, cr, uid, ids, context=None):
member_line_obj = self.pool.get('membership.membership_line')
for invoice in self.browse(cr, uid, ids, context=context):
mlines = member_line_obj.search(cr, uid,
[('account_invoice_line', 'in',
[l.id for l in invoice.invoice_line])])
member_line_obj.unlink(cr, uid, mlines, context=context)
return super(Invoice, self).unlink(cr, uid, ids, context=context)
class account_invoice_line(osv.osv):
_inherit='account.invoice.line'
@@ -520,6 +530,7 @@ class account_invoice_line(osv.osv):
member_line_obj.unlink(cr, uid, ml_ids, context=context)
return res
# TODO master: replace by ondelete='cascade'
def unlink(self, cr, uid, ids, context=None):
"""Remove Membership Line Record for Account Invoice Line
"""