53 lines
2.1 KiB
Python
53 lines
2.1 KiB
Python
from django.shortcuts import render
|
|
from rest_framework.generics import CreateAPIView, GenericAPIView
|
|
from rest_framework.mixins import ListModelMixin
|
|
from rest_framework.utils.field_mapping import get_relation_kwargs
|
|
from rest_framework.viewsets import GenericViewSet, ModelViewSet
|
|
from apps.pm.models import SubProductionPlan
|
|
from apps.pm.serializers import SubProductionPlanListSerializer, SubProductionPlanUpdateSerializer
|
|
|
|
from apps.system.mixins import CreateUpdateModelAMixin, OptimizationMixin
|
|
from rest_framework.decorators import action
|
|
from apps.wpm.models import WMaterial
|
|
|
|
from apps.wpm.serializers import PickSerializer, WMaterialListSerializer
|
|
from rest_framework.response import Response
|
|
# Create your views here.
|
|
class WPlanViewSet(ListModelMixin, GenericViewSet):
|
|
"""
|
|
车间生产计划
|
|
"""
|
|
perms_map = {'*': '*'}
|
|
queryset = SubProductionPlan.objects.select_related('process', 'workshop', 'subproduction', 'main_product').exclude(state=0)
|
|
search_fields = []
|
|
serializer_class = SubProductionPlanListSerializer
|
|
filterset_fields = ['production_plan', 'process', 'state', 'main_product', 'workshop']
|
|
ordering_fields = ['process__number']
|
|
ordering = ['process__number']
|
|
|
|
class WMaterialViewSet(CreateUpdateModelAMixin, ListModelMixin, GenericViewSet):
|
|
"""
|
|
车间物料表
|
|
"""
|
|
perms_map={'*':'*'}
|
|
queryset = WMaterial.objects.select_related('material').all()
|
|
serializer_class = WMaterialListSerializer
|
|
filterset_fields = ['material', 'subproduction_plan', 'subproduction_plan__process', 'subproduction_plan__workshop']
|
|
ordering_fields = ['material__number']
|
|
ordering = ['material__number']
|
|
|
|
@action(methods=['post'], detail=False, perms_map={'post':'*'}, serializer_class=PickSerializer)
|
|
def pick(self, request, pk=None):
|
|
"""
|
|
领料
|
|
"""
|
|
serializer= PickSerializer(data=request.data, context={'request': request})
|
|
serializer.is_valid(raise_exception=True)
|
|
serializer.save()
|
|
return Response()
|
|
|
|
class DoFormInit(CreateAPIView):
|
|
"""
|
|
生产操作表单创建
|
|
"""
|
|
perms_map={'*':'*'} |