车间生产计划过滤条件bug
This commit is contained in:
parent
c6f30f7810
commit
985935641e
|
@ -186,9 +186,12 @@ class RecordFormSerializer(serializers.ModelSerializer):
|
|||
return queryset
|
||||
|
||||
class RecordFormCreateSerializer(serializers.ModelSerializer):
|
||||
form = serializers.PrimaryKeyRelatedField(
|
||||
queryset=RecordForm.objects.all(), label="复制表ID")
|
||||
class Meta:
|
||||
model = RecordForm
|
||||
fields = ['name', 'type', 'step', 'material', 'number', 'enabled']
|
||||
fields = ['name', 'type', 'step', 'material', 'number', 'enabled', 'form']
|
||||
|
||||
|
||||
# def validate(self, attrs):
|
||||
# if attrs['enabled']:
|
||||
|
|
|
@ -35,7 +35,7 @@ from rest_framework import exceptions, serializers
|
|||
from apps.wpm.services import WpmService
|
||||
from django.utils import timezone
|
||||
from rest_framework import status
|
||||
from django.db.models import Count
|
||||
from django.db.models import Count, Q
|
||||
|
||||
from utils.tools import ranstr
|
||||
|
||||
|
@ -49,10 +49,11 @@ class WPlanViewSet(ListModelMixin, GenericViewSet):
|
|||
"""
|
||||
perms_map = {'get': '*'}
|
||||
queryset = SubProductionPlan.objects.select_related(
|
||||
'process', 'workshop', 'subproduction', 'product')\
|
||||
.exclude(state= SubProductionPlan.SUBPLAN_STATE_PLANING,
|
||||
production_plan__state__in=[ProductionPlan.PLAN_STATE_PAUSE,
|
||||
ProductionPlan.PLAN_STATE_STOP])
|
||||
'process', 'workshop', 'subproduction', 'product').filter(
|
||||
production_plan__state__in =[
|
||||
ProductionPlan.PLAN_STATE_WORKING, ProductionPlan.PLAN_STATE_ASSGINED
|
||||
]
|
||||
)
|
||||
search_fields = []
|
||||
serializer_class = SubProductionPlanListSerializer
|
||||
filterset_fields = ['production_plan',
|
||||
|
@ -60,6 +61,7 @@ class WPlanViewSet(ListModelMixin, GenericViewSet):
|
|||
ordering_fields = []
|
||||
ordering = ['-update_time']
|
||||
|
||||
|
||||
@action(methods=['post', 'get'], detail=True, perms_map={'post': 'pick_half', 'get': '*'}, serializer_class=PickHalfsSerializer)
|
||||
@transaction.atomic
|
||||
def pick_half(self, request, pk=None):
|
||||
|
@ -119,6 +121,10 @@ class WPlanViewSet(ListModelMixin, GenericViewSet):
|
|||
pw.save()
|
||||
sp.is_picked = True
|
||||
sp.save()
|
||||
if sp.production_plan.state in \
|
||||
[ProductionPlan.PLAN_STATE_ASSGINED, ProductionPlan.PLAN_STATE_ACCEPTED]:
|
||||
sp.production_plan.state = ProductionPlan.PLAN_STATE_WORKING
|
||||
sp.production_plan.save()
|
||||
|
||||
return Response()
|
||||
|
||||
|
|
Loading…
Reference in New Issue