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
=== modified file 'product/pricelist.py'
--- product/pricelist.py 2012-01-31 13:36:57 +0000
+++ product/pricelist.py 2013-09-09 08:08:27 +0000
@@ -199,8 +199,10 @@
199 categ_ids = _create_parent_category_list(categ_id, [categ_id])199 categ_ids = _create_parent_category_list(categ_id, [categ_id])
200 if categ_ids:200 if categ_ids:
201 categ_where = '(categ_id IN (' + ','.join(map(str, categ_ids)) + '))'201 categ_where = '(categ_id IN (' + ','.join(map(str, categ_ids)) + '))'
202 categ_where_i = '(i.categ_id IN (' + ','.join(map(str, categ_ids)) + '))'
202 else:203 else:
203 categ_where = '(categ_id IS NULL)'204 categ_where = '(categ_id IS NULL)'
205 categ_where_i = '(i.categ_id IS NULL)'
204206
205 if partner:207 if partner:
206 partner_where = 'base <> -2 OR %s IN (SELECT name FROM product_supplierinfo WHERE product_id = %s) '208 partner_where = 'base <> -2 OR %s IN (SELECT name FROM product_supplierinfo WHERE product_id = %s) '
@@ -208,20 +210,41 @@
208 else:210 else:
209 partner_where = 'base <> -2 '211 partner_where = 'base <> -2 '
210 partner_args = ()212 partner_args = ()
211213
212 cr.execute(214 query = (
213 'SELECT i.*, pl.currency_id '215 'SELECT '
214 'FROM product_pricelist_item AS i, '216 'i.*, pl.currency_id , p.* '
215 'product_pricelist_version AS v, product_pricelist AS pl '217 'FROM '
216 'WHERE (product_tmpl_id IS NULL OR product_tmpl_id = %s) '218 'product_pricelist_item AS i '
217 'AND (product_id IS NULL OR product_id = %s) '219 'JOIN product_pricelist_version AS v '
218 'AND (' + categ_where + ' OR (categ_id IS NULL)) '220 'ON i.price_version_id = v.id '
219 'AND (' + partner_where + ') '221 'JOIN product_pricelist AS pl '
220 'AND price_version_id = %s '222 'ON v.pricelist_id = pl.id '
221 'AND (min_quantity IS NULL OR min_quantity <= %s) '223 'LEFT OUTER JOIN ( '
222 'AND i.price_version_id = v.id AND v.pricelist_id = pl.id '224 'WITH RECURSIVE subtree(depth, categ_id, parent_id, name) AS ( '
223 'ORDER BY sequence',225 'SELECT 0, id, parent_id, name FROM product_category WHERE parent_id is NULL '
224 (tmpl_id, product_id) + partner_args + (pricelist_version_ids[0], qty))226 'UNION '
227 'SELECT depth+1, m.id, m.parent_id, m.name '
228 'FROM subtree t, product_category m '
229 'WHERE m.parent_id = t.categ_id '
230 ') '
231 'SELECT * '
232 'FROM subtree '
233 'WHERE (' + categ_where + ' OR (categ_id IS NULL)) '
234 ') AS p '
235 'on i.categ_id = p.categ_id '
236 'WHERE '
237 '(product_tmpl_id IS NULL OR product_tmpl_id = %s) '
238 'AND (product_id IS NULL OR product_id = %s) '
239 'AND (' + categ_where_i + ' OR (i.categ_id IS NULL)) '
240 'AND (' + partner_where + ') '
241 'AND price_version_id = %s '
242 'AND (min_quantity IS NULL OR min_quantity <= %s) '
243 'ORDER BY '
244 'sequence, depth desc '
245 ) % ((tmpl_id, product_id) + partner_args + (pricelist_version_ids[0], qty))
246
247 cr.execute(query)
225 res1 = cr.dictfetchall()248 res1 = cr.dictfetchall()
226 uom_price_already_computed = False249 uom_price_already_computed = False
227 for res in res1:250 for res in res1:
@@ -304,6 +327,7 @@
304 res.update({'item_id': {ids[-1]: res_multi.get('item_id', ids[-1])}})327 res.update({'item_id': {ids[-1]: res_multi.get('item_id', ids[-1])}})
305 return res328 return res
306329
330
307product_pricelist()331product_pricelist()
308332
309333

Subscribers

People subscribed via source and target branches