[MERGE] lp: 860625 (pricelist item wrongly chosen when based on partner section of product form). Courtesy of Numerigraphe

bzr revid: qdp-launchpad@openerp.com-20111116114039-4i8jge9e36v3umbc
This commit is contained in:
Quentin (OpenERP)
2011-11-16 12:40:39 +01:00
+16 -1
View File
@@ -202,6 +202,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, '
@@ -209,11 +216,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, pricelist_version_ids[0], qty))
(tmpl_id, product_id) + partner_args + (pricelist_version_ids[0], qty))
res1 = cr.dictfetchall()
uom_price_already_computed = False
for res in res1:
@@ -357,6 +365,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 '
@@ -365,6 +379,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 '