From e5ac627834d383af325415b8db39055460df5c81 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 5 Sep 2024 12:29:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20wmaterial=20filter=5Fqueryset=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E8=BF=94=E5=9B=9E=E9=9D=9E=E6=8A=A5=E5=BA=9F=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wpm/views.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/wpm/views.py b/apps/wpm/views.py index e0ac32d5..81566e30 100644 --- a/apps/wpm/views.py +++ b/apps/wpm/views.py @@ -119,6 +119,12 @@ class WMaterialViewSet(ListModelMixin, CustomGenericViewSet): 'material__number', 'material__specification', 'batch', 'material__model'] filterset_class = WMaterialFilter + def filter_queryset(self, queryset): + queryset = super().filter_queryset(queryset) + if self.request.query_params.get('state_all'): + return queryset + return queryset.exclude(state=WMaterial.WM_SCRAP) + @action(methods=['post'], detail=False, perms_map={'post': '*'}, serializer_class=DeptBatchSerializer) @transaction.atomic def batchs(self, request):