Merge lp:~openerp-dev/openobject-addons/7.0-opw-592447-rha into lp:openobject-addons/7.0

Proposed by Rifakat Husen (OpenERP)
Status: Approved
Approved by: Naresh(OpenERP)
Approved revision: 9133
Proposed branch: lp:~openerp-dev/openobject-addons/7.0-opw-592447-rha
Merge into: lp:openobject-addons/7.0
Diff against target: 42 lines (+8/-7)
1 file modified
product/pricelist.py (+8/-7)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/7.0-opw-592447-rha
Reviewer Review Type Date Requested Status
Naresh(OpenERP) (community) Approve
Review via email: mp+164163@code.launchpad.net

Description of the change

On sales order, when you have pricelist configured with the rule that calculates price based on
supplier price on the product form, that price is not getting used.

Scenario:
* I want to sell product based on the price on which this product's supplier delivers
* create sales pricelist having version rule based on 'Supplier prices on the product form'
* selecting product on sales item does not fill unit price based on it's supplier price

Also there is a problem when we have any version rule based on 'Other Pricelist' nestedly.
When selling any product, it checks customer's id on the product_supplierinfo table to fetch
price(this is actually a case for purchase) and we will never find customer id on this table
so there is not need to check it, and simply get supplier's price which satisfies the qty criteria.

To post a comment you must log in.
Revision history for this message
Naresh(OpenERP) (nch-openerp) :
review: Approve

Unmerged revisions

9133. By Rifakat Husen (OpenERP)

[FIX] product: selling product with sales pricelist on version rule based on supplier price does not work

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'product/pricelist.py'
--- product/pricelist.py 2013-04-18 14:10:13 +0000
+++ product/pricelist.py 2013-05-16 11:51:09 +0000
@@ -202,14 +202,15 @@
202 categ_where = '(categ_id IN (' + ','.join(map(str, categ_ids)) + '))'202 categ_where = '(categ_id IN (' + ','.join(map(str, categ_ids)) + '))'
203 else:203 else:
204 categ_where = '(categ_id IS NULL)'204 categ_where = '(categ_id IS NULL)'
205205
206 if partner:206 if partner and self.browse(cr, uid, pricelist_id, context=context).type == 'purchase':
207 partner_where = 'base <> -2 OR %s IN (SELECT name FROM product_supplierinfo WHERE product_id = %s) '207 partner_where = 'AND (base <> -2 OR %s IN (SELECT name FROM product_supplierinfo WHERE product_id = %s)) '
208 partner_args = (partner, tmpl_id)208 partner_args = (partner, tmpl_id)
209 else:209 else:
210 partner_where = 'base <> -2 '210 partner_where= ' '
211 partner_args = ()211 partner_args = ()
212212 partner = None
213
213 cr.execute(214 cr.execute(
214 'SELECT i.*, pl.currency_id '215 'SELECT i.*, pl.currency_id '
215 'FROM product_pricelist_item AS i, '216 'FROM product_pricelist_item AS i, '
@@ -217,7 +218,7 @@
217 'WHERE (product_tmpl_id IS NULL OR product_tmpl_id = %s) '218 'WHERE (product_tmpl_id IS NULL OR product_tmpl_id = %s) '
218 'AND (product_id IS NULL OR product_id = %s) '219 'AND (product_id IS NULL OR product_id = %s) '
219 'AND (' + categ_where + ' OR (categ_id IS NULL)) '220 'AND (' + categ_where + ' OR (categ_id IS NULL)) '
220 'AND (' + partner_where + ') '221 + partner_where +
221 'AND price_version_id = %s '222 'AND price_version_id = %s '
222 'AND (min_quantity IS NULL OR min_quantity <= %s) '223 'AND (min_quantity IS NULL OR min_quantity <= %s) '
223 'AND i.price_version_id = v.id AND v.pricelist_id = pl.id '224 'AND i.price_version_id = v.id AND v.pricelist_id = pl.id '
@@ -233,7 +234,7 @@
233 else:234 else:
234 price_tmp = self.price_get(cr, uid,235 price_tmp = self.price_get(cr, uid,
235 [res['base_pricelist_id']], product_id,236 [res['base_pricelist_id']], product_id,
236 qty, context=context)[res['base_pricelist_id']]237 qty, partner=partner, context=context)[res['base_pricelist_id']]
237 ptype_src = self.browse(cr, uid, res['base_pricelist_id']).currency_id.id238 ptype_src = self.browse(cr, uid, res['base_pricelist_id']).currency_id.id
238 uom_price_already_computed = True239 uom_price_already_computed = True
239 price = currency_obj.compute(cr, uid,240 price = currency_obj.compute(cr, uid,