From 2e961e1d640af0a6ef9a5b46a000def5866bbf68 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Tue, 16 May 2023 14:47:31 +0200 Subject: [PATCH] [FIX] account_reconciliation_widget: Multiple blue lines In case of multiple blue lines, the code was not working properly, as the old temporary journal entry was being deleted several times. This situation is handled in this commit. --- .../models/account_bank_statement.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/account_reconciliation_widget/models/account_bank_statement.py b/account_reconciliation_widget/models/account_bank_statement.py index 5ff9ae02..f7849f5e 100644 --- a/account_reconciliation_widget/models/account_bank_statement.py +++ b/account_reconciliation_widget/models/account_bank_statement.py @@ -129,15 +129,18 @@ class AccountBankStatementLine(models.Model): # but the generated move on statement post should be removed and link the # payment one for not having double entry # TODO: To mix already done payments with new ones. Not sure if possible. + old_move = self.move_id.with_context(force_delete=True) for aml_rec in payment_aml_rec: aml_rec.with_context(check_move_validity=False).write( {"statement_line_id": self.id} ) - old_move = self.move_id.with_context(force_delete=True) + # This overwrites the value on each loop, so only one will be linked, but + # there's no better solution in this case self.move_id = aml_rec.move_id.id + counterpart_moves |= aml_rec.move_id + if payment_aml_rec: old_move.button_draft() old_move.unlink() - counterpart_moves |= aml_rec.move_id # Create move line(s). Either matching an existing journal entry # (eg. invoice), in which case we reconcile the existing and the # new move lines together, or being a write-off.