Skip to content

Commit

Permalink
[IMP] shopinvader_search_engine_update_image: update thumbnails image…
Browse files Browse the repository at this point in the history
…s when product images are replaced
  • Loading branch information
qgroulard committed Feb 21, 2024
1 parent 5e49856 commit f6fdcd3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions shopinvader_search_engine_update_image/models/fs_product_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit f6fdcd3

Please sign in to comment.