From 76adab157168b08f3d67894eea83593b8d49360d Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 28 Apr 2025 11:08:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=89=B9=E6=AC=A1=E8=BF=BD=E8=B8=AA?= =?UTF-8?q?=E9=93=BE=E6=9D=A1=E8=BF=98=E6=98=AF=E5=8F=AF=E4=BB=A5=E5=A4=8D?= =?UTF-8?q?=E7=94=A8=E6=89=B9=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wpm/models.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/wpm/models.py b/apps/wpm/models.py index 31337a0f..6491731b 100644 --- a/apps/wpm/models.py +++ b/apps/wpm/models.py @@ -633,6 +633,8 @@ class BatchSt(BaseModel): return node, False else: version = 1 + if mio is None and handover is None and mlog is None: + raise ParseError("mio or handover or mlog must be provided") # 带有来源的批次获取,需检查批次号是否可用 if cls.objects.filter(batch=batch).exists(): if reuse_node: @@ -641,11 +643,8 @@ class BatchSt(BaseModel): raise ParseError(f"{batch}-该批次号因物料不同不可引用") return node, False else: - raise ParseError(f"{batch}-该批次号不可使用") - # latest_version = BatchSt.objects.filter(batch=batch).aggregate(Max("version"))["version__max"] - # version = latest_version + 1 - if mio is None and handover is None and mlog is None: - raise ParseError("mio or handover or mlog must be provided") + latest_version = BatchSt.objects.filter(batch=batch).aggregate(Max("version"))["version__max"] + version = latest_version + 1 ins = cls.objects.create(batch=batch, mio=mio, handover=handover, mlog=mlog, material_start=material_start, version=version) return ins, True