From 2476a5b1bb13befe5522fc440679295e5ecb7f22 Mon Sep 17 00:00:00 2001 From: Saurabh Choraria Date: Wed, 31 May 2023 12:51:01 +0000 Subject: [PATCH] [FIX] base: prevent traceback when icon file is not found When user tries to import a module which does not consist of an icon and then when user tries to access that module the error occurs. Steps to reproduce: 1. Install web_studio. 2. Import a module(without icon) from apps > import module menu. 3. Now search that module in apps and click on module info. 4. The error will occur. Applying this commit will fix this issue. sentry-4206999375 closes odoo/odoo#124540 X-original-commit: 4b0221800ab75d5573e7066bf8beee14488062dd Signed-off-by: Xavier Morel (xmo) --- odoo/addons/base/models/ir_module.py | 2 +- odoo/modules/module.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/odoo/addons/base/models/ir_module.py b/odoo/addons/base/models/ir_module.py index 1305833fac7..6f304e70c77 100644 --- a/odoo/addons/base/models/ir_module.py +++ b/odoo/addons/base/models/ir_module.py @@ -233,7 +233,7 @@ class Module(models.Model): path_parts = module.icon.split('/') path = modules.get_module_resource(path_parts[1], *path_parts[2:]) elif module.id: - path = modules.module.get_module_icon(module.name) + path = modules.module.get_module_icon_path(module) else: path = '' if path: diff --git a/odoo/modules/module.py b/odoo/modules/module.py index 48ba5d0f752..824eed7e16d 100644 --- a/odoo/modules/module.py +++ b/odoo/modules/module.py @@ -245,6 +245,13 @@ def get_module_icon(module): return ('/' + module + '/') + '/'.join(iconpath) return '/base/' + '/'.join(iconpath) +def get_module_icon_path(module): + iconpath = ['static', 'description', 'icon.png'] + path = get_module_resource(module.name, *iconpath) + if not path: + path = get_module_resource('base', *iconpath) + return path + def module_manifest(path): """Returns path to module manifest if one can be found under `path`, else `None`.""" if not path: