Expose SalesOrderLineItem objects to the REST API

This commit is contained in:
Oliver Walters 2020-04-20 21:11:59 +10:00
parent 47ada25315
commit b2569d5cba
2 changed files with 48 additions and 3 deletions

View File

@ -20,7 +20,7 @@ from .models import PurchaseOrder, PurchaseOrderLineItem
from .serializers import POSerializer, POLineItemSerializer from .serializers import POSerializer, POLineItemSerializer
from .models import SalesOrder, SalesOrderLineItem from .models import SalesOrder, SalesOrderLineItem
from .serializers import SalseOrderSerializer from .serializers import SalseOrderSerializer, SOLineItemSerializer
class POList(generics.ListCreateAPIView): class POList(generics.ListCreateAPIView):
@ -295,6 +295,32 @@ class SODetail(generics.RetrieveUpdateAPIView):
permission_classes = [permissions.IsAuthenticated] permission_classes = [permissions.IsAuthenticated]
class SOLineItemList(generics.ListCreateAPIView):
"""
API endpoint for accessing a list of SalesOrderLineItem objects.
"""
queryset = SalesOrderLineItem.objects.all()
serializer_class = SOLineItemSerializer
permission_classes = [permissions.IsAuthenticated]
filter_backends = [DjangoFilterBackend]
filter_fields = [
'order',
]
class SOLineItemDetail(generics.RetrieveUpdateAPIView):
""" API endpoint for detail view of a SalesOrderLineItem object """
queryset = SalesOrderLineItem.objects.all()
serializer_class = SOLineItemSerializer
permission_classes = [permissions.IsAuthenticated]
order_api_urls = [ order_api_urls = [
# API endpoints for purchase orders # API endpoints for purchase orders
url(r'^po/(?P<pk>\d+)/$', PODetail.as_view(), name='api-po-detail'), url(r'^po/(?P<pk>\d+)/$', PODetail.as_view(), name='api-po-detail'),
@ -307,4 +333,8 @@ order_api_urls = [
# API endpoints for sales ordesr # API endpoints for sales ordesr
url(r'^so/(?P<pk>\d+)/$', SODetail.as_view(), name='api-so-detail'), url(r'^so/(?P<pk>\d+)/$', SODetail.as_view(), name='api-so-detail'),
url(r'^so/$', SOList.as_view(), name='api-so-list'), url(r'^so/$', SOList.as_view(), name='api-so-list'),
# API endpoints for sales order line items
url(r'^so-line/(?P<pk>\d+)/$', SOLineItemDetail.as_view(), name='api-so-line-detail'),
url(r'^so-line/$', SOLineItemList.as_view(), name='api-so-line-list'),
] ]

View File

@ -140,3 +140,18 @@ class SalseOrderSerializer(InvenTreeModelSerializer):
'reference', 'reference',
'status' 'status'
] ]
class SOLineItemSerializer(InvenTreeModelSerializer):
""" Serializer for a SalesOrderLineItem object """
class Meta:
model = SalesOrderLineItem
fields = [
'pk',
'quantity',
'reference',
'notes',
'order',
]