From 93399e07244634ca6f4026738477af9d2e709086 Mon Sep 17 00:00:00 2001 From: Ronald Portier Date: Mon, 13 Dec 2021 22:11:22 +0100 Subject: [PATCH] [FIX] *_online Improvements after review --- .../models/account_bank_statement_line.py | 2 +- .../models/online_bank_statement_provider.py | 10 +++++++++- .../views/account_bank_statement_line.xml | 6 +++++- .../models/online_bank_statement_provider_ponto.py | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/account_statement_import_online/models/account_bank_statement_line.py b/account_statement_import_online/models/account_bank_statement_line.py index 1fc457bd..7f0c7f08 100644 --- a/account_statement_import_online/models/account_bank_statement_line.py +++ b/account_statement_import_online/models/account_bank_statement_line.py @@ -11,7 +11,7 @@ class AccountBankStatementLine(models.Model): _inherit = "account.bank.statement.line" - raw_data = fields.Text( + online_raw_data = fields.Text( help="The complete data retrieved online for this transaction", readonly=True, copy=False, diff --git a/account_statement_import_online/models/online_bank_statement_provider.py b/account_statement_import_online/models/online_bank_statement_provider.py index 3b03f54e..2366fb72 100644 --- a/account_statement_import_online/models/online_bank_statement_provider.py +++ b/account_statement_import_online/models/online_bank_statement_provider.py @@ -364,8 +364,16 @@ class OnlineBankStatementProvider(models.Model): return sanitize_account_number(bank_account_number) def _update_partner_from_account_number(self, line_values): + """Lookup partner using account number.""" + self.ensure_one() partner_bank = self.env["res.partner.bank"].search( - [("acc_number", "=", line_values["account_number"])], limit=1 + [ + ("acc_number", "=", line_values["account_number"]), + "|", + ("company_id", "=", False), + ("company_id", "=", self.company_id.id), + ], + limit=1, ) if partner_bank: line_values["partner_bank_id"] = partner_bank.id diff --git a/account_statement_import_online/views/account_bank_statement_line.xml b/account_statement_import_online/views/account_bank_statement_line.xml index 88d13b36..1b7dd2f9 100644 --- a/account_statement_import_online/views/account_bank_statement_line.xml +++ b/account_statement_import_online/views/account_bank_statement_line.xml @@ -13,7 +13,11 @@ - + diff --git a/account_statement_import_online_ponto/models/online_bank_statement_provider_ponto.py b/account_statement_import_online_ponto/models/online_bank_statement_provider_ponto.py index e67ce2c1..b962ae96 100644 --- a/account_statement_import_online_ponto/models/online_bank_statement_provider_ponto.py +++ b/account_statement_import_online_ponto/models/online_bank_statement_provider_ponto.py @@ -237,7 +237,7 @@ class OnlineBankStatementProviderPonto(models.Model): "payment_ref": attributes.get("remittanceInformation", ref), "unique_import_id": transaction["id"], "amount": attributes["amount"], - "raw_data": transaction, + "online_raw_data": transaction, } if attributes.get("counterpartReference"): vals_line["account_number"] = attributes["counterpartReference"]