From 37406c404232831e19747f99072f3de646c60215 Mon Sep 17 00:00:00 2001 From: Luc De Meyer Date: Fri, 17 Jul 2020 17:27:19 +0200 Subject: [PATCH] [13.0]fix stack trace when bank journal not found (#16) --- account_ebics/models/ebics_file.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/account_ebics/models/ebics_file.py b/account_ebics/models/ebics_file.py index 2d8c56f..3d32a39 100644 --- a/account_ebics/models/ebics_file.py +++ b/account_ebics/models/ebics_file.py @@ -165,7 +165,7 @@ class EbicsFile(models.Model): """, (tuple(st_line_ids),) ) - statement_ids = list(self.env.cr.fetchall()[0]) + statement_ids = [x[0] for x in self.env.cr.fetchall()] self.note_process += _( "Number of Bank Statements: %s" ) % len(statement_ids) @@ -224,11 +224,26 @@ class EbicsFile(models.Model): 'notifications': []}, } wiz_ctx = dict(self.env.context, active_model='ebics.file') - for attachment_vals in attachments_vals: + for i, attachment_vals in enumerate(attachments_vals, start=1): wiz_vals = {'attachment_ids': [(0, 0, attachment_vals)]} wiz = self.env[wiz_model].with_context(wiz_ctx).create(wiz_vals) res = wiz.import_file() ctx = res.get('context') + if (res.get('res_model') + == 'account.bank.statement.import.journal.creation'): + message = _( + "Error detected while importing statement number %s.\n" + ) % i + message += _("No financial journal found.") + details = _( + 'Bank account number: %s' + ) % ctx.get('default_bank_acc_number') + result['context']['notifications'].extend([{ + 'type': 'warning', + 'message': message, + 'details': details, + }]) + continue result['context']['statement_line_ids'].extend( ctx['statement_line_ids']) result['context']['notifications'].extend(