[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
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user