diff options
| author | Lucas Perais (lpe) <lpe@odoo.com> | 2018-08-08 14:27:15 +0200 |
|---|---|---|
| committer | Lucas Perais (lpe) <lpe@odoo.com> | 2018-08-10 09:35:26 +0200 |
| commit | abd2b2e2caef0e073c8df4f973c9059f29bebdd9 (patch) | |
| tree | 966e002da143386b7f677c4806854c737b884df7 | |
| parent | 47c7d123da0050cc30d90ba5e983eaa005c18029 (diff) | |
[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
| -rw-r--r-- | addons/account/models/account_move.py | 16 |
1 files changed, 16 insertions, 0 deletions
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 |
