From aaef93c0174cec4d470a364b8c8468fe2a225fd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Mottet=20=28oms=29?= Date: Tue, 14 Sep 2021 11:33:36 +0000 Subject: [PATCH] [FIX] website: keep configurator images on theme switch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On theme switch default images of the previous theme are replaced by the one of the new theme. For website where default images come from the configurator we don't want them to be replaced by the theme's images. task-2614840 closes odoo/odoo#77648 X-original-commit: c25f80c70930f65a928b44d4fe91775c37bc4268 Signed-off-by: Jérémy Kersten (jke) --- addons/website/models/website.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/website/models/website.py b/addons/website/models/website.py index 291bb8f8373..ff8c533065c 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -457,7 +457,7 @@ class Website(models.Model): except Exception as e: logger.warning("Failed to download image: %s.\n%s", url, e) else: - self.env['ir.attachment'].create({ + attachment = self.env['ir.attachment'].create({ 'name': name, 'website_id': website.id, 'key': name, @@ -465,6 +465,13 @@ class Website(models.Model): 'raw': response.content, 'public': True, }) + self.env['ir.model.data'].create({ + 'name': 'configurator_%s_%s' % (website.id, name.split('.')[1]), + 'module': 'website', + 'model': 'ir.attachment', + 'res_id': attachment.id, + 'noupdate': True, + }) website = self.get_current_website() theme_name = kwargs['theme_name']