refector: 优化了do_in报错
This commit is contained in:
parent
8f90df0f32
commit
2597617a94
|
|
@ -3,7 +3,7 @@ import datetime
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.db.models import Sum
|
from django.db.models import Sum
|
||||||
from django.utils.timezone import localtime
|
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
|
from rest_framework.exceptions import ParseError
|
||||||
|
|
||||||
|
|
@ -89,7 +89,9 @@ def do_in(mio: MIO):
|
||||||
wm = WMaterial.objects.get(
|
wm = WMaterial.objects.get(
|
||||||
batch=item.batch, material=item.material, belong_dept=belong_dept)
|
batch=item.batch, material=item.material, belong_dept=belong_dept)
|
||||||
except ObjectDoesNotExist:
|
except ObjectDoesNotExist:
|
||||||
raise ParseError('车间物料不存在')
|
raise ParseError('车间物料不存在!')
|
||||||
|
except MultipleObjectsReturned:
|
||||||
|
raise ParseError('存在多行车间物料!')
|
||||||
new_count = wm.count - item.count
|
new_count = wm.count - item.count
|
||||||
if new_count > 0:
|
if new_count > 0:
|
||||||
wm.count = new_count
|
wm.count = new_count
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue