[IMP] Put remaining qty in variable not to calculate multiple times
bzr revid: jco@openerp.com-20140227084509-cr589ynshxltt2fv
This commit is contained in:
parent
bb3045f0f8
commit
23128a26ae
|
@ -1100,16 +1100,17 @@ class stock_picking(osv.osv):
|
|||
todo_move_ids = []
|
||||
toassign_move_ids = []
|
||||
for move in picking.move_lines:
|
||||
remaining_qty = move.remaining_qty
|
||||
if move.state in ('done', 'cancel'):
|
||||
#ignore stock moves cancelled or already done
|
||||
continue
|
||||
elif move.state == 'draft':
|
||||
toassign_move_ids.append(move.id)
|
||||
if move.remaining_qty == 0:
|
||||
if remaining_qty == 0:
|
||||
if move.state in ('draft', 'assigned', 'confirmed'):
|
||||
todo_move_ids.append(move.id)
|
||||
elif move.remaining_qty > 0 and move.remaining_qty < move.product_qty:
|
||||
new_move = stock_move_obj.split(cr, uid, move, move.remaining_qty, context=context)
|
||||
elif remaining_qty > 0 and remaining_qty < move.product_qty:
|
||||
new_move = stock_move_obj.split(cr, uid, move, remaining_qty, context=context)
|
||||
todo_move_ids.append(move.id)
|
||||
#Assign move as it was assigned before
|
||||
toassign_move_ids.append(new_move)
|
||||
|
@ -1355,6 +1356,7 @@ class stock_move(osv.osv):
|
|||
res += [x.id for x in picking.move_lines]
|
||||
return res
|
||||
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Description', required=True, select=True),
|
||||
'priority': fields.selection([('0', 'Not urgent'), ('1', 'Urgent')], 'Priority'),
|
||||
|
@ -3528,7 +3530,11 @@ class stock_pack_operation(osv.osv):
|
|||
for move in sorted_moves:
|
||||
if move.product_id.id == product_id and move.state not in ['done', 'cancel']:
|
||||
qty_on_link = min(move.remaining_qty, qty_to_assign)
|
||||
link_obj.create(cr, uid, {'move_id': move.id, 'operation_id': op.id, 'qty': qty_on_link}, context=context)
|
||||
before = time.time()
|
||||
cr.execute("""insert into stock_move_operation_link (move_id, operation_id, qty) values
|
||||
(%s, %s, %s)""", (move.id, op.id, qty_on_link,))
|
||||
# link_obj.create(cr, uid, {'move_id': move.id, 'operation_id': op.id, 'qty': qty_on_link}, context=context)
|
||||
print "Link create", time.time() - before
|
||||
qty_to_assign -= qty_on_link
|
||||
move.refresh()
|
||||
if qty_to_assign <= 0:
|
||||
|
@ -3541,7 +3547,9 @@ class stock_pack_operation(osv.osv):
|
|||
#Entire packages means entire quants from those packages
|
||||
if not quants_done.get(quant.id):
|
||||
quants_done[quant.id] = 0
|
||||
before = time.time()
|
||||
link_obj.create(cr, uid, {'move_id': quant.reservation_id.id, 'operation_id': ops.id, 'qty': quant.qty}, context=context)
|
||||
print "Link create", time.time() - before
|
||||
else:
|
||||
qty = uom_obj._compute_qty(cr, uid, ops.product_uom_id.id, ops.product_qty, ops.product_id.uom_id.id)
|
||||
#Check moves with same product
|
||||
|
@ -3595,6 +3603,7 @@ class stock_pack_operation(osv.osv):
|
|||
if op.product_id:
|
||||
#TODO: Remaining qty: UoM conversions are done twice
|
||||
normalized_qty = uom_obj._compute_qty(cr, uid, op.product_uom_id.id, op.remaining_qty, op.product_id.uom_id.id)
|
||||
|
||||
if normalized_qty > 0:
|
||||
_create_link_for_product(op.product_id.id, normalized_qty)
|
||||
elif op.package_id:
|
||||
|
|
|
@ -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()
|
Loading…
Reference in New Issue