[IMP] Do not search quants when source location requires to create quants

bzr revid: jco@openerp.com-20140227100401-axy57wrto0ex2xf7
This commit is contained in:
Josse Colpaert
2014-02-27 11:04:01 +01:00
parent 23128a26ae
commit 634d0f3ff8
2 changed files with 7 additions and 3 deletions
+5 -1
View File
@@ -2018,6 +2018,7 @@ class stock_move(osv.osv):
for link in move.linked_move_operation_ids:
operations.add(link.operation_id)
#Sort operations according to entire packages first, then package + lot, package only, lot only
operations = list(operations)
operations.sort(key = lambda x: ((x.package_id and not x.product_id) and -4 or 0) + (x.package_id and -2 or 0) + (x.lot_id and -1 or 0))
@@ -2051,7 +2052,10 @@ class stock_move(osv.osv):
fallback_domain = [('reservation_id', '=', False)]
self.check_tracking(cr, uid, move, move.restrict_lot_id.id, context=context)
qty = move_qty[move.id]
quants = quant_obj.quants_get_prefered_domain(cr, uid, move.location_id, move.product_id, qty, domain=main_domain, prefered_domain=prefered_domain, fallback_domain=fallback_domain, restrict_lot_id=move.restrict_lot_id.id, restrict_partner_id=move.restrict_partner_id.id, context=context)
if move.location_id.usage in ('supplier', 'inventory', 'production'):
quants = [(None, move.product_uom_qty)]
else:
quants = quant_obj.quants_get_prefered_domain(cr, uid, move.location_id, move.product_id, qty, domain=main_domain, prefered_domain=prefered_domain, fallback_domain=fallback_domain, restrict_lot_id=move.restrict_lot_id.id, restrict_partner_id=move.restrict_partner_id.id, context=context)
quant_obj.quants_move(cr, uid, quants, move, lot_id=move.restrict_lot_id.id, owner_id=move.restrict_partner_id.id, context=context)
#unreserve the quants and make them available for other operations/moves
quant_obj.quants_unreserve(cr, uid, move, context=context)
@@ -178,7 +178,7 @@
pick_obj = self.pool.get('stock.picking')
# Process those pickings and put in boxes of 20 pieces
for pick in pickings:
pick_obj.do_prepare_partial(cr, uid, [pick.id])
#pick_obj.do_prepare_partial(cr, uid, [pick.id])
#for ops in pick.pack_operation_ids:
# pick
# while ops.product_qty > 100:
@@ -198,6 +198,6 @@
related_dest_pickings = [x.picking_id for x in move_dest_ids if x.picking_id]
picks = list(set(related_dest_pickings))
for pick in picks:
pick_obj.do_prepare_partial(cr, uid, [pick.id])
#pick_obj.do_prepare_partial(cr, uid, [pick.id])
pick_obj.do_transfer(cr, uid, [pick.id])
print "after second transfer", time.time()