diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index 1c654d8b3c..f0fb8a5d7a 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -15,6 +15,7 @@ from django.db.models import Q from .models import StockLocation, StockItem from .models import StockItemTracking from .models import StockItemAttachment +from .models import StockItemTestResult from part.models import Part, PartCategory from part.serializers import PartBriefSerializer @@ -26,6 +27,7 @@ from .serializers import StockItemSerializer from .serializers import LocationSerializer, LocationBriefSerializer from .serializers import StockTrackingSerializer from .serializers import StockItemAttachmentSerializer +from .serializers import StockItemTestResultSerializer from InvenTree.views import TreeSerializer from InvenTree.helpers import str2bool, isNull @@ -659,6 +661,33 @@ class StockAttachmentList(generics.ListCreateAPIView, AttachmentMixin): ] +class StockItemTestResultList(generics.ListCreateAPIView): + """ + API endpoint for listing (and creating) a StockItemTestResult object. + """ + + queryset = StockItemTestResult.objects.all() + serializer_class = StockItemTestResultSerializer + + permission_classes = [ + permissions.IsAuthenticated, + ] + + filter_backends = [ + DjangoFilterBackend, + filters.SearchFilter, + filters.OrderingFilter, + ] + + filter_fields = [ + 'stock_item', + 'test', + 'user', + 'result', + 'value', + ] + + class StockTrackingList(generics.ListCreateAPIView): """ API endpoint for list view of StockItemTracking objects. @@ -769,6 +798,11 @@ stock_api_urls = [ url(r'^$', StockAttachmentList.as_view(), name='api-stock-attachment-list'), ])), + # Base URL for StockItemTestResult API endpoints + url(r'^test/', include([ + url(r'^$', StockItemTestResultList.as_view(), name='api-stock-test-result-list'), + ])), + url(r'track/?', StockTrackingList.as_view(), name='api-stock-track'), url(r'^tree/?', StockCategoryTree.as_view(), name='api-stock-tree'), diff --git a/InvenTree/stock/serializers.py b/InvenTree/stock/serializers.py index ad53da200d..8459aefd2a 100644 --- a/InvenTree/stock/serializers.py +++ b/InvenTree/stock/serializers.py @@ -225,6 +225,7 @@ class StockItemTestResultSerializer(InvenTreeModelSerializer): fields = [ 'pk', + 'stock_item', 'test', 'result', 'value',