update excel

This commit is contained in:
2026-01-27 14:21:46 +03:30
parent 3b4ef2c1e1
commit c55433a1b7
4 changed files with 60 additions and 9 deletions

View File

@@ -4510,10 +4510,8 @@ class AllProductsTransportViewSet(viewsets.ModelViewSet):
pagination_class = CustomPagination
filterset_class = AllProductsTransportFilterSet
def list(self, request, *args, **kwargs):
transports = self.filter_queryset(self.get_queryset())
filters = {"trash": False}
product_type = request.GET.get('product_type')
destination_province = request.GET.get('destination_province')
date1 = request.GET.get('date1')
@@ -4521,21 +4519,23 @@ class AllProductsTransportViewSet(viewsets.ModelViewSet):
search = request.GET.get('search')
if product_type and product_type != 'undefined':
transports = transports.filter(product=product_type)
filters['product'] = product_type
if destination_province and destination_province != 'undefined':
transports = transports.filter(destination_province=destination_province)
filters['destination_province'] = destination_province
if date1 and date2 and date1 != 'undefined' and date2 != 'undefined':
try:
start_date = datetime.datetime.strptime(str(date1), '%Y-%m-%d')
end_date = datetime.datetime.strptime(str(date2), '%Y-%m-%d')
transports = transports.filter(date__gte=start_date, date__lte=end_date)
filters['date__gte'] = start_date
filters['date__lte'] = end_date
except ValueError:
pass
if search:
if search != 'undefined' and search.strip():
transports = AllProductsTransport.objects.filter(**filters).order_by('-date', '-create_date')
if search and search != 'undefined' and search.strip():
transports = transports.filter(
build_query(self.filterset_class.Meta.fields, search)
)