2025-07-02 15:42:51 +03:30
|
|
|
from apps.warehouse.web.api.v1 import serializers as warehouse_serializers
|
|
|
|
|
from apps.warehouse import models as warehouse_models
|
2025-07-28 09:52:17 +03:30
|
|
|
from common.liara_tools import upload_to_liara
|
2025-07-02 15:42:51 +03:30
|
|
|
from rest_framework.decorators import action
|
|
|
|
|
from rest_framework.response import Response
|
2025-07-13 10:29:52 +03:30
|
|
|
from rest_framework import viewsets, filters
|
2025-07-02 15:42:51 +03:30
|
|
|
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
|
2025-07-13 10:29:52 +03:30
|
|
|
filter_backends = [filters.SearchFilter]
|
|
|
|
|
search_fields = ['']
|
2025-07-02 15:42:51 +03:30
|
|
|
|
2025-07-28 09:52:17 +03:30
|
|
|
@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}'
|
|
|
|
|
)
|
|
|
|
|
|
2025-07-02 15:42:51 +03:30
|
|
|
|
|
|
|
|
class InventoryQuotaSaleTransactionViewSet(viewsets.ModelViewSet):
|
|
|
|
|
queryset = warehouse_models.InventoryQuotaSaleTransaction.objects.all()
|
|
|
|
|
serializer_class = warehouse_serializers.InventoryQuotaSaleTransactionSerializer
|
2025-07-13 10:29:52 +03:30
|
|
|
filter_backends = [filters.SearchFilter]
|
|
|
|
|
search_fields = ['']
|