42 lines
1.5 KiB
Python
42 lines
1.5 KiB
Python
from apps.warehouse.web.api.v1 import serializers as warehouse_serializers
|
|
from apps.warehouse import models as warehouse_models
|
|
from common.liara_tools import upload_to_liara
|
|
from rest_framework.decorators import action
|
|
from rest_framework.response import Response
|
|
from rest_framework import viewsets, filters
|
|
from django.db import transaction
|
|
from rest_framework import status
|
|
|
|
|
|
class InventoryEntryViewSet(viewsets.ModelViewSet):
|
|
queryset = warehouse_models.InventoryEntry.objects.all()
|
|
serializer_class = warehouse_serializers.InventoryEntrySerializer
|
|
filter_backends = [filters.SearchFilter]
|
|
search_fields = ['']
|
|
|
|
@action(
|
|
methods=['get'],
|
|
detail=True,
|
|
url_path='confirmation_document',
|
|
url_name='confirmation_document',
|
|
name='confirmation_document'
|
|
)
|
|
def confirmation_document(self, request, pk=None):
|
|
""" upload document for inventory entry confirmation """
|
|
|
|
inventory = self.get_object()
|
|
|
|
# upload document to liara
|
|
document = request.FILES.get('document')
|
|
document_url = upload_to_liara(
|
|
document,
|
|
f'inventory_entry_document_{inventory.di}'
|
|
)
|
|
|
|
|
|
class InventoryQuotaSaleTransactionViewSet(viewsets.ModelViewSet):
|
|
queryset = warehouse_models.InventoryQuotaSaleTransaction.objects.all()
|
|
serializer_class = warehouse_serializers.InventoryQuotaSaleTransactionSerializer
|
|
filter_backends = [filters.SearchFilter]
|
|
search_fields = ['']
|