[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.
This commit is contained in:
Jérémy Didderen committed 2026-10-27 21:38:40 +01:00
1 parent 3585c85298
commit f2d9f1138a
1 file changed
+4 -5
+4 -5
View File
@@ -586,12 +586,11 @@ class EbicsFile(models.Model):
camt_tag = variant_tags[camt_variant] camt_tag = variant_tags[camt_variant]
stmts = root[0].findall(f"ns:{camt_tag}", ns) stmts = root[0].findall(f"ns:{camt_tag}", ns)
for i, stmt in enumerate(stmts): for i, stmt in enumerate(stmts):
acc_number = sanitize_account_number( acc_ids = stmt.xpath(
stmt.xpath( "ns:Acct/ns:Id/ns:IBAN/text() | ns:Acct/ns:Id/ns:Othr/ns:Id/text()",
"ns:Acct/ns:Id/ns:IBAN/text() | ns:Acct/ns:Id/ns:Othr/ns:Id/text()", namespaces=ns,
namespaces=ns,
)[0]
) )
acc_number = acc_ids and sanitize_account_number(acc_ids[0])
if not acc_number: if not acc_number:
message = self.env._("No bank account number found.") message = self.env._("No bank account number found.")
res["notifications"].append({"type": "error", "message": message}) res["notifications"].append({"type": "error", "message": message})