From f0ee747761f0f929ab25b58a071e0a34dd763527 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Wed, 30 Sep 2015 09:33:47 +0300 Subject: Handle moving non-existing inventory --- servo/models/order.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'servo/models/order.py') diff --git a/servo/models/order.py b/servo/models/order.py index d394502..18fc3b0 100644 --- a/servo/models/order.py +++ b/servo/models/order.py @@ -433,9 +433,13 @@ class Order(models.Model): # move the products too for soi in self.serviceorderitem_set.all(): product = soi.product - source = Inventory.objects.get(location=self.location, product=product) - source.move(new_location, soi.amount) - + + try: + source = Inventory.objects.get(location=self.location, product=product) + source.move(new_location, soi.amount) + except Inventory.DoesNotExist: + pass # @TODO: Is this OK? + self.location = new_location msg = _(u"Order %s moved to %s") % (self.code, new_location.title) self.notify("set_location", msg, user) -- cgit v1.2.3