车间物料大于0的
This commit is contained in:
parent
a4c37d5255
commit
06d0021808
|
@ -13,8 +13,10 @@ def update_subplan_main(sender, instance, created, **kwargs):
|
|||
subplan.main_product = instance.material
|
||||
subplan.main_count = instance.count
|
||||
subplan.main_count_real = instance.count_real
|
||||
if instance.count_real>= instance.count and instance.count_real != 0:
|
||||
if instance.count_ok >= instance.count and instance.count_ok > 0:
|
||||
subplan.state = SubProductionPlan.SUBPLAN_STATE_DONE
|
||||
elif instance.count_ok < instance.count and instance.count_ok > 0:
|
||||
subplan.state = SubProductionPlan.SUBPLAN_STATE_WORKING
|
||||
subplan.save()
|
||||
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ class SubProductionPlanViewSet(CreateUpdateModelAMixin, ListModelMixin, UpdateMo
|
|||
materials = []
|
||||
for i in need:
|
||||
materials.append(i['material'])
|
||||
objs = MaterialBatch.objects.filter(material__id__in=materials).order_by('material__number')
|
||||
objs = MaterialBatch.objects.filter(material__id__in=materials, count_gt=0).order_by('material__number')
|
||||
have = MaterialBatchSerializer(instance=objs, many=True).data
|
||||
return Response({'need':need, 'have':have})
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
# Generated by Django 3.2.9 on 2021-11-23 15:10
|
||||
|
||||
import django.core.validators
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('wpm', '0022_auto_20211123_1425'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='operationmaterial',
|
||||
name='count',
|
||||
field=models.IntegerField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(0)], verbose_name='消耗或产出数量'),
|
||||
),
|
||||
]
|
|
@ -75,7 +75,7 @@ class OperationMaterial(BaseModel):
|
|||
operation = models.ForeignKey(Operation, verbose_name='关联的生产操作', on_delete=models.CASCADE)
|
||||
|
||||
material = models.ForeignKey(Material, verbose_name='可能产出的产品', on_delete=models.CASCADE, null=True, blank=True)
|
||||
count = models.IntegerField('消耗或产出数量', validators=[MinValueValidator(0)])
|
||||
count = models.IntegerField('消耗或产出数量', validators=[MinValueValidator(0)], null=True, blank=True)
|
||||
|
||||
wmaterial = models.ForeignKey(WMaterial, verbose_name='关联的车间物料', on_delete=models.CASCADE, null=True, blank=True)
|
||||
subproduction_progress = models.ForeignKey(SubProductionProgress, verbose_name='关联的生产进度', on_delete=models.CASCADE, null=True, blank=True)
|
||||
|
|
|
@ -117,6 +117,7 @@ class WMaterialListSerializer(serializers.ModelSerializer):
|
|||
车间物料
|
||||
"""
|
||||
material_ = MaterialSimpleSerializer(source='material', read_only=True)
|
||||
subproduction_plan_ = SubproductionPlanSimpleSerializer(source='subproduction_plan', read_only=True)
|
||||
class Meta:
|
||||
model = WMaterial
|
||||
fields = '__all__'
|
||||
|
|
|
@ -63,13 +63,15 @@ class WPlanViewSet(ListModelMixin, GenericViewSet):
|
|||
if 'wproducts' in i and len(i['wproducts'])>0:
|
||||
spp = SubProductionProgress.objects.get(pk=i['id'])
|
||||
spp.count_pick = spp.count_pick + len(i['wproducts'])
|
||||
if spp.count_pick > spp.count:
|
||||
raise exceptions.APIException('超过计划数')
|
||||
# if spp.count_pick > spp.count:
|
||||
# raise exceptions.APIException('超过计划数')
|
||||
spp.save()
|
||||
wps = WProduct.objects.filter(pk__in=[x for x in i['wproducts']])
|
||||
wps.update(step=first_step, is_executed=False,
|
||||
act_state=WProduct.WPR_ACT_STATE_DOING, is_hidden=False, warehouse=None,
|
||||
subproduction_plan=sp, update_by=request.user, update_time=timezone.now())
|
||||
sp.is_picked = True
|
||||
sp.save()
|
||||
return Response()
|
||||
|
||||
|
||||
|
@ -137,7 +139,7 @@ class WMaterialViewSet(CreateUpdateModelAMixin, ListModelMixin, GenericViewSet):
|
|||
车间物料表
|
||||
"""
|
||||
perms_map={'*':'*'}
|
||||
queryset = WMaterial.objects.select_related('material').all()
|
||||
queryset = WMaterial.objects.select_related('material', 'subproduction_plan').filter(count_gt=0)
|
||||
serializer_class = WMaterialListSerializer
|
||||
filterset_class = WMaterialFilterSet
|
||||
ordering_fields = ['material__number']
|
||||
|
@ -313,6 +315,7 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd
|
|||
# 创建操作所用半成品关联记录
|
||||
if 'wproducts' in vdata:
|
||||
owps = []
|
||||
WProduct.objects.filter(pk__in=[x.id for x in vdata['wproducts']]).update(operation=op)
|
||||
splans = WpmServies.get_subplans_queryset_from_wproducts(vdata['wproducts'])
|
||||
for wpd in vdata['wproducts']:
|
||||
owp = {}
|
||||
|
|
Loading…
Reference in New Issue