[FIX] membership: remove date_cancel for draft invoices

In `action_cancel` method below, the date_cancel is set when the linked invoice
is canceled.
When the canceled invoiced was reset to draft, the date_cancel was not removed.
This change makes sense as the state of the membership line is changed from
`cancel` to `waiting` when the invoice is reset to draft.

Closes #14313
This commit is contained in:
Antonio Espinosa 2016-11-14 16:19:08 +01:00 committed by Martin Trigaux
parent adb12f95ea
commit aac0faafb8
No known key found for this signature in database
GPG Key ID: 7B0E288E7C0F83A7
1 changed files with 9 additions and 0 deletions

View File

@ -477,6 +477,15 @@ class Invoice(osv.osv):
'''Invoice'''
_inherit = 'account.invoice'
def action_cancel_draft(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.write(cr, uid, mlines, {'date_cancel': False}, context=context)
return super(Invoice, self).action_cancel_draft(cr, uid, ids, context=context)
def action_cancel(self, cr, uid, ids, context=None):
'''Create a 'date_cancel' on the membership_line object'''
member_line_obj = self.pool.get('membership.membership_line')