[IMP] account_reconcile_oca: Add auto-reconcile compatibility (Example: Rule to match invoices/bills)

TT52146

[FIX] account_reconcile_oca: Fix test related to match_text_location fields

Related to 8948b31407

TT52146
pull/808/head
Víctor Martínez 2024-12-10 16:33:39 +01:00 committed by Jordi Ballester Alomar
parent ca4fe69b31
commit 2f1543ab31
2 changed files with 23 additions and 1 deletions

View File

@ -532,7 +532,14 @@ class AccountBankStatementLine(models.Model):
res = (
self.env["account.reconcile.model"]
.search(
[("rule_type", "in", ["invoice_matching", "writeoff_suggestion"])]
[
(
"rule_type",
"in",
["invoice_matching", "writeoff_suggestion"],
),
("company_id", "=", self.company_id.id),
]
)
._apply_rules(self, self._retrieve_partner())
)
@ -555,6 +562,8 @@ class AccountBankStatementLine(models.Model):
)
amount -= sum(line.get("amount") for line in line_data)
data += line_data
if res.get("auto_reconcile"):
self.reconcile_bank_line()
return self._recompute_suspense_line(
data,
reconcile_auxiliary_id,
@ -750,6 +759,7 @@ class AccountBankStatementLine(models.Model):
models = self.env["account.reconcile.model"].search(
[
("rule_type", "in", ["invoice_matching", "writeoff_suggestion"]),
("company_id", "in", result.company_id.ids),
("auto_reconcile", "=", True),
]
)

View File

@ -17,6 +17,16 @@ class TestReconciliationWidget(TestAccountReconciliationCommon):
def setUpClass(cls, chart_template_ref=None):
super().setUpClass(chart_template_ref=chart_template_ref)
cls.env = cls.env(context=cls._setup_context())
# Auto-disable reconciliation model created automatically with
# generate_account_reconcile_model() to avoid side effects in tests
cls.invoice_matching_models = cls.env["account.reconcile.model"].search(
[
("rule_type", "=", "invoice_matching"),
("auto_reconcile", "=", True),
("company_id", "=", cls.company.id),
]
)
cls.invoice_matching_models.active = False
cls.acc_bank_stmt_model = cls.env["account.bank.statement"]
cls.acc_bank_stmt_line_model = cls.env["account.bank.statement.line"]
@ -995,6 +1005,8 @@ class TestReconciliationWidget(TestAccountReconciliationCommon):
}
)
self.invoice_matching_models.active = True
self.invoice_matching_models.match_text_location_label = False
bank_stmt_line = self.acc_bank_stmt_line_model.create(
{
"name": "testLine",