Skip to content

Commit c42acfa

Browse files
committed
[FIX] base_import_module: force the icon from the zip
The icon is not found by `get_module_icon` which checks whether the file exists on the system. However, that function has no access to temporary storage. We need to explicitly find the path for the imported module. closes odoo#216639 Signed-off-by: Julien Castiaux (juc) <[email protected]>
1 parent bbcbab6 commit c42acfa

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

addons/base_import_module/models/ir_module.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from odoo.modules.module import MANIFEST_NAMES, Manifest
1919
from odoo.release import major_version
2020
from odoo.tools import convert_file, exception_to_unicode
21-
from odoo.tools import file_open, file_open_temporary_directory, ormcache
21+
from odoo.tools import file_open, file_path, file_open_temporary_directory, ormcache
2222
from odoo.tools.misc import topological_sort
2323

2424
_logger = logging.getLogger(__name__)
@@ -77,6 +77,12 @@ def _import_module(self, module, path, force=False, with_demo=False):
7777
if not terp:
7878
return False
7979
values = self.get_values_from_terp(terp)
80+
try:
81+
icon_path = terp.manifest_cached.get('icon') or opj(terp.name, 'static/description/icon.png')
82+
file_path(icon_path, env=self.env, check_exists=True)
83+
values['icon'] = '/' + icon_path
84+
except OSError:
85+
pass # keep the default icon
8086
values['latest_version'] = terp.version
8187
if self.env.context.get('data_module'):
8288
values['module_type'] = 'industries'

0 commit comments

Comments
 (0)