生成半成品编号

This commit is contained in:
caoqianming 2021-11-16 13:30:16 +08:00
parent cde0f2b169
commit fd5f2e5eb2
2 changed files with 6 additions and 4 deletions

View File

@ -171,7 +171,7 @@ class SubProductionPlanViewSet(CreateUpdateModelAMixin, ListModelMixin, UpdateMo
materials = []
for i in need:
materials.append(i['material'])
objs = MaterialBatch.objects.filter(material__id__in=materials)
objs = MaterialBatch.objects.filter(material__id__in=materials).order_by('material__number')
have = MaterialBatchSerializer(instance=objs, many=True).data
return Response({'need':need, 'have':have})

View File

@ -201,7 +201,7 @@ class WProductViewSet(ListModelMixin, GenericViewSet):
if 'is_testok' not in vdata:
raise exceptions.APIException('未填写检测结论')
obj = serializer.save(create_by = self.request.user, m_state=vdata['wproduct'].m_state)
obj = serializer.save(create_by = self.request.user, m_state=wproduct.m_state)
tris = []
for m in record_data: # 保存记录详情
form_field = m['form_field']
@ -219,8 +219,10 @@ class WProductViewSet(ListModelMixin, GenericViewSet):
# 如果检测合格, 变更动态产品进行状态
if obj.is_testok:
vdata['wproduct'].act_state = WProduct.WPR_ACT_STATE_OK
vdata['wproduct'].save()
wproduct.act_state = WProduct.WPR_ACT_STATE_OK
if wproduct.number is None: # 产生半成品编号
wproduct.number = 'BCP' + str(timezone.now())
wproduct.save()
# 更新子计划状态
# 获取该子计划主产品数, 更新进度
main_count = WProduct.objects.filter(subproduction_plan=wproduct.subproduction_plan, act_stae=WProduct.WPR_ACT_STATE_OK).count()