fix: mioitem create时校验是否混批的bug

This commit is contained in:
caoqianming 2025-11-10 14:43:12 +08:00
parent 32b39ee423
commit 2d81424009
1 changed files with 12 additions and 5 deletions

View File

@ -212,11 +212,18 @@ class MIOItemCreateSerializer(CustomModelSerializer):
mio_type = mio.type mio_type = mio.type
if mio_type != "pur_in" and mio_type != "other_in": if mio_type != "pur_in" and mio_type != "other_in":
wprIds = [i["wpr"].id for i in mioitemw] wprIds = [i["wpr"].id for i in mioitemw]
mb_ids = list(Wpr.objects.filter(id__in=wprIds).values_list("mb__id", flat=True).distinct()) if instance.mb:
if len(mb_ids) == 1 and mb_ids[0] == instance.mb.id: mb_ids = list(Wpr.objects.filter(id__in=wprIds).values_list("mb__id", flat=True).distinct())
pass if len(mb_ids) == 1 and mb_ids[0] == instance.mb.id:
else: pass
raise ParseError(f'{batch}物料明细中存在{len(mb_ids)}个不同物料批次') else:
raise ParseError(f'{batch}物料明细中存在{len(mb_ids)}个不同物料批次')
elif instance.wm:
wm_ids = list(Wpr.objects.filter(id__in=wprIds).values_list("wm__id", flat=True).distinct())
if len(wm_ids) == 1 and wm_ids[0] == instance.wm.id:
pass
else:
raise ParseError(f'{batch}物料明细中存在{len(wm_ids)}个不同物料批次')
for item in mioitemw: for item in mioitemw:
if item.get("wpr", None) is None and mio_type != "pur_in" and mio_type != "other_in": if item.get("wpr", None) is None and mio_type != "pur_in" and mio_type != "other_in":
raise ParseError(f'{item["number"]}_请提供产品明细ID') raise ParseError(f'{item["number"]}_请提供产品明细ID')