Bugfix
authorhda (Tiny) <hda@tinyerp.com>
Wed, 28 Jan 2009 14:29:42 +0000 (19:59 +0530)
committerhda (Tiny) <hda@tinyerp.com>
Wed, 28 Jan 2009 14:29:42 +0000 (19:59 +0530)
lp bug: https://launchpad.net/bugs/321797 fixed

bzr revid: hda@tinyerp.com-20090128142942-7d7ljmq44fwqk2uf

addons/stock/product.py
addons/stock/wizard/wizard_inventory.py

index e60e7a7..47453c6 100644 (file)
@@ -66,8 +66,11 @@ class product_product(osv.osv):
             location_ids = [id for (id,) in cr.fetchall()]
 
         # build the list of ids of children of the location given by id
-        child_location_ids = self.pool.get('stock.location').search(cr, uid, [('location_id', 'child_of', location_ids)])
-        location_ids= len(child_location_ids) and child_location_ids or location_ids
+        if context.get('compute_child',True):
+            child_location_ids = self.pool.get('stock.location').search(cr, uid, [('location_id', 'child_of', location_ids)])
+            location_ids= len(child_location_ids) and child_location_ids or location_ids
+        else:
+            location_ids= location_ids
 
         states_str = ','.join(map(lambda s: "'%s'" % s, states))
 
index 8befd65..aebeb21 100644 (file)
@@ -63,7 +63,8 @@ def _fill_inventory(self, cr, uid, data, context):
             res=location_obj._product_get(cr, uid, location)
             res_location[location]=res
     else:
-        res=location_obj._product_get(cr, uid, data['form']['location_id'])
+        context.update({'compute_child':False})
+        res=location_obj._product_get(cr, uid, data['form']['location_id'],context=context)
         res_location[data['form']['location_id']]=res
 
     product_ids=[]
@@ -73,7 +74,8 @@ def _fill_inventory(self, cr, uid, data, context):
             #product_ids.append(product_id)
             prod = pool.get('product.product').browse(cr, uid, [product_id])[0]
             uom = prod.uom_id.id
-            amount=pool.get('stock.location')._product_get(cr, uid, location, [product_id], {'uom': uom})[product_id]
+            context.update({'uom': uom})
+            amount=pool.get('stock.location')._product_get(cr, uid, location, [product_id], context=context)[product_id]
 
             if(amount):
                 line_ids=inventory_line_obj.search(cr,uid,[('inventory_id','=',data['id']),('location_id','=',location),('product_id','=',product_id),('product_uom','=',uom),('product_qty','=',amount)])