feat: 半成品检验有关库存消耗完的逻辑处理
This commit is contained in:
parent
29f085253c
commit
c6222c65f6
|
@ -254,6 +254,7 @@ class MIOItemViewSet(ListModelMixin, BulkCreateModelMixin, BulkDestroyModelMixin
|
||||||
batch = ins.batch
|
batch = ins.batch
|
||||||
material = ins.material
|
material = ins.material
|
||||||
warehouse = ins.warehouse
|
warehouse = ins.warehouse
|
||||||
|
try:
|
||||||
mb = MaterialBatch.objects.get(
|
mb = MaterialBatch.objects.get(
|
||||||
material=material, batch=batch, warehouse=warehouse)
|
material=material, batch=batch, warehouse=warehouse)
|
||||||
count_new = mb.count - count_notok
|
count_new = mb.count - count_notok
|
||||||
|
@ -261,6 +262,10 @@ class MIOItemViewSet(ListModelMixin, BulkCreateModelMixin, BulkDestroyModelMixin
|
||||||
raise ParseError('库存扣减失败,请确认!')
|
raise ParseError('库存扣减失败,请确认!')
|
||||||
mb.count = count_new
|
mb.count = count_new
|
||||||
mb.save()
|
mb.save()
|
||||||
|
except MaterialBatch.DoesNotExist:
|
||||||
|
# 库存不存在已被消耗了
|
||||||
|
if count_notok != 0:
|
||||||
|
raise ParseError('库存已全消耗!')
|
||||||
return Response()
|
return Response()
|
||||||
|
|
||||||
@action(methods=['post'], detail=True, perms_map={'post': 'mioitem.test'}, serializer_class=MIOItemPurInTestSerializer)
|
@action(methods=['post'], detail=True, perms_map={'post': 'mioitem.test'}, serializer_class=MIOItemPurInTestSerializer)
|
||||||
|
|
Loading…
Reference in New Issue