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
1=== modified file 'product/pricelist.py'
2--- product/pricelist.py 2013-04-18 14:10:13 +0000
3+++ product/pricelist.py 2013-05-16 11:51:09 +0000
4@@ -202,14 +202,15 @@
5 categ_where = '(categ_id IN (' + ','.join(map(str, categ_ids)) + '))'
6 else:
7 categ_where = '(categ_id IS NULL)'
8-
9- if partner:
10- partner_where = 'base <> -2 OR %s IN (SELECT name FROM product_supplierinfo WHERE product_id = %s) '
11+
12+ if partner and self.browse(cr, uid, pricelist_id, context=context).type == 'purchase':
13+ partner_where = 'AND (base <> -2 OR %s IN (SELECT name FROM product_supplierinfo WHERE product_id = %s)) '
14 partner_args = (partner, tmpl_id)
15 else:
16- partner_where = 'base <> -2 '
17+ partner_where= ' '
18 partner_args = ()
19-
20+ partner = None
21+
22 cr.execute(
23 'SELECT i.*, pl.currency_id '
24 'FROM product_pricelist_item AS i, '
25@@ -217,7 +218,7 @@
26 'WHERE (product_tmpl_id IS NULL OR product_tmpl_id = %s) '
27 'AND (product_id IS NULL OR product_id = %s) '
28 'AND (' + categ_where + ' OR (categ_id IS NULL)) '
29- 'AND (' + partner_where + ') '
30+ + partner_where +
31 'AND price_version_id = %s '
32 'AND (min_quantity IS NULL OR min_quantity <= %s) '
33 'AND i.price_version_id = v.id AND v.pricelist_id = pl.id '
34@@ -233,7 +234,7 @@
35 else:
36 price_tmp = self.price_get(cr, uid,
37 [res['base_pricelist_id']], product_id,
38- qty, context=context)[res['base_pricelist_id']]
39+ qty, partner=partner, context=context)[res['base_pricelist_id']]
40 ptype_src = self.browse(cr, uid, res['base_pricelist_id']).currency_id.id
41 uom_price_already_computed = True
42 price = currency_obj.compute(cr, uid,