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