From 10f6e145ddc501be0b6a051f7ede168fcaa3141b Mon Sep 17 00:00:00 2001 From: Sylvain GARANCHER Date: Thu, 3 Aug 2017 18:56:51 +0200 Subject: [PATCH] [FIX] product: The pricelist variable must be a recordset, not a list Steps to reproduce the bug: -On an empty database, install the sale module -Activate product variants : Sales > Settings > Check Products can have several attributes, defining variants (Example: size, color,...) -Activate advanced pricelists : Sales > Settings > Check Advanced pricing based on formulas (discounts, margins, rounding) -Activate the developer mode -Go to the product.templates list : Sales > Products -Go to the debug menu > Edit TreeView and add the price field in the view -Search for a pricelist : Type the name of an existing pricelist, then go to the pricelists proposal, open the list of proposed pricelists, and select the pricelist Bug: A traceback was raised. opw:762663 --- addons/product/models/product_template.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/product/models/product_template.py b/addons/product/models/product_template.py index 16ac91ce034..38ff6c4ceba 100644 --- a/addons/product/models/product_template.py +++ b/addons/product/models/product_template.py @@ -164,7 +164,9 @@ class ProductTemplate(models.Model): # Support context pricelists specified as display_name or ID for compatibility if isinstance(pricelist_id_or_name, basestring): - pricelist = self.env['product.pricelist'].name_search(pricelist_id_or_name, operator='=', limit=1) + pricelist_data = self.env['product.pricelist'].name_search(pricelist_id_or_name, operator='=', limit=1) + if pricelist_data: + pricelist = self.env['product.pricelist'].browse(pricelist_data[0][0]) elif isinstance(pricelist_id_or_name, (int, long)): pricelist = self.env['product.pricelist'].browse(pricelist_id_or_name)