From f2d9f1138acc5f0047a20f5fb13b323c3a21eaa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Didderen?= Date: Tue, 27 Oct 2026 21:26:45 +0100 Subject: [PATCH] [FIX] account_ebics - Report camt statements without account number The xpath result was indexed before the emptiness check, so a statement without IBAN or other account id raised an IndexError instead of the "No bank account number found." notification. --- account_ebics/models/ebics_file.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/account_ebics/models/ebics_file.py b/account_ebics/models/ebics_file.py index f414cb4..05792be 100644 --- a/account_ebics/models/ebics_file.py +++ b/account_ebics/models/ebics_file.py @@ -586,12 +586,11 @@ class EbicsFile(models.Model): camt_tag = variant_tags[camt_variant] stmts = root[0].findall(f"ns:{camt_tag}", ns) for i, stmt in enumerate(stmts): - acc_number = sanitize_account_number( - stmt.xpath( - "ns:Acct/ns:Id/ns:IBAN/text() | ns:Acct/ns:Id/ns:Othr/ns:Id/text()", - namespaces=ns, - )[0] + acc_ids = stmt.xpath( + "ns:Acct/ns:Id/ns:IBAN/text() | ns:Acct/ns:Id/ns:Othr/ns:Id/text()", + namespaces=ns, ) + acc_number = acc_ids and sanitize_account_number(acc_ids[0]) if not acc_number: message = self.env._("No bank account number found.") res["notifications"].append({"type": "error", "message": message})