From 1f8632c77cc7186c458ed1d1259d993c13b49145 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 25 Apr 2019 23:19:22 +1000 Subject: [PATCH] Improved response message for stocktake --- InvenTree/stock/api.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index 2ac2ea584e..ca1d0b9988 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -111,17 +111,22 @@ class StockStocktake(APIView): if 'notes' in request.data: notes = request.data['notes'] + n = 0 + for item in items: quantity = int(item['quantity']) if action == u'stocktake': - item['item'].stocktake(quantity, request.user, notes=notes) + if item['item'].stocktake(quantity, request.user, notes=notes): + n += 1 elif action == u'remove': - item['item'].take_stock(quantity, request.user, notes=notes) + if item['item'].take_stock(quantity, request.user, notes=notes): + n += 1 elif action == u'add': - item['item'].add_stock(quantity, request.user, notes=notes) + if item['item'].add_stock(quantity, request.user, notes=notes): + n += 1 - return Response({'success': 'success'}) + return Response({'success': 'Updated stock for {n} items'.format(n=n)}) class StockMove(APIView):