add search ro excel
This commit is contained in:
@@ -22,19 +22,12 @@ class ProductExcelViewSet(viewsets.ModelViewSet, DynamicSearchMixin):
|
|||||||
serializer_class = distribution_serializers.QuotaDistributionSerializer
|
serializer_class = distribution_serializers.QuotaDistributionSerializer
|
||||||
filter_backends = [filters.SearchFilter]
|
filter_backends = [filters.SearchFilter]
|
||||||
search_fields = [
|
search_fields = [
|
||||||
"assigner_organization__name",
|
|
||||||
"assigned_organization__name",
|
|
||||||
"distribution_id",
|
|
||||||
"quota__quota_id",
|
|
||||||
"quota__product__name",
|
|
||||||
"quota__sale_type",
|
|
||||||
"quota__group",
|
|
||||||
"registerer_organization__name",
|
"registerer_organization__name",
|
||||||
"quota_id",
|
"quota_id",
|
||||||
"product__name",
|
"product__name",
|
||||||
"sale_type",
|
"sale_type",
|
||||||
"sale_unit__unit",
|
"sale_unit__unit",
|
||||||
"group"
|
"group",
|
||||||
]
|
]
|
||||||
|
|
||||||
# noqa # سهمیه و توزیع
|
# noqa # سهمیه و توزیع
|
||||||
@@ -286,6 +279,15 @@ class ProductExcelViewSet(viewsets.ModelViewSet, DynamicSearchMixin):
|
|||||||
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)
|
queryset = self.filter_query(queryset)
|
||||||
serializer_class = QuotaSerializer
|
serializer_class = QuotaSerializer
|
||||||
|
filter_backends = [filters.SearchFilter]
|
||||||
|
search_fields = [
|
||||||
|
"registerer_organization__name",
|
||||||
|
"quota_id",
|
||||||
|
"product__name",
|
||||||
|
"sale_type",
|
||||||
|
"sale_unit__unit",
|
||||||
|
"group",
|
||||||
|
]
|
||||||
|
|
||||||
output = BytesIO()
|
output = BytesIO()
|
||||||
workbook = Workbook()
|
workbook = Workbook()
|
||||||
@@ -533,9 +535,21 @@ class ProductExcelViewSet(viewsets.ModelViewSet, DynamicSearchMixin):
|
|||||||
name='quota_excel'
|
name='quota_excel'
|
||||||
)
|
)
|
||||||
def quota_excel(self, request):
|
def quota_excel(self, request):
|
||||||
|
search_fields = [
|
||||||
|
"registerer_organization__name",
|
||||||
|
"quota_id",
|
||||||
|
"product__name",
|
||||||
|
"sale_type",
|
||||||
|
"sale_unit__unit",
|
||||||
|
"group",
|
||||||
|
]
|
||||||
queryset = product_models.Quota.objects.all()
|
queryset = product_models.Quota.objects.all()
|
||||||
queryset = self.filter_query(queryset)
|
queryset = self.filter_query(queryset)
|
||||||
|
|
||||||
serializer_class = QuotaSerializer
|
serializer_class = QuotaSerializer
|
||||||
|
filter_backends = [filters.SearchFilter]
|
||||||
|
|
||||||
|
|
||||||
output = BytesIO()
|
output = BytesIO()
|
||||||
workbook = Workbook()
|
workbook = Workbook()
|
||||||
worksheet = workbook.active
|
worksheet = workbook.active
|
||||||
|
|||||||
Reference in New Issue
Block a user