2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-09 07:00:56 +00:00

Adds a BomUpload endpoint to handle upload of complete BOM

This commit is contained in:
Oliver
2022-02-07 10:54:37 +11:00
parent 80818c464a
commit a2c48d308f
5 changed files with 169 additions and 37 deletions

View File

@ -1545,7 +1545,7 @@ class BomExtract(generics.CreateAPIView):
"""
Custom create function to return the extracted data
"""
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
self.perform_create(serializer)
@ -1556,6 +1556,16 @@ class BomExtract(generics.CreateAPIView):
return Response(data, status=status.HTTP_201_CREATED, headers=headers)
class BomUpload(generics.CreateAPIView):
"""
API endpoint for uploading a complete Bill of Materials.
It is assumed that the BOM has been extracted from a file using the BomExtract endpoint.
"""
queryset = Part.objects.all()
serializer_class = part_serializers.BomUploadSerializer
class BomDetail(generics.RetrieveUpdateDestroyAPIView):
""" API endpoint for detail view of a single BomItem object """
@ -1710,6 +1720,9 @@ bom_api_urls = [
])),
url(r'^extract/', BomExtract.as_view(), name='api-bom-extract'),
url(r'^upload/', BomUpload.as_view(), name='api-bom-upload'),
# Catch-all
url(r'^.*$', BomList.as_view(), name='api-bom-list'),
]