Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion account_reconcile_oca/models/account_bank_statement_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,14 @@
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())
)
Expand All @@ -555,6 +562,8 @@
)
amount -= sum(line.get("amount") for line in line_data)
data += line_data
if res.get("auto_reconcile"):
self.reconcile_bank_line()

Check warning on line 566 in account_reconcile_oca/models/account_bank_statement_line.py

View check run for this annotation

Codecov / codecov/patch

account_reconcile_oca/models/account_bank_statement_line.py#L566

Added line #L566 was not covered by tests
return self._recompute_suspense_line(
data,
reconcile_auxiliary_id,
Expand Down Expand Up @@ -745,6 +754,7 @@
models = self.env["account.reconcile.model"].search(
[
("rule_type", "in", ["invoice_matching", "writeoff_suggestion"]),
("company_id", "in", result.company_id.ids),
("auto_reconcile", "=", True),
]
)
Expand Down
12 changes: 12 additions & 0 deletions account_reconcile_oca/tests/test_bank_account_reconcile.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ class TestReconciliationWidget(TestAccountReconciliationCommon):
@classmethod
def setUpClass(cls, chart_template_ref=None):
super().setUpClass(chart_template_ref=chart_template_ref)
# 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"]
Expand Down Expand Up @@ -988,6 +998,8 @@ def test_partner_name_with_parent(self):
}
)

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",
Expand Down
Loading