add filter to excels
This commit is contained in:
@@ -186,11 +186,12 @@ class ProductExcelViewSet(viewsets.ModelViewSet, DynamicSearchMixin):
|
|||||||
|
|
||||||
today = datetime.now().date()
|
today = datetime.now().date()
|
||||||
user_relations = product_models.UserRelations.objects.filter(user=request.user).first()
|
user_relations = product_models.UserRelations.objects.filter(user=request.user).first()
|
||||||
|
|
||||||
incentive_plans = user_relations.incentive_plans.filter(
|
incentive_plans = user_relations.incentive_plans.filter(
|
||||||
Q(is_time_unlimited=False) |
|
Q(is_time_unlimited=False) |
|
||||||
Q(start_date_limit__lte=today, end_date_limit__gte=today)
|
Q(start_date_limit__lte=today, end_date_limit__gte=today)
|
||||||
)
|
)
|
||||||
|
user_relations = self.filter_query(incentive_plans)
|
||||||
ser_data = IncentivePlanSerializer(incentive_plans, many=True).data
|
ser_data = IncentivePlanSerializer(incentive_plans, many=True).data
|
||||||
|
|
||||||
excel_options = [
|
excel_options = [
|
||||||
@@ -268,6 +269,7 @@ class ProductExcelViewSet(viewsets.ModelViewSet, DynamicSearchMixin):
|
|||||||
)
|
)
|
||||||
def detail_quota_excel(self, request):
|
def detail_quota_excel(self, request):
|
||||||
queryset = product_models.Quota.objects.filter(id=request.GET['id'], trash=False)
|
queryset = product_models.Quota.objects.filter(id=request.GET['id'], trash=False)
|
||||||
|
queryset = self.filter_query(queryset)
|
||||||
serializer_class = QuotaSerializer
|
serializer_class = QuotaSerializer
|
||||||
filter_backends = [filters.SearchFilter]
|
filter_backends = [filters.SearchFilter]
|
||||||
search_fields = [
|
search_fields = [
|
||||||
@@ -526,6 +528,8 @@ class ProductExcelViewSet(viewsets.ModelViewSet, DynamicSearchMixin):
|
|||||||
)
|
)
|
||||||
def quota_excel(self, request):
|
def quota_excel(self, request):
|
||||||
queryset = product_models.Quota.objects.all()
|
queryset = product_models.Quota.objects.all()
|
||||||
|
queryset = self.filter_query(queryset)
|
||||||
|
|
||||||
serializer_class = QuotaSerializer
|
serializer_class = QuotaSerializer
|
||||||
filter_backends = [filters.SearchFilter]
|
filter_backends = [filters.SearchFilter]
|
||||||
search_fields = [
|
search_fields = [
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ from openpyxl.styles import Font
|
|||||||
from rest_framework import viewsets
|
from rest_framework import viewsets
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
|
|
||||||
|
from apps.core.mixins.search_mixin import DynamicSearchMixin
|
||||||
from apps.warehouse import models as warehouse_models
|
from apps.warehouse import models as warehouse_models
|
||||||
from apps.warehouse.web.api.v1 import serializers as warehouse_serializers
|
from apps.warehouse.web.api.v1 import serializers as warehouse_serializers
|
||||||
from common.helper_excel import create_header, excel_description, create_header_freez, create_value, shamsi_date, \
|
from common.helper_excel import create_header, excel_description, create_header_freez, create_value, shamsi_date, \
|
||||||
@@ -13,7 +14,7 @@ from common.helper_excel import create_header, excel_description, create_header_
|
|||||||
from common.helpers import get_organization_by_user
|
from common.helpers import get_organization_by_user
|
||||||
|
|
||||||
|
|
||||||
class WareHouseExcelViewSet(viewsets.ModelViewSet):
|
class WareHouseExcelViewSet(viewsets.ModelViewSet, DynamicSearchMixin):
|
||||||
queryset = warehouse_models.InventoryEntry.objects.all()
|
queryset = warehouse_models.InventoryEntry.objects.all()
|
||||||
serializer_class = warehouse_serializers.InventoryEntrySerializer
|
serializer_class = warehouse_serializers.InventoryEntrySerializer
|
||||||
|
|
||||||
@@ -31,8 +32,9 @@ class WareHouseExcelViewSet(viewsets.ModelViewSet):
|
|||||||
worksheet = workbook.active
|
worksheet = workbook.active
|
||||||
worksheet.sheet_view.rightToLeft = True
|
worksheet.sheet_view.rightToLeft = True
|
||||||
worksheet.insert_rows(1)
|
worksheet.insert_rows(1)
|
||||||
|
queryset = self.filter_query(self.queryset)
|
||||||
|
|
||||||
entries = self.queryset.filter(organization=get_organization_by_user(request.user))
|
entries = queryset.filter(organization=get_organization_by_user(request.user))
|
||||||
ser_data = self.serializer_class(entries, many=True).data
|
ser_data = self.serializer_class(entries, many=True).data
|
||||||
|
|
||||||
excel_options = [
|
excel_options = [
|
||||||
|
|||||||
Reference in New Issue
Block a user