feat: 部分bug修复
This commit is contained in:
parent
cb45e0bab1
commit
fbb18ae990
|
@ -101,6 +101,8 @@ class MIO(CommonBDModel):
|
|||
materials = models.ManyToManyField(
|
||||
Material, verbose_name='物料明细', through='inm.mioitem', blank=True)
|
||||
|
||||
def get_a_number(self, type):
|
||||
pass
|
||||
|
||||
class MIOItem(BaseModel):
|
||||
"""
|
||||
|
|
|
@ -231,12 +231,14 @@ class RouteSerializer(CustomModelSerializer):
|
|||
process = validated_data['process']
|
||||
routepack = validated_data.get('routepack', None)
|
||||
if routepack:
|
||||
if Route.objects.filter(routepack=routepack, process=process).exists():
|
||||
raise ValidationError('已选择该工序!')
|
||||
pass
|
||||
# if Route.objects.filter(routepack=routepack, process=process).exists():
|
||||
# raise ValidationError('已选择该工序!')
|
||||
else:
|
||||
material = validated_data.get('material', None)
|
||||
if material and process and Route.objects.filter(material=material, process=process).exists():
|
||||
raise ValidationError('已选择该工序!!')
|
||||
pass
|
||||
# material = validated_data.get('material', None)
|
||||
# if material and process and Route.objects.filter(material=material, process=process).exists():
|
||||
# raise ValidationError('已选择该工序!!')
|
||||
with transaction.atomic():
|
||||
instance = super().create(validated_data)
|
||||
material_out = instance.material_out
|
||||
|
@ -246,8 +248,8 @@ class RouteSerializer(CustomModelSerializer):
|
|||
if instance.material:
|
||||
material_out.parent = instance.material
|
||||
material_out.save()
|
||||
elif material_out.process != process:
|
||||
raise ParseError('物料工序错误!请重新选择')
|
||||
# elif material_out.process != process:
|
||||
# raise ParseError('物料工序错误!请重新选择')
|
||||
else:
|
||||
if instance.material:
|
||||
self.gen_material_out(instance, validated_data.get("material_out_tracking", Material.MA_TRACKING_BATCH))
|
||||
|
@ -265,8 +267,8 @@ class RouteSerializer(CustomModelSerializer):
|
|||
if instance.material:
|
||||
material_out.parent = instance.material
|
||||
material_out.save()
|
||||
elif material_out.process != process:
|
||||
raise ParseError('物料工序错误!请重新选择')
|
||||
# elif material_out.process != process:
|
||||
# raise ParseError('物料工序错误!请重新选择')
|
||||
else:
|
||||
if instance.material:
|
||||
self.gen_material_out(instance, validated_data.get("material_out_tracking", Material.MA_TRACKING_BATCH))
|
||||
|
|
|
@ -49,10 +49,10 @@ class WMaterialFilter(filters.FilterSet):
|
|||
if mgroup:
|
||||
process = Mgroup.objects.get(id=mgroup).process
|
||||
if value == "todo":
|
||||
qs = queryset.filter(material__process=process)|queryset.filter(state=WMaterial.WM_REPAIR)
|
||||
qs = queryset.exclude(material__process=process)|queryset.filter(state=WMaterial.WM_REPAIR)
|
||||
return qs
|
||||
elif value == "done":
|
||||
qs = queryset.exclude(material__process=process)|queryset.filter(state=WMaterial.WM_REPAIRED)
|
||||
qs = queryset.filter(material__process=process)|queryset.filter(state=WMaterial.WM_REPAIRED)
|
||||
return qs
|
||||
else:
|
||||
raise ParseError("请提供工段查询条件")
|
||||
|
|
|
@ -17,9 +17,4 @@ class Migration(migrations.Migration):
|
|||
name='qct',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='qm.qct', verbose_name='所用质检表'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='mlogbdefect',
|
||||
name='count_test',
|
||||
field=models.IntegerField(blank=True, null=True, verbose_name='抽检数'),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -410,7 +410,6 @@ class Mlogb(BaseModel):
|
|||
class MlogbDefect(BaseModel):
|
||||
mlogb = models.ForeignKey(Mlogb, verbose_name='生产记录', on_delete=models.CASCADE)
|
||||
defect = models.ForeignKey("qm.Defect", verbose_name='缺陷', on_delete=models.CASCADE, null=True, blank=True)
|
||||
count_test = models.IntegerField("抽检数", null=True, blank=True)
|
||||
floor = models.IntegerField("层数", null=True, blank=True)
|
||||
count = models.PositiveIntegerField('数量', default=0)
|
||||
|
||||
|
|
|
@ -208,7 +208,7 @@ class MlogbDefectSerializer(CustomModelSerializer):
|
|||
defect_okcate = serializers.CharField(source="defect.okcate", read_only=True)
|
||||
class Meta:
|
||||
model = MlogbDefect
|
||||
fields = ["id", "defect_name", "count", "mlogb", "defect", "floor", "count_test", "defect_okcate"]
|
||||
fields = ["id", "defect_name", "count", "mlogb", "defect", "floor", "defect_okcate"]
|
||||
read_only_fields = EXCLUDE_FIELDS_BASE + ["mlogb"]
|
||||
|
||||
class MlogbSerializer(CustomModelSerializer):
|
||||
|
|
|
@ -507,7 +507,7 @@ def mlog_revert(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
|||
for item in m_ins_bl_list:
|
||||
material, batch, count, defect, mi_ = item
|
||||
if count> 0:
|
||||
lookup = {'batch': batch, 'material': material, 'mgroup': mgroup, 'defect': 'jgqbl', 'state': WMaterial.WM_NOTOK}
|
||||
lookup = {'batch': batch, 'material': material, 'mgroup': mgroup, 'defect': defect, 'state': WMaterial.WM_NOTOK}
|
||||
wm, is_create = WMaterial.objects.get_or_create(**lookup, defaults={**lookup, "belong_dept": belong_dept})
|
||||
wm.count = wm.count - count
|
||||
if wm.count < 0:
|
||||
|
|
|
@ -657,7 +657,13 @@ class FmlogViewSet(CustomModelViewSet):
|
|||
raise ParseError('因存在二级日志不可删除')
|
||||
return super().destroy(request, *args, **kwargs)
|
||||
|
||||
|
||||
@action(methods=['post'], detail=True, perms_map={'post': '*'}, serializer_class=Serializer)
|
||||
def toggle_enabled(self, request, *args, **kwargs):
|
||||
ins:Fmlog = self.get_object()
|
||||
ins.enabled = False if ins.enabled else True
|
||||
ins.save()
|
||||
return Response()
|
||||
|
||||
class BatchStViewSet(ListModelMixin, CustomGenericViewSet):
|
||||
"""
|
||||
list: 批次统计数据
|
||||
|
|
Loading…
Reference in New Issue