From 07600c09b7811b7f963d679467111e3cda4ac726 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Fri, 18 Mar 2016 11:46:47 +0200 Subject: Handle editing a product that's been removed from order --- servo/views/order.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/servo/views/order.py b/servo/views/order.py index e9d5a51..3b3930a 100644 --- a/servo/views/order.py +++ b/servo/views/order.py @@ -664,7 +664,12 @@ def edit_product(request, pk, item_id): Edits a product added to an order """ order = Order.objects.get(pk=pk) - item = ServiceOrderItem.objects.get(pk=item_id) + + try: + item = ServiceOrderItem.objects.get(pk=item_id) + except ServiceOrderItem.DoesNotExist: + messages.error(request, _('Product not found in order')) + return redirect(order) if not item.kbb_sn and item.product.part_type == "REPLACEMENT": try: -- cgit v1.2.3