Merge lp:~numerigraphe/openobject-addons/6.0-lp860625-pricelists into lp:openobject-addons/6.0

Proposed by Numérigraphe
Status: Needs review
Proposed branch: lp:~numerigraphe/openobject-addons/6.0-lp860625-pricelists
Merge into: lp:openobject-addons/6.0
Diff against target: 52 lines (+16/-1)
1 file modified
product/pricelist.py (+16/-1)
To merge this branch: bzr merge lp:~numerigraphe/openobject-addons/6.0-lp860625-pricelists
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+77348@code.launchpad.net

Description of the change

This should fix pricelists when the first item is based on the supplier section of the product, and we either don't have a partner or it's not in the supplier section.
Both price_get_multi and price_get_old are patched.

To post a comment you must log in.

Unmerged revisions

4854. By Numerigraphe - Lionel Sausin <email address hidden>

[FIX] Only consider pricelist items based on partner if we have a partner and it's on the product's supplier info

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 2011-04-21 07:45:29 +0000
3+++ product/pricelist.py 2011-09-28 15:35:35 +0000
4@@ -210,6 +210,13 @@
5 else:
6 categ_where = '(categ_id IS NULL)'
7
8+ if partner:
9+ partner_where = 'base <> -2 OR %s IN (SELECT name FROM product_supplierinfo WHERE product_id = %s) '
10+ partner_args = (partner, product_id)
11+ else:
12+ partner_where = 'base <> -2 '
13+ partner_args = ()
14+
15 cr.execute(
16 'SELECT i.*, pl.currency_id '
17 'FROM product_pricelist_item AS i, '
18@@ -217,11 +224,12 @@
19 'WHERE (product_tmpl_id IS NULL OR product_tmpl_id = %s) '
20 'AND (product_id IS NULL OR product_id = %s) '
21 'AND (' + categ_where + ' OR (categ_id IS NULL)) '
22+ 'AND (' + partner_where + ') '
23 'AND price_version_id = %s '
24 'AND (min_quantity IS NULL OR min_quantity <= %s) '
25 'AND i.price_version_id = v.id AND v.pricelist_id = pl.id '
26 'ORDER BY sequence',
27- (tmpl_id, product_id, plversion_ids[0], qty))
28+ (tmpl_id, product_id) + partner_args + (plversion_ids[0], qty))
29 res1 = cr.dictfetchall()
30 uom_price_already_computed = False
31 for res in res1:
32@@ -365,6 +373,12 @@
33 categ_where = '(categ_id IN (' + ','.join(categ_ids) + '))'
34 else:
35 categ_where = '(categ_id IS NULL)'
36+
37+ if partner:
38+ partner_where = 'base <> -2 OR %s IN (SELECT name FROM product_supplierinfo WHERE product_id = %s) '
39+ sqlargs = sqlargs + (partner, prod_id)
40+ else:
41+ partner_where = 'base <> -2 '
42
43 cr.execute(
44 'SELECT i.*, pl.currency_id '
45@@ -373,6 +387,7 @@
46 'WHERE (product_tmpl_id IS NULL OR product_tmpl_id = %s) '
47 'AND (product_id IS NULL OR product_id = %s) '
48 'AND (' + categ_where + ' OR (categ_id IS NULL)) '
49+ 'AND (' + partner_where + ') '
50 'AND price_version_id = %s '
51 'AND (min_quantity IS NULL OR min_quantity <= %s) '
52 'AND i.price_version_id = v.id AND v.pricelist_id = pl.id '