From 08f3f3dffb7d0d9cfe422e2bf114f1bbafa99cb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Tue, 13 Aug 2019 15:43:49 +0000 Subject: [PATCH] [IMP] website_sale: speed up loading of attributes on shop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For 10000 templates, of which around 1000 have variants, with 100 existing attributes and 20 values for each: - Displaying the /shop page takes 0.55s before the commit and 0.49s after. That's a 60ms again, around 10% faster. - The number of queries goes from 113 to 106. - The specific line that is changed goes from 6.3% total request time down to 2.77%, so the line becomes 2.3 times faster. closes odoo/odoo#34213 Signed-off-by: Sébastien Theys (seb) --- addons/website_sale/controllers/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index f6f6803760c..ba6f5548504 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -278,7 +278,7 @@ class WebsiteSale(http.Controller): ProductAttribute = request.env['product.attribute'] if products: # get all products without limit - attributes = ProductAttribute.search([('attribute_line_ids.value_ids', '!=', False), ('attribute_line_ids.product_tmpl_id', 'in', search_product.ids)]) + attributes = ProductAttribute.search([('product_tmpl_ids', 'in', search_product.ids)]) else: attributes = ProductAttribute.browse(attributes_ids)