[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
This commit is contained in:
Lucas Perais (lpe)
2018-08-10 09:35:26 +02:00
parent 47c7d123da
commit abd2b2e2ca
+16
View File
@@ -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