Skip to content

Commit 994b0fa

Browse files
committed
[IMP] base_import_module: provide full traceback if error arises
Before this commit, when an error happens during the import of a data module, the UserError was displaying the last part of the traceback. In some cases, it was sufficient (missing manifest, unknown dependency, ...). But in other cases, this was only displaying the record triggering the error, but not more, giving no clue on what was the exact error and how to fix it. This commit adapts the UserError to provide the full traceback in the popup window, such that the user can understand or at least report the error. Another task is targeting master to improve the design of this window. task-4876416 closes odoo#233237 X-original-commit: 65873de Signed-off-by: Julien Castiaux (juc) <juc@odoo.com> Signed-off-by: Vallaeys Valentin (vava) <vava@odoo.com>
1 parent bb5b7cf commit 994b0fa

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

addons/base_import_module/models/ir_module.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import os
88
import pathlib
99
import sys
10+
import traceback
1011
import zipfile
1112
from babel.messages import extract
1213
from collections import defaultdict
@@ -19,7 +20,7 @@
1920
from odoo.http import request
2021
from odoo.modules.module import MANIFEST_NAMES, Manifest
2122
from odoo.release import major_version
22-
from odoo.tools import SQL, convert_file, exception_to_unicode
23+
from odoo.tools import SQL, convert_file
2324
from odoo.tools import file_open, file_path, file_open_temporary_directory, ormcache
2425
from odoo.tools.misc import OrderedSet, topological_sort
2526
from odoo.tools.translate import JAVASCRIPT_TRANSLATION_COMMENT, CodeTranslations, TranslationImporter, get_base_langs
@@ -382,7 +383,7 @@ def _import_zipfile(self, module_file, force=False, with_demo=False):
382383
except Exception as e:
383384
raise UserError(_(
384385
"Error while importing module '%(module)s'.\n\n %(error_message)s \n\n",
385-
module=mod_name, error_message=exception_to_unicode(e),
386+
module=mod_name, error_message=traceback.format_exc(),
386387
)) from e
387388
return "", module_names
388389

0 commit comments

Comments
 (0)