mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge pull request #303 from SchrodingersGat/optional-quantity
Make the 'quantity' field optional in the stock move API
This commit is contained in:
commit
992ee27f87
@ -178,7 +178,11 @@ class StockMove(APIView):
|
|||||||
for item in stock_list:
|
for item in stock_list:
|
||||||
try:
|
try:
|
||||||
stock_id = int(item['pk'])
|
stock_id = int(item['pk'])
|
||||||
|
if 'quantity' in item:
|
||||||
quantity = int(item['quantity'])
|
quantity = int(item['quantity'])
|
||||||
|
else:
|
||||||
|
# If quantity not supplied, we'll move the entire stock
|
||||||
|
quantity = None
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# Ignore this one
|
# Ignore this one
|
||||||
continue
|
continue
|
||||||
@ -192,6 +196,9 @@ class StockMove(APIView):
|
|||||||
except StockItem.DoesNotExist:
|
except StockItem.DoesNotExist:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if quantity is None:
|
||||||
|
quantity = stock.quantity
|
||||||
|
|
||||||
stock.move(location, data.get('notes'), request.user, quantity=quantity)
|
stock.move(location, data.get('notes'), request.user, quantity=quantity)
|
||||||
|
|
||||||
return Response({'success': 'Moved parts to {loc}'.format(
|
return Response({'success': 'Moved parts to {loc}'.format(
|
||||||
|
Loading…
Reference in New Issue
Block a user