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