Merge lp:~yann-papouin/ocb-addons/6.1-bug-1169074-pricelist-category-depth into lp:ocb-addons/6.1

Proposed by Yann Papouin
Status: Merged
Merged at revision: 6812
Proposed branch: lp:~yann-papouin/ocb-addons/6.1-bug-1169074-pricelist-category-depth
Merge into: lp:ocb-addons/6.1
Diff against target: 76 lines (+38/-14)
1 file modified
product/pricelist.py (+38/-14)
To merge this branch: bzr merge lp:~yann-papouin/ocb-addons/6.1-bug-1169074-pricelist-category-depth
Reviewer Review Type Date Requested Status
Holger Brunn (Therp) Approve
Review via email: mp+184510@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

I think your code is fine.

But it would be very unfortunate to have this feature in 6.1 and loose it when stepping over to 7.0, so please also provide an MP effecting the same change for 7.0.

review: Approve
Revision history for this message
Yann Papouin (yann-papouin) wrote :

Thank you for your review.

It's not easy for me to make MP for 7.0 as our company is not using it, we are using 6.1 in production/daily use for our specific needs since 01/2013, and I'm fixing bugs as soon as they can be traced.

It would be hard to me to justify my work time on something that is not used by my company to my employer.
Worse, as I don't really follow 7.0/trunk code evolution, I prefer not making any MP to avoid any error as I don't have any code introspection experience on these versions.

I think that my MP is enough to help anyone to create it's own MP from his 7.0's experience.

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 2012-01-31 13:36:57 +0000
3+++ product/pricelist.py 2013-09-09 08:08:27 +0000
4@@ -199,8 +199,10 @@
5 categ_ids = _create_parent_category_list(categ_id, [categ_id])
6 if categ_ids:
7 categ_where = '(categ_id IN (' + ','.join(map(str, categ_ids)) + '))'
8+ categ_where_i = '(i.categ_id IN (' + ','.join(map(str, categ_ids)) + '))'
9 else:
10 categ_where = '(categ_id IS NULL)'
11+ categ_where_i = '(i.categ_id IS NULL)'
12
13 if partner:
14 partner_where = 'base <> -2 OR %s IN (SELECT name FROM product_supplierinfo WHERE product_id = %s) '
15@@ -208,20 +210,41 @@
16 else:
17 partner_where = 'base <> -2 '
18 partner_args = ()
19-
20- cr.execute(
21- 'SELECT i.*, pl.currency_id '
22- 'FROM product_pricelist_item AS i, '
23- 'product_pricelist_version AS v, product_pricelist AS pl '
24- 'WHERE (product_tmpl_id IS NULL OR product_tmpl_id = %s) '
25- 'AND (product_id IS NULL OR product_id = %s) '
26- 'AND (' + categ_where + ' OR (categ_id IS NULL)) '
27- 'AND (' + partner_where + ') '
28- 'AND price_version_id = %s '
29- 'AND (min_quantity IS NULL OR min_quantity <= %s) '
30- 'AND i.price_version_id = v.id AND v.pricelist_id = pl.id '
31- 'ORDER BY sequence',
32- (tmpl_id, product_id) + partner_args + (pricelist_version_ids[0], qty))
33+
34+ query = (
35+ 'SELECT '
36+ 'i.*, pl.currency_id , p.* '
37+ 'FROM '
38+ 'product_pricelist_item AS i '
39+ 'JOIN product_pricelist_version AS v '
40+ 'ON i.price_version_id = v.id '
41+ 'JOIN product_pricelist AS pl '
42+ 'ON v.pricelist_id = pl.id '
43+ 'LEFT OUTER JOIN ( '
44+ 'WITH RECURSIVE subtree(depth, categ_id, parent_id, name) AS ( '
45+ 'SELECT 0, id, parent_id, name FROM product_category WHERE parent_id is NULL '
46+ 'UNION '
47+ 'SELECT depth+1, m.id, m.parent_id, m.name '
48+ 'FROM subtree t, product_category m '
49+ 'WHERE m.parent_id = t.categ_id '
50+ ') '
51+ 'SELECT * '
52+ 'FROM subtree '
53+ 'WHERE (' + categ_where + ' OR (categ_id IS NULL)) '
54+ ') AS p '
55+ 'on i.categ_id = p.categ_id '
56+ 'WHERE '
57+ '(product_tmpl_id IS NULL OR product_tmpl_id = %s) '
58+ 'AND (product_id IS NULL OR product_id = %s) '
59+ 'AND (' + categ_where_i + ' OR (i.categ_id IS NULL)) '
60+ 'AND (' + partner_where + ') '
61+ 'AND price_version_id = %s '
62+ 'AND (min_quantity IS NULL OR min_quantity <= %s) '
63+ 'ORDER BY '
64+ 'sequence, depth desc '
65+ ) % ((tmpl_id, product_id) + partner_args + (pricelist_version_ids[0], qty))
66+
67+ cr.execute(query)
68 res1 = cr.dictfetchall()
69 uom_price_already_computed = False
70 for res in res1:
71@@ -304,6 +327,7 @@
72 res.update({'item_id': {ids[-1]: res_multi.get('item_id', ids[-1])}})
73 return res
74
75+
76 product_pricelist()
77
78

Subscribers

People subscribed via source and target branches