输出输出物料批量更新
This commit is contained in:
parent
30fb6749bb
commit
590059b23f
|
|
@ -6,7 +6,7 @@ from apps.mtm.models import TechDoc
|
||||||
|
|
||||||
class TechDocFilterset(filters.FilterSet):
|
class TechDocFilterset(filters.FilterSet):
|
||||||
# operation = filters.NumberFilter(method='filter_operation')
|
# operation = filters.NumberFilter(method='filter_operation')
|
||||||
operation = filters.NumberFilter(field_name="subproduction__subplan_subprod__ow_subplan__operation")
|
operation = filters.CharFilter(field_name="subproduction__subplan_subprod__ow_subplan__operation")
|
||||||
class Meta:
|
class Meta:
|
||||||
model = TechDoc
|
model = TechDoc
|
||||||
fields = ['subproduction', 'operation']
|
fields = ['subproduction', 'operation']
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ class ProductionPlan(CommonAModel):
|
||||||
order = models.ForeignKey(Order, verbose_name='关联订单', null=True, blank=True, on_delete=models.SET_NULL)
|
order = models.ForeignKey(Order, verbose_name='关联订单', null=True, blank=True, on_delete=models.SET_NULL)
|
||||||
product = models.ForeignKey(Material, verbose_name='生产产品', on_delete=models.CASCADE)
|
product = models.ForeignKey(Material, verbose_name='生产产品', on_delete=models.CASCADE)
|
||||||
count = models.IntegerField('生产数量', default=1)
|
count = models.IntegerField('生产数量', default=1)
|
||||||
|
count_real = models.IntegerField('实际产出数', default=0)
|
||||||
|
count_ok = models.IntegerField('合格数', default=0)
|
||||||
start_date = models.DateField('计划开工日期')
|
start_date = models.DateField('计划开工日期')
|
||||||
end_date = models.DateField('计划完工日期')
|
end_date = models.DateField('计划完工日期')
|
||||||
is_planed = models.BooleanField('是否已排产', default=False)
|
is_planed = models.BooleanField('是否已排产', default=False)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
from django.db.models.signals import post_save
|
from django.db.models.signals import post_save
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
|
from apps.mtm.models import Material
|
||||||
from apps.pm.models import SubProductionPlan, SubProductionProgress
|
from apps.pm.models import SubProductionPlan, SubProductionProgress
|
||||||
|
|
||||||
@receiver(post_save, sender=SubProductionProgress)
|
@receiver(post_save, sender=SubProductionProgress)
|
||||||
|
|
@ -18,6 +19,13 @@ def update_subplan_main(sender, instance, created, **kwargs):
|
||||||
subplan.state = SubProductionPlan.SUBPLAN_STATE_DONE
|
subplan.state = SubProductionPlan.SUBPLAN_STATE_DONE
|
||||||
elif instance.count_ok < instance.count and instance.count_ok > 0:
|
elif instance.count_ok < instance.count and instance.count_ok > 0:
|
||||||
subplan.state = SubProductionPlan.SUBPLAN_STATE_WORKING
|
subplan.state = SubProductionPlan.SUBPLAN_STATE_WORKING
|
||||||
subplan.save()
|
subplan.save()
|
||||||
|
if subplan.main_product.type == Material.MA_TYPE_GOOD:
|
||||||
|
# 如果是产品,更新主计划进度
|
||||||
|
plan = subplan.production_plan
|
||||||
|
plan.count_real = subplan.count_real
|
||||||
|
plan.count_ok = subplan.count_ok
|
||||||
|
plan.save()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -684,7 +684,7 @@ class OperationMaterialInputViewSet(ListModelMixin, CreateModelMixin, DestroyMod
|
||||||
"""
|
"""
|
||||||
批量创建消耗物料
|
批量创建消耗物料
|
||||||
"""
|
"""
|
||||||
serializer = OperationMaterialCreate1ListSerailizer(data=request.data, many=True)
|
serializer = OperationMaterialCreate1ListSerailizer(data=request.data)
|
||||||
serializer.is_valid(raise_exception=True)
|
serializer.is_valid(raise_exception=True)
|
||||||
serializer.save()
|
serializer.save()
|
||||||
return Response()
|
return Response()
|
||||||
|
|
@ -719,7 +719,7 @@ class OperationMaterialOutputViewSet(ListModelMixin, CreateModelMixin, DestroyMo
|
||||||
"""
|
"""
|
||||||
批量创建产出物料
|
批量创建产出物料
|
||||||
"""
|
"""
|
||||||
serializer = OperationMaterialCreate2ListSerailizer(data=request.data, many=True)
|
serializer = OperationMaterialCreate2ListSerailizer(data=request.data)
|
||||||
serializer.is_valid(raise_exception=True)
|
serializer.is_valid(raise_exception=True)
|
||||||
serializer.save()
|
serializer.save()
|
||||||
return Response()
|
return Response()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue