[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) <xmo@odoo.com>
This commit is contained in:
Saurabh Choraria
2023-06-12 12:41:15 +02:00
parent f95e49beb0
commit 2476a5b1bb
2 changed files with 8 additions and 1 deletions
+1 -1
View File
@@ -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:
+7
View File
@@ -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: