From c13d18d93b7e4f87a16a3fe6e3eb04add94508a7 Mon Sep 17 00:00:00 2001 From: Numerigraphe - Lionel Sausin Date: Wed, 28 Sep 2011 17:34:34 +0200 Subject: [PATCH] [FIX] Only consider pricelist items based on partner if we have a partner and it's on the product's supplier info lp bug: https://launchpad.net/bugs/860625 fixed bzr revid: ls@numerigraphe.fr-20110928153434-5qd9lbk6i2dm2f5l --- addons/product/pricelist.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/addons/product/pricelist.py b/addons/product/pricelist.py index 81cec0e7d95..94046710880 100644 --- a/addons/product/pricelist.py +++ b/addons/product/pricelist.py @@ -210,6 +210,13 @@ class product_pricelist(osv.osv): else: categ_where = '(categ_id IS NULL)' + if partner: + partner_where = 'base <> -2 OR %s IN (SELECT name FROM product_supplierinfo WHERE product_id = %s) ' + partner_args = (partner, product_id) + else: + partner_where = 'base <> -2 ' + partner_args = () + cr.execute( 'SELECT i.*, pl.currency_id ' 'FROM product_pricelist_item AS i, ' @@ -217,11 +224,12 @@ class product_pricelist(osv.osv): 'WHERE (product_tmpl_id IS NULL OR product_tmpl_id = %s) ' 'AND (product_id IS NULL OR product_id = %s) ' 'AND (' + categ_where + ' OR (categ_id IS NULL)) ' + 'AND (' + partner_where + ') ' 'AND price_version_id = %s ' 'AND (min_quantity IS NULL OR min_quantity <= %s) ' 'AND i.price_version_id = v.id AND v.pricelist_id = pl.id ' 'ORDER BY sequence', - (tmpl_id, product_id, plversion_ids[0], qty)) + (tmpl_id, product_id) + partner_args + (plversion_ids[0], qty)) res1 = cr.dictfetchall() uom_price_already_computed = False for res in res1: @@ -365,6 +373,12 @@ class product_pricelist(osv.osv): categ_where = '(categ_id IN (' + ','.join(categ_ids) + '))' else: categ_where = '(categ_id IS NULL)' + + if partner: + partner_where = 'base <> -2 OR %s IN (SELECT name FROM product_supplierinfo WHERE product_id = %s) ' + sqlargs = sqlargs + (partner, prod_id) + else: + partner_where = 'base <> -2 ' cr.execute( 'SELECT i.*, pl.currency_id ' @@ -373,6 +387,7 @@ class product_pricelist(osv.osv): 'WHERE (product_tmpl_id IS NULL OR product_tmpl_id = %s) ' 'AND (product_id IS NULL OR product_id = %s) ' 'AND (' + categ_where + ' OR (categ_id IS NULL)) ' + 'AND (' + partner_where + ') ' 'AND price_version_id = %s ' 'AND (min_quantity IS NULL OR min_quantity <= %s) ' 'AND i.price_version_id = v.id AND v.pricelist_id = pl.id '