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

[17.0][FIX] account_reconcile_model_oca: Populate partner when writeoff reconcile model has partner mapping #800

Open
wants to merge 2 commits into
base: 17.0
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions account_reconcile_model_oca/models/account_reconcile_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ def _get_write_off_move_lines_dict(self, residual_balance, partner_id):
continue

writeoff_line = line._get_write_off_move_line_dict(balance, currency)
if partner_id:
writeoff_line["partner_id"] = partner_id
lines_vals_list.append(writeoff_line)

residual_balance -= balance
Expand Down
70 changes: 70 additions & 0 deletions account_reconcile_oca/tests/test_bank_account_reconcile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1389,3 +1389,73 @@ def test_invoice_foreign_currency_late_change_of_rate(self):
self.assertEqual(3, len(f.reconcile_data_info["data"]))
self.assertTrue(f.can_reconcile)
self.assertEqual(f.reconcile_data_info["data"][-1]["amount"], 3.63)

def test_reconcile_rule_with_partner_mapping(self):
"""
Testing the fill of the bank statement line with
writeoff suggestion reconcile model with auto_reconcile
and partner matching
"""

partner = self.env["res.partner"].create(
{
"name": "test partner",
}
)
self.env["account.reconcile.model"].create(
{
"name": "write-off model suggestion with partner matching",
"rule_type": "writeoff_suggestion",
"match_label": "contains",
"match_label_param": "RECEIVED FROM",
"auto_reconcile": True,
"line_ids": [(0, 0, {"account_id": self.current_assets_account.id})],
"partner_mapping_line_ids": [
(
0,
0,
{
"partner_id": partner.id,
"payment_ref_regex": ".*TOTO.*",
},
)
],
}
)

bank_stmt = self.acc_bank_stmt_model.create(
{
"company_id": self.env.ref("base.main_company").id,
"journal_id": self.bank_journal_euro.id,
"date": time.strftime("%Y-07-15"),
"name": "test",
}
)
bank_stmt_line_1 = self.acc_bank_stmt_line_model.create(
{
"name": "DEMO WRITEOFF WITH PARTNER MAPPING 1",
"payment_ref": "RECEIVED FROM TOTO42",
"journal_id": self.bank_journal_euro.id,
"statement_id": bank_stmt.id,
"amount": 100,
"date": time.strftime("%Y-07-15"),
}
)
bank_stmt_line_2 = self.acc_bank_stmt_line_model.create(
{
"name": "DEMO WRITEOFF WITH PARTNER MAPPING 2",
"payment_ref": "RECEIVED FROM TETE42",
"journal_id": self.bank_journal_euro.id,
"statement_id": bank_stmt.id,
"amount": 100,
"date": time.strftime("%Y-07-15"),
}
)
self.assertTrue(bank_stmt_line_1.is_reconciled)
self.assertTrue(
"test partner" in bank_stmt_line_1.line_ids.mapped("partner_id.name")
)
self.assertTrue(bank_stmt_line_2.is_reconciled)
self.assertTrue(
"test partner" not in bank_stmt_line_2.line_ids.mapped("partner_id.name")
)