feat: wmaterial filter_queryset默认返回非报废品

This commit is contained in:
caoqianming 2024-09-05 12:29:36 +08:00
parent 308fa4c7ad
commit e5ac627834
1 changed files with 6 additions and 0 deletions

View File

@ -119,6 +119,12 @@ class WMaterialViewSet(ListModelMixin, CustomGenericViewSet):
'material__number', 'material__specification', 'batch', 'material__model'] 'material__number', 'material__specification', 'batch', 'material__model']
filterset_class = WMaterialFilter 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) @action(methods=['post'], detail=False, perms_map={'post': '*'}, serializer_class=DeptBatchSerializer)
@transaction.atomic @transaction.atomic
def batchs(self, request): def batchs(self, request):