From 12df3c6a98e4a925a8aa2e1232497a01cb4f8d69 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Wed, 19 Dec 2018 18:25:46 +0100 Subject: [PATCH] [FIX] product: name_get, products can share the same template Oversight in revision a91ffcf1a72f7d8759704405cd5026cf32c21a7f Multiple products can have the same template. Passing multiple times the same template id to the search domain to get the sellers works, but better avoid the repetition for the performances. --- addons/product/models/product.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/product/models/product.py b/addons/product/models/product.py index 3cb6b240746..019bd7fcef8 100644 --- a/addons/product/models/product.py +++ b/addons/product/models/product.py @@ -398,9 +398,9 @@ class ProductProduct(models.Model): # Prefetch the fields used by the `name_get`, so `browse` doesn't fetch other fields # Use `load=False` to not call `name_get` for the `product_tmpl_id` - self.sudo().read(['name', 'default_code', 'product_tmpl_id', 'attribute_value_ids'], load=False) + products = self.sudo().read(['name', 'default_code', 'product_tmpl_id', 'attribute_value_ids'], load=False) - product_template_ids = [product.product_tmpl_id.id for product in self] + product_template_ids = list(set(product['product_tmpl_id'] for product in products)) if partner_ids: supplier_info = self.env['product.supplierinfo'].sudo().search([