Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][IMP] shopinvader_search_engine_update_image: update thumbnails images #1504

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we add this in the relation mixin? Because we will have to add thoses inside all submodels of the mixin


def get_products(self):
return self.mapped("product_tmpl_id")
Loading