From 8b6eecc8f162a667b5cc853138272b202dcc893a Mon Sep 17 00:00:00 2001 From: Adrien Minet Date: Wed, 16 Feb 2022 07:56:10 +0000 Subject: [PATCH] [FIX] base_import: read error message clearer for import How to reproduce the bug ? - install the inventory app - open the app and try to import a file where at least one cell has a wrong value What is the bug ? When you try to import a file in the inventory app where at least one cell has a wrong value, the file won't be imported. In addition to that, you will get an error saying that one python module is missing while this might not be the case. opw-2715625 closes odoo/odoo#91482 X-original-commit: cafd8699ff8ec8eb93aa283a4cac57317ce40708 Signed-off-by: Adrien Minet Signed-off-by: Nicolas Lempereur (nle) Signed-off-by: Simon Goffin --- addons/base_import/models/base_import.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/base_import/models/base_import.py b/addons/base_import/models/base_import.py index c9e0af0525e..39b5a93a8e6 100644 --- a/addons/base_import/models/base_import.py +++ b/addons/base_import/models/base_import.py @@ -352,6 +352,8 @@ class Import(models.TransientModel): if handler: try: return getattr(self, '_read_' + file_extension)(options) + except ValueError as e: + raise e except Exception: _logger.warning("Failed to read file '%s' (transient id %d) using guessed mimetype %s", self.file_name or '', self.id, mimetype) @@ -360,6 +362,8 @@ class Import(models.TransientModel): if handler: try: return getattr(self, '_read_' + file_extension)(options) + except ValueError as e: + raise e except Exception: _logger.warning("Failed to read file '%s' (transient id %d) using user-provided mimetype %s", self.file_name or '', self.id, self.file_type) @@ -371,6 +375,8 @@ class Import(models.TransientModel): if ext in EXTENSIONS: try: return getattr(self, '_read_' + ext[1:])(options) + except ValueError as e: + raise e except Exception: _logger.warning("Failed to read file '%s' (transient id %s) using file extension", self.file_name, self.id)