[FIX]Fixed Partial deliveries problem
lp bug: https://launchpad.net/bugs/399817 fixed bzr revid: hda@tinyerp.com-20090910091254-2xzcrzdvmgcigfmt
This commit is contained in:
committed by
HDA (OpenERP)
parent
9513616ae1
commit
01c96820db
+16
-3
@@ -492,7 +492,7 @@ class sale_order(osv.osv):
|
||||
if line.procurement_id:
|
||||
res.append(line.procurement_id.id)
|
||||
return res
|
||||
|
||||
|
||||
# if mode == 'finished':
|
||||
# returns True if all lines are done, False otherwise
|
||||
# if mode == 'canceled':
|
||||
@@ -504,9 +504,22 @@ class sale_order(osv.osv):
|
||||
notcanceled = False
|
||||
write_done_ids = []
|
||||
write_cancel_ids = []
|
||||
stock_move_obj = self.pool.get('stock.move')
|
||||
|
||||
for order in self.browse(cr, uid, ids, context={}):
|
||||
for line in order.order_line:
|
||||
if (not line.procurement_id) or (line.procurement_id.state=='done'):
|
||||
|
||||
#check for pending deliveries
|
||||
pending_deliveries = False
|
||||
|
||||
for line in order.order_line:
|
||||
move_ids = stock_move_obj.search(cr, uid, [('sale_line_id','=', line.id)])
|
||||
for move in stock_move_obj.browse( cr, uid, move_ids ):
|
||||
#if one of the related order lines is in state draft, auto or confirmed
|
||||
#this order line is not yet delivered
|
||||
if move.state in ('draft', 'auto', 'confirmed'):
|
||||
pending_deliveries = True
|
||||
|
||||
if ((not line.procurement_id) or (line.procurement_id.state=='done')) and not pending_deliveries:
|
||||
finished = True
|
||||
if line.state != 'done':
|
||||
write_done_ids.append(line.id)
|
||||
|
||||
@@ -1135,6 +1135,11 @@ class stock_move(osv.osv):
|
||||
if move.state in ('confirmed', 'waiting'):
|
||||
res = self.pool.get('stock.location')._product_reserve(cr, uid, [move.location_id.id], move.product_id.id, move.product_qty, {'uom': move.product_uom.id})
|
||||
if res:
|
||||
#_product_available_test depends on the next status for correct functioning
|
||||
#the test does not work correctly if the same product occurs multiple times
|
||||
#in the same order. This is e.g. the case when using the button 'split in two' of
|
||||
#the stock outgoing form
|
||||
self.write(cr, uid, move.id, {'state':'assigned'})
|
||||
done.append(move.id)
|
||||
pickings[move.picking_id.id] = 1
|
||||
r = res.pop(0)
|
||||
|
||||
Reference in New Issue
Block a user