From b9d1d6dbc08c49b7662cca5a3fb0aa3e69653dfe Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Mon, 9 Sep 2024 14:42:29 +0200 Subject: [PATCH] [FIX] account_reconcile_oca: Fix wrong display on reconciled moves If your reconcile an invoice and in the old option, the reconcile widget shows something weird with three lines but we should have only two. The data was right with 2 lines only. --- .../models/account_bank_statement_line.py | 9 ++---- .../tests/test_bank_account_reconcile.py | 32 +++++++++++++++++++ 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/account_reconcile_oca/models/account_bank_statement_line.py b/account_reconcile_oca/models/account_bank_statement_line.py index db0a3731..abba3e11 100644 --- a/account_reconcile_oca/models/account_bank_statement_line.py +++ b/account_reconcile_oca/models/account_bank_statement_line.py @@ -438,7 +438,7 @@ class AccountBankStatementLine(models.Model): return self.partner_id = self.manual_partner_id - @api.depends("reconcile_data") + @api.depends("reconcile_data", "is_reconciled") def _compute_reconcile_data_info(self): for record in self: if record.reconcile_data: @@ -553,11 +553,6 @@ class AccountBankStatementLine(models.Model): reconcile_auxiliary_id, self.manual_reference, ) - else: - other_lines = ( - other_lines.matched_credit_ids.credit_move_id - | other_lines.matched_debit_ids.debit_move_id - ) for line in other_lines: reconcile_auxiliary_id, lines = self._get_reconcile_line( line, "other", from_unreconcile=from_unreconcile @@ -579,7 +574,7 @@ class AccountBankStatementLine(models.Model): result = getattr(self, "_reconcile_bank_line_%s" % self.reconcile_mode)( self._prepare_reconcile_line_data(self.reconcile_data_info["data"]) ) - self.reconcile_data_info = False + self.reconcile_data = False return result def _reconcile_bank_line_edit(self, data): diff --git a/account_reconcile_oca/tests/test_bank_account_reconcile.py b/account_reconcile_oca/tests/test_bank_account_reconcile.py index bead9237..9fcfb51b 100644 --- a/account_reconcile_oca/tests/test_bank_account_reconcile.py +++ b/account_reconcile_oca/tests/test_bank_account_reconcile.py @@ -200,7 +200,11 @@ class TestReconciliationWidget(TestAccountReconciliationCommon): lambda r: r.account_id == self.bank_journal_euro.suspense_account_id ) ) + number_of_lines = len(bank_stmt_line.reconcile_data_info["data"]) bank_stmt_line.reconcile_bank_line() + self.assertEqual( + number_of_lines, len(bank_stmt_line.reconcile_data_info["data"]) + ) self.assertTrue(bank_stmt_line.is_reconciled) self.assertFalse( bank_stmt_line.move_id.line_ids.filtered( @@ -267,7 +271,11 @@ class TestReconciliationWidget(TestAccountReconciliationCommon): self.assertTrue(f.can_reconcile) self.assertEqual(inv1.amount_residual_signed, 100) self.assertEqual(inv2.amount_residual_signed, 100) + number_of_lines = len(bank_stmt_line.reconcile_data_info["data"]) bank_stmt_line.reconcile_bank_line() + self.assertEqual( + number_of_lines, len(bank_stmt_line.reconcile_data_info["data"]) + ) self.assertEqual(inv1.amount_residual_signed, 30) self.assertEqual(inv2.amount_residual_signed, 70) @@ -327,7 +335,11 @@ class TestReconciliationWidget(TestAccountReconciliationCommon): self.assertTrue(f.can_reconcile) self.assertEqual(inv1.amount_residual_signed, -100) self.assertEqual(inv2.amount_residual_signed, -100) + number_of_lines = len(bank_stmt_line.reconcile_data_info["data"]) bank_stmt_line.reconcile_bank_line() + self.assertEqual( + number_of_lines, len(bank_stmt_line.reconcile_data_info["data"]) + ) self.assertEqual(inv1.amount_residual_signed, -30) self.assertEqual(inv2.amount_residual_signed, -70) @@ -360,7 +372,11 @@ class TestReconciliationWidget(TestAccountReconciliationCommon): self.assertFalse(f.can_reconcile) f.manual_model_id = self.rule self.assertTrue(f.can_reconcile) + number_of_lines = len(bank_stmt_line.reconcile_data_info["data"]) bank_stmt_line.reconcile_bank_line() + self.assertEqual( + number_of_lines, len(bank_stmt_line.reconcile_data_info["data"]) + ) self.assertEqual(2, len(bank_stmt_line.move_id.line_ids)) self.assertTrue( bank_stmt_line.move_id.line_ids.filtered( @@ -400,7 +416,11 @@ class TestReconciliationWidget(TestAccountReconciliationCommon): self.assertFalse(f.can_reconcile) f.manual_model_id = self.rule self.assertTrue(f.can_reconcile) + number_of_lines = len(bank_stmt_line.reconcile_data_info["data"]) bank_stmt_line.reconcile_bank_line() + self.assertEqual( + number_of_lines, len(bank_stmt_line.reconcile_data_info["data"]) + ) self.assertEqual(3, len(bank_stmt_line.move_id.line_ids)) self.assertTrue( bank_stmt_line.move_id.line_ids.filtered( @@ -453,7 +473,11 @@ class TestReconciliationWidget(TestAccountReconciliationCommon): self.assertFalse(f.can_reconcile) f.manual_model_id = self.rule self.assertTrue(f.can_reconcile) + number_of_lines = len(bank_stmt_line.reconcile_data_info["data"]) bank_stmt_line.reconcile_bank_line() + self.assertEqual( + number_of_lines, len(bank_stmt_line.reconcile_data_info["data"]) + ) self.assertNotEqual(self.current_assets_account, receivable1.account_id) self.assertTrue( bank_stmt_line.move_id.line_ids.filtered( @@ -541,7 +565,11 @@ class TestReconciliationWidget(TestAccountReconciliationCommon): f.add_account_move_line_id = receivable1 self.assertFalse(f.add_account_move_line_id) self.assertTrue(bank_stmt_line.can_reconcile) + number_of_lines = len(bank_stmt_line.reconcile_data_info["data"]) bank_stmt_line.reconcile_bank_line() + self.assertEqual( + number_of_lines, len(bank_stmt_line.reconcile_data_info["data"]) + ) self.assertIn( self.bank_journal_euro.suspense_account_id, bank_stmt_line.mapped("move_id.line_ids.account_id"), @@ -1018,7 +1046,11 @@ class TestReconciliationWidget(TestAccountReconciliationCommon): self.assertFalse(f.add_account_move_line_id) self.assertTrue(f.can_reconcile) self.assertTrue(bank_stmt_line.can_reconcile) + number_of_lines = len(bank_stmt_line.reconcile_data_info["data"]) bank_stmt_line.reconcile_bank_line() + self.assertEqual( + number_of_lines, len(bank_stmt_line.reconcile_data_info["data"]) + ) self.assertEqual(0, inv1.amount_residual) self.assertTrue( inv1.line_ids.filtered(