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