fix: handoverb validate错误

This commit is contained in:
caoqianming 2024-09-05 15:13:50 +08:00
parent beb6b79709
commit 4b44b40c77
1 changed files with 2 additions and 1 deletions

View File

@ -582,6 +582,7 @@ class HandoverSerializer(CustomModelSerializer):
if wm: if wm:
material = wm.material material = wm.material
attrs['handoverb'] = [{"wm": wm, "count": attrs["count"] }] attrs['handoverb'] = [{"wm": wm, "count": attrs["count"] }]
handoverb = attrs['handoverb']
elif handoverb: elif handoverb:
wm: WMaterial = handoverb[0]["wm"] wm: WMaterial = handoverb[0]["wm"]
else: else:
@ -600,7 +601,7 @@ class HandoverSerializer(CustomModelSerializer):
if 'send_dept' not in attrs and 'send_mgroup' not in attrs: if 'send_dept' not in attrs and 'send_mgroup' not in attrs:
raise ValidationError('送料车间和送料工段必须有一个') raise ValidationError('送料车间和送料工段必须有一个')
t_count = 0 t_count = 0
for ind, item in enumerate(handoverb): for ind, item in enumerate(attrs['handoverb']):
wm = item["wm"] wm = item["wm"]
t_count += item["count"] t_count += item["count"]
if attrs["material"] != wm.material: if attrs["material"] != wm.material: