From f7909dbfe8f3ded13e7d833a222b9984fa72e584 Mon Sep 17 00:00:00 2001 From: Luc De Meyer Date: Mon, 13 Jul 2026 22:12:15 +0200 Subject: [PATCH] [FIX]account_ebics_oca_statement_import - fix stack trace Fix stack trace when importing csv file on financial journal without bank account number. This PR optimises also the _match_journal() method in the import wizard. --- .../wizards/account_statement_import.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/account_ebics_oca_statement_import/wizards/account_statement_import.py b/account_ebics_oca_statement_import/wizards/account_statement_import.py index 3326be7..5cea8c7 100644 --- a/account_ebics_oca_statement_import/wizards/account_statement_import.py +++ b/account_ebics_oca_statement_import/wizards/account_statement_import.py @@ -15,25 +15,25 @@ class AccountStatementImport(models.TransientModel): _inherit = "account.statement.import" def _match_journal(self, account_number, currency): - journal = self.env["account.journal"] + if not account_number: + return super()._match_journal(account_number, currency) sanitized_account_number = self._sanitize_account_number(account_number) - fin_journals = self.env["account.journal"].search( + fin_journal = self.env["account.journal"].search( [ ("type", "=", "bank"), + ( + "bank_account_id.sanitized_acc_number", + "like", + sanitized_account_number, + ), "|", ("currency_id", "=", currency.id), ("company_id.currency_id", "=", currency.id), ] ) - fin_journal = fin_journals.filtered( - lambda r: sanitized_account_number - in (r.bank_account_id.sanitized_acc_number or "") - ) if len(fin_journal) == 1: - journal = fin_journal - if not journal: - journal = super()._match_journal(account_number, currency) - return journal + return fin_journal + return super()._match_journal(account_number, currency) def _sanitize_account_number(self, account_number): sanitized_number = sanitize_account_number(account_number)