From 2597617a9497e510d61333eca25d37a38e177219 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 28 Sep 2023 10:18:44 +0800 Subject: [PATCH] =?UTF-8?q?refector:=20=E4=BC=98=E5=8C=96=E4=BA=86do=5Fin?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wpm/services.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/wpm/services.py b/apps/wpm/services.py index 7db7bd48..cc049717 100644 --- a/apps/wpm/services.py +++ b/apps/wpm/services.py @@ -3,7 +3,7 @@ import datetime from django.core.cache import cache from django.db.models import Sum from django.utils.timezone import localtime -from django.core.exceptions import ObjectDoesNotExist +from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned from rest_framework.exceptions import ParseError @@ -89,7 +89,9 @@ def do_in(mio: MIO): wm = WMaterial.objects.get( batch=item.batch, material=item.material, belong_dept=belong_dept) except ObjectDoesNotExist: - raise ParseError('车间物料不存在') + raise ParseError('车间物料不存在!') + except MultipleObjectsReturned: + raise ParseError('存在多行车间物料!') new_count = wm.count - item.count if new_count > 0: wm.count = new_count