2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-14 19:15:41 +00:00

Pass stock move quantity through per item

This commit is contained in:
Oliver Walters
2019-05-11 00:04:45 +10:00
parent 99c0921113
commit 8d5c4c521c
2 changed files with 44 additions and 12 deletions

View File

@ -151,7 +151,7 @@ class StockMove(APIView):
data = request.data
if u'location' not in data:
if 'location' not in data:
raise ValidationError({'location': 'Destination must be specified'})
loc_id = data.get(u'location')
@ -161,18 +161,34 @@ class StockMove(APIView):
except StockLocation.DoesNotExist:
raise ValidationError({'location': 'Location does not exist'})
if u'parts[]' not in data:
raise ValidationError({'parts[]': 'Parts list must be specified'})
if 'stock' not in data:
raise ValidationError({'stock': 'Stock list must be specified'})
stock_list = data.get('stock')
part_list = data.get(u'parts[]')
if type(stock_list) is not list:
raise ValidationError({'stock': 'Stock must be supplied as a list'})
if 'notes' not in data:
raise ValidationError({'notes': 'Notes field must be supplied'})
parts = []
errors = []
if u'notes' not in data:
errors.append({'notes': 'Notes field must be supplied'})
for item in stock_list:
try:
stock_id = int(item['pk'])
quantity = int(item['quantity'])
except ValueError:
# Ignore this one
continue
print('stock:', stock_id)
print('quantity:', quantity)
"""
for pid in part_list:
try:
part = StockItem.objects.get(pk=pid)
@ -189,6 +205,10 @@ class StockMove(APIView):
if part.move(location, data.get('notes'), request.user):
n += 1
"""
n = 0
return Response({'success': 'Moved {n} parts to {loc}'.format(
n=n,
loc=str(location)