diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 7a96d543bd2..2f157085374 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -400,11 +400,14 @@ class stock_picking(osv.osv): return True def test_finnished(self, cr, uid, ids): - for id in ids: - cr.execute('select id,state from stock_move where picking_id=%d', (id,)) - for x in cr.fetchall(): - if x[1] not in ('done','cancel'): + move_ids=self.pool.get('stock.move').search(cr,uid,[('picking_id','in',ids)]) + + for move in self.pool.get('stock.move').browse(cr,uid,move_ids): + if move.state not in ('done','cancel') : + if move.product_qty != 0.0: return False + else: + move.write(cr,uid,[move.id],{'state':'done'}) return True def test_assigned(self, cr, uid, ids):