[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.
This commit is contained in:
Jérome Maes
2016-08-26 10:40:05 +02:00
parent 5c2274e169
commit 17f69e70fe
+6 -2
View File
@@ -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')