diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 3d176264b42..5619c952ab2 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -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) diff --git a/addons/stock_megatest/test/megatestmtobuy.yml b/addons/stock_megatest/test/megatestmtobuy.yml index 0ec5d2d47be..e5129e22c15 100644 --- a/addons/stock_megatest/test/megatestmtobuy.yml +++ b/addons/stock_megatest/test/megatestmtobuy.yml @@ -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() \ No newline at end of file