From 0773bba147ea3f1c5c42ca77065d31dd31b95309 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 16 Aug 2012 15:59:44 +0200 Subject: [PATCH] Improve creation of inventory moves to write only once on shipment review457002 --- shipment.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/shipment.py b/shipment.py index 1aede63250..3faae092bc 100644 --- a/shipment.py +++ b/shipment.py @@ -377,12 +377,15 @@ class ShipmentIn(Workflow, ModelSQL, ModelView): def create_inventory_moves(self, shipments): for shipment in shipments: + inventory_moves = [] for incoming_move in shipment.incoming_moves: vals = self._get_inventory_moves(incoming_move) if vals: - self.write(shipment.id, { - 'inventory_moves': [('create', vals)], - }) + inventory_moves.append(('create', vals)) + if inventory_moves: + self.write(shipment.id, { + 'inventory_moves': inventory_moves, + }) def delete(self, ids): if isinstance(ids, (int, long)):