From d85889f50f92a4ef4c612b4ffd34a45f0490836e Mon Sep 17 00:00:00 2001 From: "Anh Thao Pham (pta)" Date: Tue, 9 Feb 2021 14:19:50 +0000 Subject: [PATCH] [FIX] account: fix counterpart values of Reconciliation Models for Statement Line with no Partner - Go to Accounting > Configuration > Reconciliation Models - Create a Reconciliation Model: * Type: Suggest counterpart values * Amount Nature: Amount Paid/Received * Label: Contains test * Counterpart Values: [Add a line with "Percentage of balance" as Amount Type and 100 as Amount, for example] - Create a Bank Statement of any amount with "test" as Label and no Partner - Post Bank Statement and Reconcile it Created Bank Statement matches conditions of Reconciliation Model but Counterpart Values are not suggested. No counterpart values are suggested if there is no Partner on Bank Statement During preparation of reconciliation, reconciliation is skipped because an open balance has to be created but no receivable/payable account is retrieved as there is no Partner on Bank Statement. If no Partner is set, receivable/payable account is retrieved from company. opw-2441484 opw-2442491 closes odoo/odoo#66167 X-original-commit: b9052f30dd8c26e0402a7f4a55b72204e9f1e633 Signed-off-by: oco-odoo --- addons/account/models/account_bank_statement.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py index 722d26670bb..b70ae4761a1 100644 --- a/addons/account/models/account_bank_statement.py +++ b/addons/account/models/account_bank_statement.py @@ -1169,6 +1169,12 @@ class AccountBankStatementLine(models.Model): counterpart_vals['account_id'] = open_balance_account.id counterpart_vals['partner_id'] = partner.id + else: + if self.amount > 0: + open_balance_account = self.company_id.partner_id.with_company(self.company_id).property_account_receivable_id + else: + open_balance_account = self.company_id.partner_id.with_company(self.company_id).property_account_payable_id + counterpart_vals['account_id'] = open_balance_account.id open_balance_vals = self._prepare_counterpart_move_line_vals(counterpart_vals) else: