[FIX] Be sure the reserved quants are handled well in recompute and action_assign should not assign moves not in its ids, even if in ops

bzr revid: jco@openerp.com-20140313142002-c4zs75p1oay3gkpd
This commit is contained in:
Josse Colpaert 2014-03-13 15:20:02 +01:00
parent 8ed31b881b
commit 50cd5eae53
1 changed files with 19 additions and 16 deletions

View File

@ -31,6 +31,8 @@ from openerp import SUPERUSER_ID
import openerp.addons.decimal_precision as dp
import logging
from profilehooks import profile
_logger = logging.getLogger(__name__)
#----------------------------------------------------------
# Incoterms
@ -1100,6 +1102,7 @@ class stock_picking(osv.osv):
if prod_move.get(product_id):
for move in prod_move[product_id]:
qty_on_link = min(qty_move_rem[move.id], qty_to_assign)
if qty_on_link > 0:
cr.execute("""insert into stock_move_operation_link (move_id, operation_id, qty) values
(%s, %s, %s)""", (move.id, op.id, qty_on_link,))
qty_move_rem[move.id] -= qty_on_link
@ -1141,7 +1144,6 @@ class stock_picking(osv.osv):
flag = flag and (ops.owner_id.id == quant.owner_id.id)
if flag:
quant_qty = quant.qty
if quants_done.get(quant.id):
if quants_done[quant.id] == 0:
continue
quant_qty = quants_done[quant.id]
@ -1186,7 +1188,6 @@ class stock_picking(osv.osv):
for op in operations:
_check_quants_reserved(op)
remaining_qty_ok = True
for op in operations:
op.refresh()
@ -2028,6 +2029,7 @@ class stock_move(osv.osv):
if check and not lot_id:
raise osv.except_osv(_('Warning!'), _('You must assign a serial number for the product %s') % (move.product_id.name))
@profile(immediate=True)
def action_assign(self, cr, uid, ids, context=None):
""" Checks the product type and accordingly writes the state.
"""
@ -2076,6 +2078,7 @@ class stock_move(osv.osv):
#first try to find quants based on specific domains given by linked operations
for record in ops.linked_move_operation_ids:
move = record.move_id
if move.id in main_domain:
domain = main_domain[move.id] + self.pool.get('stock.move.operation.link').get_specific_domain(cr, uid, record, context=context)
qty_already_assigned = sum([q.qty for q in record.reserved_quant_ids])
qty = record.qty - qty_already_assigned