From d8151c8dfe0a7268f45e2227be64cd9fc6a3220c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 30 Oct 2008 11:30:04 +0100 Subject: [PATCH] Don't set cancel-draft for move that are already in draft in set_state_draft Because cost_price is computed when canceling a move and set_state_draft is called by the workflow at the creation of the packing. --- packing.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packing.py b/packing.py index 4151b104b2..54923390f6 100644 --- a/packing.py +++ b/packing.py @@ -212,12 +212,14 @@ class PackingIn(OSV): def set_state_draft(self, cursor, user, packing_id, context=None): move_obj = self.pool.get('stock.move') packing = self.browse(cursor, user, packing_id, context=context) - move_obj.write( - cursor, user, [m.id for m in packing.incoming_moves], - {'state': 'cancel'}, context=context) - move_obj.write( - cursor, user, [m.id for m in packing.incoming_moves], - {'state': 'draft'}, context=context) + move_obj.write(cursor, user, [m.id for m in packing.incoming_moves + if m.state != 'draft'], { + 'state': 'cancel', + }, context=context) + move_obj.write(cursor, user, [m.id for m in packing.incoming_moves + if m.state != 'draft'], { + 'state': 'draft', + }, context=context) move_obj.delete(cursor, user, [m.id for m in packing.inventory_moves], context=context) self.write(cursor, user, packing_id, {