From ef372a6bd0a447849d3c80963c85f15c5b4a6ff3 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Tue, 18 Feb 2014 10:31:49 +0100 Subject: [PATCH] [FIX] stock: fixes + comments made during code review bzr revid: qdp-launchpad@openerp.com-20140218093149-pg751zobmpied10f --- addons/stock/stock.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index bcb3261675f..36ad25da981 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1775,15 +1775,16 @@ class stock_move(osv.osv): } for move in self.browse(cr, uid, ids, context=context): state = 'confirmed' - for m in move.move_orig_ids: - if move.move_orig_ids: - state = 'waiting' - elif move.split_from: - move2 = move.split_from - while move2 and state != 'waiting': - if move2.move_orig_ids: - state = 'waiting' - move2 = move2.split_from + #if the move is preceeded, then it's waiting (if preceeding move is done, then action_assign has been called already and its state is already available) + if move.move_orig_ids: + state = 'waiting' + #if the move is split and some of the ancestor was preceeded, then it's waiting as well + elif move.split_from: + move2 = move.split_from + while move2 and state != 'waiting': + if move2.move_orig_ids: + state = 'waiting' + move2 = move2.split_from states[state].append(move.id) self._picking_assign(cr, uid, move, context=context) @@ -1842,11 +1843,12 @@ class stock_move(osv.osv): fallback_domain = prev_quant_ids and [('id', 'not in', prev_quant_ids)] or [] #we always keep the quants already assigned and try to find the remaining quantity on quants not assigned only main_domain = [('reservation_id', '=', False), ('qty', '>', 0)] - #Check for original moves + + #if the move is preceeded, restrict the choice of quants in the ones moved previously in original move move_orig_ids = [] - result = False move2 = move while move2: + #loop on the split_from to find the ancestor of split moves move_orig_ids += [x.id for x in move2.move_orig_ids] move2 = move2.split_from if move_orig_ids: @@ -2042,7 +2044,6 @@ class stock_move(osv.osv): self.action_done(cr, uid, res, context=context) return res - def split(self, cr, uid, move, qty, restrict_lot_id=False, restrict_partner_id=False, context=None): """ Splits qty from move move into a new move :param move: browse record @@ -2065,6 +2066,7 @@ class stock_move(osv.osv): 'product_uom_qty': uom_qty, 'product_uos_qty': uos_qty, 'state': move.state, + 'procure_method': 'make_to_stock', 'move_dest_id': False, 'reserved_quant_ids': [], 'restrict_lot_id': restrict_lot_id,