feat: 隐式物料不可出入库

This commit is contained in:
caoqianming 2025-01-15 17:13:28 +08:00
parent a7b14994b7
commit 923ac2276c
1 changed files with 4 additions and 2 deletions

View File

@ -128,16 +128,18 @@ class MIOItemCreateSerializer(CustomModelSerializer):
material: Material = validated_data['material']
batch = validated_data['batch']
if material.is_hidden:
raise ParseError('隐式物料不可出入库')
if mio.state != MIO.MIO_CREATE:
raise ValidationError('出入库记录非创建中不可新增')
raise ParseError('出入库记录非创建中不可新增')
# 生产领料要校验是否进行检验
# 某些客户此处无需校验
check_test_when_do_out = get_sysconfig('mes.check_test_when_do_out', True)
if check_test_when_do_out and mio.type == MIO.MIO_TYPE_DO_OUT:
mis = MIOItem.objects.filter(batch=batch, material=material, mio__type__in=[MIO.MIO_TYPE_PUR_IN, MIO.MIO_TYPE_DO_IN, MIO.MIO_TYPE_OTHER_IN])
if mis.exists() and (not mis.exclude(test_date=None).exists()):
raise ValidationError('该批次的物料未经检验')
raise ParseError('该批次的物料未经检验')
with transaction.atomic():
count = validated_data["count"]
batch = validated_data["batch"]