aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2015-09-30 09:33:47 +0300
committerFilipp Lepalaan <filipp@mac.com>2015-09-30 09:33:47 +0300
commitf0ee747761f0f929ab25b58a071e0a34dd763527 (patch)
tree3f66010e88a457c1bcd9f9be5579a6634b5d7694
parent3d5a54a91dcc2013cf6949311c6efa12b19f3897 (diff)
downloadServo-f0ee747761f0f929ab25b58a071e0a34dd763527.tar.gz
Servo-f0ee747761f0f929ab25b58a071e0a34dd763527.tar.bz2
Servo-f0ee747761f0f929ab25b58a071e0a34dd763527.zip
Handle moving non-existing inventory
-rw-r--r--servo/models/order.py10
1 files changed, 7 insertions, 3 deletions
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)