From 8b5ede8a58ecdae46c4fa94ceef5b943512b335f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 12 Dec 2013 13:31:21 +0100 Subject: [PATCH] Test move from _get_inventory_moves before setting location issue3530 review2011002 (transplanted from 1a68309d3de62a024703eaa2ae7a3aca79f208e6) --- location.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/location.py b/location.py index 639776230c..59e451364b 100644 --- a/location.py +++ b/location.py @@ -52,11 +52,12 @@ class ShipmentIn: @classmethod def _get_inventory_moves(cls, incoming_move): move = super(ShipmentIn, cls)._get_inventory_moves(incoming_move) - for product_location in incoming_move.product.locations: - if product_location.warehouse.id != \ - incoming_move.shipment.warehouse.id: - continue - move.to_location = product_location.location + if move: + for product_location in incoming_move.product.locations: + if product_location.warehouse.id != \ + incoming_move.shipment.warehouse.id: + continue + move.to_location = product_location.location return move @@ -67,8 +68,9 @@ class ShipmentOutReturn: def _get_inventory_moves(cls, incoming_move): move = super(ShipmentOutReturn, cls)._get_inventory_moves( incoming_move) - for product_location in incoming_move.product.locations: - if (product_location.warehouse - == incoming_move.shipment.warehouse): - move.to_location = product_location.location + if move: + for product_location in incoming_move.product.locations: + if (product_location.warehouse + == incoming_move.shipment.warehouse): + move.to_location = product_location.location return move