diff --git a/apps/wpm/models.py b/apps/wpm/models.py index ffeba063..4574fddd 100644 --- a/apps/wpm/models.py +++ b/apps/wpm/models.py @@ -641,10 +641,10 @@ class BatchSt(BaseModel): 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(): + cls_qs = cls.objects.filter(batch=batch) + if cls_qs.exists(): if reuse_node: - cls = cls.objects.filter(batch=batch) - node:BatchSt = (cls.objects.filter(mio__isnull=False)|cls.objects.filter( + node:BatchSt = (cls_qs.filter(mio__isnull=False)|cls_qs.filter( material_start__isnull=True)).order_by('-version').first() if node is None: raise ParseError(f"{batch}-该批次号因物料不同不可引用")