From 742d55de2c1128a4d457817bd2ce8d548488b170 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Thu, 16 Jan 2014 11:26:21 +0100 Subject: [PATCH] [REF] stock: small refactoring of code bzr revid: qdp-launchpad@openerp.com-20140116102621-r8dsx9j5wyp79v1s --- addons/stock/stock.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 7c64cdab2d7..2f52ce604e0 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1055,17 +1055,20 @@ class stock_picking(osv.osv): todo_move_ids = [] toassign_move_ids = [] for move in picking.move_lines: - if move.state == 'draft': + 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 move.state in ('draft', 'assigned', 'confirmed'): todo_move_ids.append(move.id) - elif move.remaining_qty > 0 and move.state not in ['done', 'cancel']: + elif move.remaining_qty > 0: new_move = stock_move_obj.split(cr, uid, move, move.remaining_qty, context=context) todo_move_ids.append(move.id) #Assign move as it was assigned before toassign_move_ids.append(new_move) - elif move.state not in ['done', 'cancel']: + elif move.state: #this should never happens raise self.rereserve_quants(cr, uid, picking, move_ids=todo_move_ids, context=context)