[FIX] account: invoices on unmatched payment

When unreconciling a payment from an invoice, the link between
the payment and the invoice (in many2many invoice_ids)was kept
and then the invoice still appeared when clicking on the button
invoices in the payment form view.

The invoice must be removed from invoice_ids.

opw:691692
This commit is contained in:
Goffin Simon
2016-10-26 13:50:55 +02:00
parent 1f06cc4168
commit 69c41c7e3c
+3
View File
@@ -972,6 +972,9 @@ class AccountMoveLine(models.Model):
return True
rec_move_ids = self.env['account.partial.reconcile']
for account_move_line in self:
for invoice in account_move_line.payment_id.invoice_ids:
if account_move_line in invoice.payment_move_line_ids:
account_move_line.payment_id.write({'invoice_ids': [(3, invoice.id, None)]})
rec_move_ids += account_move_line.matched_debit_ids
rec_move_ids += account_move_line.matched_credit_ids
return rec_move_ids.unlink()