Skip to content
Snippets Groups Projects
Commit 17f69e70 authored by Jérome Maes's avatar Jérome Maes
Browse files

[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.
parent 5c2274e1
No related branches found
No related tags found
No related merge requests found
......@@ -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')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment