Skip to content

Commit aefbced

Browse files
StephanRozendaalOpenCode
authored andcommitted
icon from manifest (OCA#23)
* [FIX] Fix field property The property is 'readony'. * [IMP]Get module icon from multiple sources Get the module icon from the following sources (in order): 1. From the first entry of the images tag from the manifest 2. From the static directory
1 parent 6d9c3f0 commit aefbced

2 files changed

Lines changed: 21 additions & 9 deletions

File tree

github_connector_odoo/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
'name': 'Github Connector - Odoo',
66
'summary': 'Analyze Odoo modules information from Github repositories',
7-
'version': '11.0.1.0.0',
7+
'version': '11.0.1.0.1',
88
'category': 'Connector',
99
'license': 'AGPL-3',
1010
'author': 'Odoo Community Association (OCA), Sylvain LE GAL, GRAP',

github_connector_odoo/models/odoo_module_version.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class OdooModuleVersion(models.Model):
136136
string='Odoo Type', selection=_ODOO_TYPE_SELECTION, store=True,
137137
compute='_compute_odoo_type')
138138

139-
image = fields.Binary(string='Icon Image', reaonly=True)
139+
image = fields.Binary(string='Icon Image', readonly=True)
140140

141141
github_url = fields.Char(
142142
string='Github URL', compute='_compute_github_url', store=True,
@@ -332,19 +332,31 @@ def create_or_update_from_manifest(
332332
info, repository_branch, module_version.module_id)
333333
module_version.write(value)
334334
icon_path = False
335-
for current_icon_path in self._ICON_PATH:
335+
resize = False
336+
if info.get('images'):
336337
full_current_icon_path = os.path.join(
337-
full_module_path, current_icon_path, 'icon.png')
338+
full_module_path, info.get('images')[0])
338339
if os.path.exists(full_current_icon_path):
339340
icon_path = full_current_icon_path
341+
else:
342+
for current_icon_path in self._ICON_PATH:
343+
full_current_icon_path = os.path.join(
344+
full_module_path, current_icon_path, 'icon.png')
345+
if os.path.exists(full_current_icon_path):
346+
icon_path = full_current_icon_path
347+
resize = True
348+
break
340349
if icon_path:
341-
resized_image = False
350+
image_enc = False
342351
try:
343352
with open(icon_path, 'rb') as f:
344353
image = f.read()
345-
resized_image = tools.image_resize_image(
346-
base64.b64encode(image), size=(96, 96),
347-
encoding='base64', filetype='PNG')
354+
if resize:
355+
image_enc = tools.image_resize_image(
356+
base64.b64encode(image), size=(96, 96),
357+
encoding='base64', filetype='PNG')
358+
else:
359+
image_enc = base64.b64encode(image)
348360
except Exception:
349361
_logger.warning("Unable to read or resize %s" % icon_path)
350-
module_version.write({'image': resized_image})
362+
module_version.write({'image': image_enc})

0 commit comments

Comments
 (0)