[FW][FIX] (website_)sale: Perf improvement on /shop loading

closes odoo/odoo#83215

Forward-port-of: #81767
X-original-commit: cb19f45ae8180247101cf4aafec2a1fe769772ff
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
Juan Jose Scarafia
2022-01-24 11:10:04 +00:00
committed by Yannick Tivisse
parent 97f470b949
commit f7e74e7fa1
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -234,7 +234,7 @@ class ProductTemplate(models.Model):
price = pricelist._get_product_price(product, quantity)
else:
price = list_price
display_image = bool(product.image_1920)
display_image = bool(product.image_128)
display_name = product.display_name
price_extra = (product.price_extra or 0.0) + (sum(no_variant_attributes_price_extra) or 0.0)
else:
@@ -246,7 +246,7 @@ class ProductTemplate(models.Model):
price = pricelist._get_product_price(product_template, quantity)
else:
price = list_price
display_image = bool(product_template.image_1920)
display_image = bool(product_template.image_128)
combination_name = combination._get_combination_name()
if combination_name:
@@ -234,11 +234,11 @@ class ProductTemplate(models.Model):
:rtype: recordset of 'product.template' or recordset of 'product.product'
"""
self.ensure_one()
if self.image_1920:
if self.image_128:
return self
variant = self.env['product.product'].browse(self._get_first_possible_variant_id())
# if the variant has no image anyway, spare some queries by using template
return variant if variant.image_variant_1920 else self
return variant if variant.image_variant_128 else self
def _get_current_company_fallback(self, **kwargs):
"""Override: if a website is set on the product or given, fallback to