From 712301a96452d01a13b7644208e44c3017a7606a Mon Sep 17 00:00:00 2001 From: Katherine Zaoral Date: Sat, 12 Nov 2022 09:00:18 -0300 Subject: [PATCH] [ADD] account_statement_import_txt_xlsx: show mapping error If there is a problem parsing the file we are not showing the error to the user, instead a generic message telling something is wrong with the type of file is shown, and we only showing the error if we are running unit tests. In this case we think is good to show the error to the user, this way they can check what is wrong and fix it in the sheet mapping. * We are only showing the title of the error as a HINT, we think that is a good start to undestand what needs to change in the sheet mapping. * The complete traceback error is shown in the log if we needed for more detail review from the technical teams. --- .../models/account_statement_import.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/account_statement_import_txt_xlsx/models/account_statement_import.py b/account_statement_import_txt_xlsx/models/account_statement_import.py index 8e854be1..cceb90b8 100644 --- a/account_statement_import_txt_xlsx/models/account_statement_import.py +++ b/account_statement_import_txt_xlsx/models/account_statement_import.py @@ -3,7 +3,8 @@ import logging -from odoo import fields, models +from odoo import _, fields, models +from odoo.exceptions import UserError _logger = logging.getLogger(__name__) @@ -32,10 +33,11 @@ class AccountStatementImport(models.TransientModel): return Parser.parse( data_file, self.sheet_mapping_id, self.statement_filename ) - except BaseException: + except BaseException as exc: if self.env.context.get("account_statement_import_txt_xlsx_test"): raise _logger.warning("Sheet parser error", exc_info=True) + raise UserError(_("Bad file/mapping: ") + str(exc)) from exc return super()._parse_file(data_file) def _create_bank_statements(self, stmts_vals, result):