From f6fdcd3f3835c0e119a25d91afc931a4b595841e Mon Sep 17 00:00:00 2001 From: Quentin Groulard Date: Wed, 21 Feb 2024 11:31:44 +0100 Subject: [PATCH] [IMP] shopinvader_search_engine_update_image: update thumbnails images when product images are replaced --- .../models/fs_product_image.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/shopinvader_search_engine_update_image/models/fs_product_image.py b/shopinvader_search_engine_update_image/models/fs_product_image.py index 755e05efb8..0530a79eda 100644 --- a/shopinvader_search_engine_update_image/models/fs_product_image.py +++ b/shopinvader_search_engine_update_image/models/fs_product_image.py @@ -8,5 +8,20 @@ class FsProductImage(models.Model): _name = "fs.product.image" _inherit = ["fs.product.image", "se.product.update.mixin"] + def _update_se_thumbnails(self): + for rec in self: + for thumbnail in rec.image.attachment.se_thumbnail_ids: + values = thumbnail._prepare_tumbnail( + rec.image, thumbnail.size_x, thumbnail.size_y, thumbnail.base_name + ) + thumbnail.write(values) + + def write(self, vals): + needs_update = self.needs_product_update(vals) + res = super().write(vals) + if needs_update and "specific_image" in vals: + self._update_se_thumbnails() + return res + def get_products(self): return self.mapped("product_tmpl_id")