From b6d4cd5deb319c92a89961ec88f1fdc52560bd53 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Mon, 26 Feb 2018 14:25:50 +0100 Subject: [PATCH] [FIX] account: reconcile on move reversal Make an invoice for partner X Make a payment from partner X (not using the register payment button) On the invoice, you'll see your payment proposal Now, reverse the move of the payment Before this commit: On the invoice you *still have* the payment proposal This is because nothing reconciled the reversed entries with the original ones when they were created After this commit: The reversed moves are reconciled one on one with their original counterparts And the original payment doesn't show up anymore on the invoice's proposal OPW 1816462 OPW 1816641 --- addons/account/models/account_move.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index a3c37846348..fc20c5196dc 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -211,6 +211,15 @@ class AccountMove(models.Model): raise UserError(_("Cannot create unbalanced journal entry.")) return True + # Do not forward port in >= saas-14 + def _reconcile_reversed_pair(self, move, reversed_move): + amls_to_reconcile = move.line_ids + reversed_move.line_ids + accounts_reconcilable = amls_to_reconcile.mapped('account_id').filtered(lambda a: a.reconcile) + for account in accounts_reconcilable: + amls_for_account = amls_to_reconcile.filtered(lambda l: l.account_id.id == account.id) + amls_for_account.reconcile() + amls_to_reconcile = amls_to_reconcile - amls_for_account + @api.multi def reverse_moves(self, date=None, journal_id=None): date = date or fields.Date.today() @@ -225,6 +234,7 @@ class AccountMove(models.Model): 'credit': acm_line.debit, 'amount_currency': -acm_line.amount_currency }) + self._reconcile_reversed_pair(ac_move, reversed_move) reversed_moves |= reversed_move if reversed_moves: reversed_moves._post_validate()