mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-09 07:00:56 +00:00
Add new attechment functionality to new models
- Giving the ol' refactor tractor a fresh coat of paint
This commit is contained in:
@ -29,6 +29,7 @@ from .serializers import StockItemAttachmentSerializer
|
||||
|
||||
from InvenTree.views import TreeSerializer
|
||||
from InvenTree.helpers import str2bool, isNull
|
||||
from InvenTree.api import AttachmentMixin
|
||||
|
||||
from decimal import Decimal, InvalidOperation
|
||||
|
||||
@ -645,7 +646,7 @@ class StockList(generics.ListCreateAPIView):
|
||||
]
|
||||
|
||||
|
||||
class StockAttachmentList(generics.ListCreateAPIView):
|
||||
class StockAttachmentList(generics.ListCreateAPIView, AttachmentMixin):
|
||||
"""
|
||||
API endpoint for listing (and creating) a StockItemAttachment (file upload)
|
||||
"""
|
||||
@ -653,22 +654,10 @@ class StockAttachmentList(generics.ListCreateAPIView):
|
||||
queryset = StockItemAttachment.objects.all()
|
||||
serializer_class = StockItemAttachmentSerializer
|
||||
|
||||
filter_backends = [
|
||||
DjangoFilterBackend,
|
||||
filters.OrderingFilter,
|
||||
filters.SearchFilter,
|
||||
]
|
||||
|
||||
filter_fields = [
|
||||
'stock_item',
|
||||
]
|
||||
|
||||
def perform_create(self, serializer):
|
||||
|
||||
attachment = serializer.save()
|
||||
attachment.user = self.request.user
|
||||
attachment.save()
|
||||
|
||||
|
||||
class StockTrackingList(generics.ListCreateAPIView):
|
||||
""" API endpoint for list view of StockItemTracking objects.
|
||||
|
Reference in New Issue
Block a user