Merge lp:~yann-papouin/ocb-addons/6.1-bug-899470-stock-product-available-optimization into lp:ocb-addons/6.1

Proposed by Yann Papouin
Status: Merged
Merged at revision: 6845
Proposed branch: lp:~yann-papouin/ocb-addons/6.1-bug-899470-stock-product-available-optimization
Merge into: lp:ocb-addons/6.1
Diff against target: 33 lines (+9/-6)
1 file modified
stock/product.py (+9/-6)
To merge this branch: bzr merge lp:~yann-papouin/ocb-addons/6.1-bug-899470-stock-product-available-optimization
Reviewer Review Type Date Requested Status
Ana Juaristi Olalde (community) code review Approve
Pedro Manuel Baeza code review Approve
Omar (Pexego) code review Approve
Guewen Baconnier @ Camptocamp Needs Information
Holger Brunn (Therp) code review Approve
Review via email: mp+205200@code.launchpad.net

Description of the change

Backport from existing functionality in 6.0/7.0/trunk

To post a comment you must log in.
Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

verified that this is functionally equivalent to what 7.0-ocb does.

Side note: When you want to give people credit, better do a bzr log -r -1 on the branch you merge, there you'll see the author's email address. Use that as --author, this way launchpad can connect the commit to the launchpad account in question.

review: Approve (code review)
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

The fix is different on https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-50947-ado/+merge/123889

I don't know which one is better. Can you check?

Thanks

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

My proposal don't use the temporary variable uoms_ids = {} since it contains exactly the same data than product2uom.values()

Revision history for this message
Omar (Pexego) (omar7r) wrote :

LGTM

review: Approve (code review)
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Guewen, does Yann's answer satisfy you? For my part, it's correct.

Regards.

review: Approve (code review)
Revision history for this message
Ana Juaristi Olalde (ajuaristio) :
review: Approve (code review)
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

I proceed with the merge, because Guewen's question has been answered.

Regards.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'stock/product.py'
2--- stock/product.py 2012-07-05 08:27:08 +0000
3+++ stock/product.py 2014-02-06 16:00:18 +0000
4@@ -185,6 +185,7 @@
5 location_obj = self.pool.get('stock.location')
6 warehouse_obj = self.pool.get('stock.warehouse')
7 shop_obj = self.pool.get('sale.shop')
8+ uom_obj = self.pool.get('product.uom')
9
10 states = context.get('states',[])
11 what = context.get('what',())
12@@ -222,13 +223,15 @@
13 child_location_ids = location_obj.search(cr, uid, [('location_id', 'child_of', location_ids)])
14 location_ids = child_location_ids or location_ids
15
16- # this will be a dictionary of the UoM resources we need for conversion purposes, by UoM id
17+ # Extract UoM id from product ids
18+ product2uom = {}
19+ for product in self.read(cr, uid, ids, ['uom_id'], context=context):
20+ product2uom[product['id']] = product['uom_id'][0]
21+
22+ # Create a dict of the UoM resources by id that we need for conversion purposes
23 uoms_o = {}
24- # this will be a dictionary of the product UoM by product id
25- product2uom = {}
26- for product in self.browse(cr, uid, ids, context=context):
27- product2uom[product.id] = product.uom_id.id
28- uoms_o[product.uom_id.id] = product.uom_id
29+ for uom in uom_obj.browse(cr, uid, product2uom.values(), context=context):
30+ uoms_o[uom.id] = uom
31
32 results = []
33 results2 = []

Subscribers

People subscribed via source and target branches