diff --git a/modules/product_image/product.py b/modules/product_image/product.py index 328cd837c0..e309e3a1b7 100644 --- a/modules/product_image/product.py +++ b/modules/product_image/product.py @@ -166,7 +166,8 @@ class Image(ImageMixin, sequence_ordered(), ModelSQL, ModelView, MatchMixin): raise ValueError("Invalid size") for cache in self.cache: if cache.size == size: - return cache.image + # re-instantiate to fetch only one image + return cache.__class__(cache.id).image with Transaction().new_transaction(): cache = self._store_cache(size, self._resize(size)) # Save cache only if record is already committed diff --git a/trytond/trytond/ir/avatar.py b/trytond/trytond/ir/avatar.py index 50e896b75c..142a4efbfb 100644 --- a/trytond/trytond/ir/avatar.py +++ b/trytond/trytond/ir/avatar.py @@ -100,7 +100,8 @@ class Avatar(ImageMixin, ResourceMixin, ModelSQL): raise ValueError("Invalid size") for avatar in self.cache: if avatar.size == size: - return avatar.image + # re-instantiate to fetch only one image + return avatar.__class__(avatar.id).image if not self.image: return None if PIL: