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.
This commit is contained in:
Cédric Krier
2008-10-30 11:30:04 +01:00
parent d54bf32fe4
commit d8151c8dfe
+8 -6
View File
@@ -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, {