[FIX] stock: correctly handle case when we have no child location
bzr revid: mat@openerp.com-20131015112016-vj6yr6kfxfe8go2p
This commit is contained in:
parent
7040fb35dd
commit
98d31e411f
|
@ -403,14 +403,15 @@ class stock_location(osv.osv):
|
||||||
uom_rounding = uom_obj.browse(cr, uid, context.get('uom'), context=context).rounding
|
uom_rounding = uom_obj.browse(cr, uid, context.get('uom'), context=context).rounding
|
||||||
|
|
||||||
locations_ids = self.search(cr, uid, [('location_id', 'child_of', ids)])
|
locations_ids = self.search(cr, uid, [('location_id', 'child_of', ids)])
|
||||||
# Fetch only the locations in which this product has ever been processed (in or out)
|
if locations_ids:
|
||||||
cr.execute("""SELECT l.id FROM stock_location l WHERE l.id in %s AND
|
# Fetch only the locations in which this product has ever been processed (in or out)
|
||||||
EXISTS (SELECT 1 FROM stock_move m WHERE m.product_id = %s
|
cr.execute("""SELECT l.id FROM stock_location l WHERE l.id in %s AND
|
||||||
AND ((state = 'done' AND m.location_dest_id = l.id)
|
EXISTS (SELECT 1 FROM stock_move m WHERE m.product_id = %s
|
||||||
OR (state in ('done','assigned') AND m.location_id = l.id)))
|
AND ((state = 'done' AND m.location_dest_id = l.id)
|
||||||
""", (tuple(locations_ids), product_id,))
|
OR (state in ('done','assigned') AND m.location_id = l.id)))
|
||||||
|
""", (tuple(locations_ids), product_id,))
|
||||||
for id in [i for (i,) in cr.fetchall()]:
|
locations_ids = [i for (i,) in cr.fetchall()]
|
||||||
|
for id in locations_ids:
|
||||||
if lock:
|
if lock:
|
||||||
try:
|
try:
|
||||||
# Must lock with a separate select query because FOR UPDATE can't be used with
|
# Must lock with a separate select query because FOR UPDATE can't be used with
|
||||||
|
|
Loading…
Reference in New Issue