Merge PR #665 into 16.0

Signed-off-by etobella
pull/679/head
OCA-git-bot 2024-07-24 10:43:58 +00:00
commit bbceaa6785
2 changed files with 29 additions and 5 deletions

View File

@ -668,7 +668,25 @@ class AccountBankStatementLine(models.Model):
self.action_undo_reconciliation() self.action_undo_reconciliation()
def _unreconcile_bank_line_keep(self): def _unreconcile_bank_line_keep(self):
raise UserError(_("Keep suspense move lines mode cannot be unreconciled")) self.reconcile_data_info = self._default_reconcile_data(from_unreconcile=True)
# Reverse reconciled journal entry
to_reverse = (
self.line_ids._all_reconciled_lines()
.filtered(
lambda line: line.move_id != self.move_id
and (line.matched_debit_ids or line.matched_credit_ids)
)
.mapped("move_id")
)
if to_reverse:
default_values_list = [
{
"date": move.date,
"ref": _("Reversal of: %s", move.name),
}
for move in to_reverse
]
to_reverse._reverse_moves(default_values_list, cancel=True)
def _reconcile_move_line_vals(self, line, move_id=False): def _reconcile_move_line_vals(self, line, move_id=False):
return { return {

View File

@ -1,6 +1,5 @@
import time import time
from odoo.exceptions import UserError
from odoo.tests import Form, tagged from odoo.tests import Form, tagged
from odoo.addons.account.tests.common import TestAccountReconciliationCommon from odoo.addons.account.tests.common import TestAccountReconciliationCommon
@ -500,7 +499,7 @@ class TestReconciliationWidget(TestAccountReconciliationCommon):
def test_reconcile_invoice_keep(self): def test_reconcile_invoice_keep(self):
""" """
We want to test how the keep mode works, keeping the original move lines. We want to test how the keep mode works, keeping the original move lines.
However, the unreconcile will not work properly When unreconciling, the entry created for the reconciliation is reversed.
""" """
self.bank_journal_euro.reconcile_mode = "keep" self.bank_journal_euro.reconcile_mode = "keep"
self.bank_journal_euro.suspense_account_id.reconcile = True self.bank_journal_euro.suspense_account_id.reconcile = True
@ -540,8 +539,15 @@ class TestReconciliationWidget(TestAccountReconciliationCommon):
self.bank_journal_euro.suspense_account_id, self.bank_journal_euro.suspense_account_id,
bank_stmt_line.mapped("move_id.line_ids.account_id"), bank_stmt_line.mapped("move_id.line_ids.account_id"),
) )
with self.assertRaises(UserError): # Reset reconciliation
reconcile_move = (
bank_stmt_line.line_ids._all_reconciled_lines()
.filtered(lambda line: line.move_id != bank_stmt_line.move_id)
.move_id
)
bank_stmt_line.unreconcile_bank_line() bank_stmt_line.unreconcile_bank_line()
self.assertTrue(reconcile_move.reversal_move_id)
self.assertFalse(bank_stmt_line.is_reconciled)
# Testing to check functionality # Testing to check functionality