From 17f69e70fe2ff042586b4d97d8783ac3b2636267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Maes?= Date: Fri, 26 Aug 2016 09:51:51 +0200 Subject: [PATCH] [IMP] ir_module: make icon_image depends on icon path field For now, the base64 image (binary field) is the content of the image in /static/src/description.png The kanban view use 'icon' field, and form view use 'icon_image' field. For module having no icon defined the default image is not the same on kanban or on form view. Moreover, it makes more sence to add this dependency. --- openerp/addons/base/module/module.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openerp/addons/base/module/module.py b/openerp/addons/base/module/module.py index 6a53717761b..60f6c79faea 100644 --- a/openerp/addons/base/module/module.py +++ b/openerp/addons/base/module/module.py @@ -210,11 +210,15 @@ class Module(models.Model): module.reports_by_module = "\n".join(sorted(map(attrgetter('name'), browse('ir.actions.report.xml')))) module.menus_by_module = "\n".join(sorted(map(attrgetter('complete_name'), browse('ir.ui.menu')))) - @api.depends('name') + @api.depends('icon') def _get_icon_image(self): for module in self: module.icon_image = '' - path = modules.get_module_resource(module.name, 'static', 'description', 'icon.png') + if module.icon: + path_parts = module.icon.split('/') + path = modules.get_module_resource(path_parts[1], *path_parts[2:]) + else: + path = modules.get_module_icon(module.name) if path: with tools.file_open(path, 'rb') as image_file: module.icon_image = image_file.read().encode('base64')