2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-12 07:54:14 +00:00

Detail in StockItem API now optional

This commit is contained in:
Oliver Walters
2019-05-23 22:57:45 +10:00
parent 9052ccc181
commit 5664fc5472
6 changed files with 42 additions and 9 deletions

View File

@ -18,6 +18,7 @@ from .serializers import LocationSerializer
from .serializers import StockTrackingSerializer
from InvenTree.views import TreeSerializer
from InvenTree.helpers import str2bool
from rest_framework.serializers import ValidationError
from rest_framework.views import APIView
@ -245,6 +246,17 @@ class StockList(generics.ListCreateAPIView):
- supplier: Filter by supplier
"""
def get_serializer(self, *args, **kwargs):
part_detail = str2bool(self.request.GET.get('part_detail', None))
location_detail = str2bool(self.request.GET.get('location_detail', None))
kwargs['part_detail'] = part_detail
kwargs['location_detail'] = location_detail
kwargs['context'] = self.get_serializer_context()
return self.serializer_class(*args, **kwargs)
def get_queryset(self):
"""
If the query includes a particular location,