From 97b9cac20525d38b717596c9713cc36d5fd4ece9 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 11 May 2019 00:42:24 +1000 Subject: [PATCH] Successfully move multiple parts with partial quantities --- InvenTree/stock/api.py | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index 7397f45370..ad688c6e28 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -186,34 +186,19 @@ class StockMove(APIView): except ValueError: # Ignore this one continue - - print('stock:', stock_id) - print('quantity:', quantity) - """ - - for pid in part_list: + # Ignore a zero quantity movement + if quantity <= 0: + continue + try: - part = StockItem.objects.get(pk=pid) - parts.append(part) + stock = StockItem.objects.get(pk=stock_id) except StockItem.DoesNotExist: - errors.append({'part': 'Part {id} does not exist'.format(id=pid)}) + continue - if len(errors) > 0: - raise ValidationError(errors) + stock.move(location, data.get('notes'), request.user, quantity=quantity) - n = 0 - - for part in parts: - if part.move(location, data.get('notes'), request.user): - n += 1 - - """ - - n = 0 - - return Response({'success': 'Moved {n} parts to {loc}'.format( - n=n, + return Response({'success': 'Moved parts to {loc}'.format( loc=str(location) )})