fix: batchst create bug

This commit is contained in:
caoqianming 2025-03-21 17:54:50 +08:00
parent 9780cd8021
commit f57604492b
1 changed files with 5 additions and 7 deletions

View File

@ -589,13 +589,11 @@ class BatchSt(BaseModel):
"""
创建新的批次
"""
try:
BatchSt.objects.get(batch=batch)
raise ParseError(f"{batch} 该批号不可使用")
except BatchSt.DoesNotExist:
if mio is None and handover is None and mlog is None:
raise ParseError("mio or handover or mlog must be provided")
BatchSt.objects.create(batch=batch, mio=mio, handover=handover, mlog=mlog)
if BatchSt.objects.filter(batch=batch).exists():
raise ParseError(f"{batch} 该批号已存在不可用")
if mio is None and handover is None and mlog is None:
raise ParseError("mio or handover or mlog must be provided")
BatchSt.objects.create(batch=batch, mio=mio, handover=handover, mlog=mlog)