testrecord item parent
This commit is contained in:
parent
e4706e2635
commit
e9cea356d3
|
@ -56,6 +56,7 @@ class TestRecordItemSerializer(serializers.ModelSerializer):
|
||||||
rule_expression = serializers.JSONField(source='form_field.rule_expression', read_only=True)
|
rule_expression = serializers.JSONField(source='form_field.rule_expression', read_only=True)
|
||||||
display_expression = serializers.JSONField(source='form_field.display_expression', read_only=True)
|
display_expression = serializers.JSONField(source='form_field.display_expression', read_only=True)
|
||||||
is_hidden = serializers.BooleanField(source='form_field.is_hidden', read_only=True)
|
is_hidden = serializers.BooleanField(source='form_field.is_hidden', read_only=True)
|
||||||
|
parent = serializers.IntegerField(source='form_field.parent', read_only=True)
|
||||||
help_text = serializers.CharField(source='form_field.help_text', read_only=True)
|
help_text = serializers.CharField(source='form_field.help_text', read_only=True)
|
||||||
sort = serializers.IntegerField(source='form_field.sort', read_only=True)
|
sort = serializers.IntegerField(source='form_field.sort', read_only=True)
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
|
@ -35,6 +35,7 @@ class WProduct(CommonAModel):
|
||||||
WPR_ACT_STATE_INM = 40
|
WPR_ACT_STATE_INM = 40
|
||||||
WPR_ACT_STATE_NOTOK = 50
|
WPR_ACT_STATE_NOTOK = 50
|
||||||
WPR_ACT_STATE_TOFINALTEST = 60
|
WPR_ACT_STATE_TOFINALTEST = 60
|
||||||
|
WPR_ACT_STATE_SCRAP = 70
|
||||||
act_state_choices=(
|
act_state_choices=(
|
||||||
(WPR_ACT_STATE_TORETEST, '待复检'),
|
(WPR_ACT_STATE_TORETEST, '待复检'),
|
||||||
(WPR_ACT_STATE_DOWAIT, '操作准备中'),
|
(WPR_ACT_STATE_DOWAIT, '操作准备中'),
|
||||||
|
@ -45,6 +46,7 @@ class WProduct(CommonAModel):
|
||||||
(WPR_ACT_STATE_INM, '已入库'),
|
(WPR_ACT_STATE_INM, '已入库'),
|
||||||
(WPR_ACT_STATE_NOTOK, '不合格'),
|
(WPR_ACT_STATE_NOTOK, '不合格'),
|
||||||
(WPR_ACT_STATE_TOFINALTEST, '待成品检验')
|
(WPR_ACT_STATE_TOFINALTEST, '待成品检验')
|
||||||
|
(WPR_ACT_STATE_SCRAP, '已报废')
|
||||||
)
|
)
|
||||||
number = models.CharField('物品编号', unique=True, null=True, blank=True, max_length=50)
|
number = models.CharField('物品编号', unique=True, null=True, blank=True, max_length=50)
|
||||||
material = models.ForeignKey(Material, verbose_name='所属物料状态', on_delete=models.CASCADE)
|
material = models.ForeignKey(Material, verbose_name='所属物料状态', on_delete=models.CASCADE)
|
||||||
|
@ -55,6 +57,7 @@ class WProduct(CommonAModel):
|
||||||
child = models.ForeignKey('self', blank=True, null=True, on_delete=models.CASCADE)
|
child = models.ForeignKey('self', blank=True, null=True, on_delete=models.CASCADE)
|
||||||
remark = models.CharField('备注', max_length=200, null=True, blank=True)
|
remark = models.CharField('备注', max_length=200, null=True, blank=True)
|
||||||
subproduction_plan = models.ForeignKey(SubProductionPlan, verbose_name='当前子生产计划', on_delete=models.CASCADE, related_name='wproduct_subplan')
|
subproduction_plan = models.ForeignKey(SubProductionPlan, verbose_name='当前子生产计划', on_delete=models.CASCADE, related_name='wproduct_subplan')
|
||||||
|
|
||||||
warehouse = models.ForeignKey(WareHouse, verbose_name='所在仓库', on_delete=models.SET_NULL, null=True, blank=True)
|
warehouse = models.ForeignKey(WareHouse, verbose_name='所在仓库', on_delete=models.SET_NULL, null=True, blank=True)
|
||||||
operation = models.ForeignKey('wpm.operation', verbose_name='当前操作',
|
operation = models.ForeignKey('wpm.operation', verbose_name='当前操作',
|
||||||
on_delete=models.SET_NULL, null=True, blank=True, related_name='wp_operation')
|
on_delete=models.SET_NULL, null=True, blank=True, related_name='wp_operation')
|
||||||
|
@ -69,40 +72,7 @@ class WProduct(CommonAModel):
|
||||||
最后提交的工序自检
|
最后提交的工序自检
|
||||||
"""
|
"""
|
||||||
return self.test_wproduct.filter(type=TestRecord.TEST_PROCESS, is_submited=True).order_by('-id').first()
|
return self.test_wproduct.filter(type=TestRecord.TEST_PROCESS, is_submited=True).order_by('-id').first()
|
||||||
|
|
||||||
# @property
|
|
||||||
# def last_test(self):
|
|
||||||
# """
|
|
||||||
# 最后提交的检验
|
|
||||||
# """
|
|
||||||
# return self.test_wproduct.filter(is_submited=True).order_by('-id').first()
|
|
||||||
|
|
||||||
# @property
|
|
||||||
# def current_test(self):
|
|
||||||
# """
|
|
||||||
# 当前未提交的检验
|
|
||||||
# """
|
|
||||||
# trs = self.test_wproduct.filter(is_submited=False).order_by('-id')
|
|
||||||
# if trs.count() == 1:
|
|
||||||
# return trs[0]
|
|
||||||
# elif trs.count() == 0:
|
|
||||||
# return None
|
|
||||||
# else:
|
|
||||||
# raise exceptions.APIException('存在多条未提交检验记录')
|
|
||||||
|
|
||||||
# @property
|
|
||||||
# def current_ticket(self):
|
|
||||||
# """
|
|
||||||
# 当前是否有进行中工单
|
|
||||||
# """
|
|
||||||
# tickets = Ticket.objects.filter(wt_ticket__wproduct=self, act_state=Ticket.TICKET_ACT_STATE_ONGOING).order_by('-id')
|
|
||||||
# if tickets.count() == 1:
|
|
||||||
# return tickets[0]
|
|
||||||
# elif tickets.count() == 0:
|
|
||||||
# return None
|
|
||||||
# else:
|
|
||||||
# raise exceptions.APIException('存在多条进行中工单')
|
|
||||||
|
|
||||||
|
|
||||||
class WprouctTicket(CommonAModel):
|
class WprouctTicket(CommonAModel):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -17,6 +17,7 @@ from apps.qm.serializers import TestRecordDetailSerializer
|
||||||
from apps.system.mixins import CreateUpdateModelAMixin, OptimizationMixin
|
from apps.system.mixins import CreateUpdateModelAMixin, OptimizationMixin
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
from apps.wf.models import Workflow
|
from apps.wf.models import Workflow
|
||||||
|
from apps.wf.serializers import WorkflowSimpleSerializer
|
||||||
from apps.wpm.filters import WMaterialFilterSet
|
from apps.wpm.filters import WMaterialFilterSet
|
||||||
from apps.wpm.models import OperationEquip, OperationWproduct, Pick, PickWproduct, WMaterial, WProduct, Operation, OperationMaterial, OperationRecord, OperationRecordItem
|
from apps.wpm.models import OperationEquip, OperationWproduct, Pick, PickWproduct, WMaterial, WProduct, Operation, OperationMaterial, OperationRecord, OperationRecordItem
|
||||||
|
|
||||||
|
@ -331,12 +332,29 @@ class WProductViewSet(ListModelMixin, GenericViewSet):
|
||||||
wproduct.save()
|
wproduct.save()
|
||||||
return Response()
|
return Response()
|
||||||
|
|
||||||
@action(methods=['get'], detail=False, perms_map={'post':'*'})
|
@action(methods=['post'], detail=True, perms_map={'post':'*'})
|
||||||
|
def scrap(self, request, pk=None):
|
||||||
|
"""
|
||||||
|
报废操作
|
||||||
|
"""
|
||||||
|
obj = self.get_object()
|
||||||
|
if obj.ow_wproduct.ow_operation.count() >4 or obj.act_state != WProduct.WPR_ACT_STATE_NOTOK:
|
||||||
|
raise exceptions.APIException('该产品不支持直接报废')
|
||||||
|
obj.act_state = WProduct.WPR_ACT_STATE_SCRAP
|
||||||
|
obj.update_by = request.user
|
||||||
|
obj.save()
|
||||||
|
return Response()
|
||||||
|
|
||||||
|
@action(methods=['get'], detail=False, perms_map={'get':'*'})
|
||||||
def workflows(self, request, pk=None):
|
def workflows(self, request, pk=None):
|
||||||
"""
|
"""
|
||||||
可发起的工作流
|
可发起的工作流
|
||||||
"""
|
"""
|
||||||
wfs = Workflow.objects.get()
|
wfs = Workflow.objects.filter(key__startswith= 'wp')
|
||||||
|
return WorkflowSimpleSerializer(instance=wfs, many=True).data
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, UpdateModelMixin, DestroyModelMixin, GenericViewSet):
|
class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, UpdateModelMixin, DestroyModelMixin, GenericViewSet):
|
||||||
"""
|
"""
|
||||||
生产操作记录
|
生产操作记录
|
||||||
|
|
Loading…
Reference in New Issue