From abd2b2e2caef0e073c8df4f973c9059f29bebdd9 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Wed, 8 Aug 2018 14:27:15 +0200 Subject: [PATCH] [FIX] account: reconcile through widget associate payment/invoice Create an invoice, validate it Create a payment from athe account.payment model (not the register payment wizard) click on the smart button payment matching, and match the invoice with the payment Reconcile Before this commit, the invoice was not part of the invoice_ids field of the payment, So, when printing the payment receipt or check, there was nothing on there After this commit, we associate the invoice with the payment, and the receipt prints what is expected OPW 1871575 closes #26245 --- addons/account/models/account_move.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 3b8968f8912..993a04abb7f 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -1542,6 +1542,21 @@ class AccountMoveLine(models.Model): action['domain'] = [('id', 'in', ids)] return action + @api.multi + def _payment_invoice_match(self): + ''' + If a partial reconciliation involves payments and invoices + mark the invoices as paid by the payments + Specifically made for len(self) == 2 + ''' + if not self: + return + invoice_ids = self.mapped('invoice_id') + payment_ids = self.mapped('payment_id') + + if payment_ids and invoice_ids: + payment_ids.write({'invoice_ids': [(4, inv.id, False) for inv in invoice_ids]}) + class AccountPartialReconcile(models.Model): _name = "account.partial.reconcile" @@ -1830,6 +1845,7 @@ class AccountPartialReconcile(models.Model): aml.append(vals['credit_move_id']) # Get value of matched percentage from both move before reconciliating lines = self.env['account.move.line'].browse(aml) + lines._payment_invoice_match() if lines[0].account_id.internal_type in ('receivable', 'payable'): percentage_before_rec = lines._get_matched_percentage() # Reconcile