[FIX] website: preserve theme images order
The image displayed in the theme selection page is the last one that was created out of the theme's manifest's `images` entry. Because of this, when a theme has a different non-last image in a new version compared to an old version, that image becomes the last created one and is displayed in the theme selection page instead of the expected screenshot image. This commit preserves the order that was specified in the `images` definition by re-creating all images instead of only the modified ones - if an update is needed at all. Steps to reproduce: - Install `website` with a theme in 14.0. - Upgrade to 15.0. - Go to the theme selection page. => Some themes (e.g. `theme_beauty`) displayed their cover picture instead of their screenshot. task-2719425 closes odoo/odoo#163118 X-original-commit: 4bc165b68078638a8057c79162f428026ca81321 Signed-off-by: Soukéina Bojabza (sobo) <sobo@odoo.com>
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
import logging
|
||||
import os
|
||||
from collections import defaultdict, OrderedDict
|
||||
|
||||
from odoo import api, fields, models
|
||||
@@ -446,17 +445,19 @@ class IrModuleModule(models.Model):
|
||||
theme._generate_primary_snippet_templates()
|
||||
terp = self.get_module_info(theme.name)
|
||||
images = terp.get('images', [])
|
||||
for image in images:
|
||||
image_path = '/' + os.path.join(theme.name, image)
|
||||
if image_path not in existing_urls:
|
||||
image_name = os.path.basename(image_path)
|
||||
IrAttachment.create({
|
||||
'type': 'url',
|
||||
'name': image_name,
|
||||
'url': image_path,
|
||||
'res_model': self._name,
|
||||
'res_id': theme.id,
|
||||
})
|
||||
image_paths = ['/%s/%s' % (theme.name, image) for image in images]
|
||||
if all(image_path in existing_urls for image_path in image_paths):
|
||||
continue
|
||||
# Images creation order must be the order specified in the manifest
|
||||
for image_path in image_paths:
|
||||
image_name = image_path.split('/')[-1]
|
||||
IrAttachment.create({
|
||||
'type': 'url',
|
||||
'name': image_name,
|
||||
'url': image_path,
|
||||
'res_model': self._name,
|
||||
'res_id': theme.id,
|
||||
})
|
||||
|
||||
def get_themes_domain(self):
|
||||
"""Returns the 'ir.module.module' search domain matching all available themes."""
|
||||
|
||||
Reference in New Issue
Block a user