feat: materialbatch也不进行物理删除
This commit is contained in:
parent
592e34c07e
commit
561c2a0c31
|
@ -87,7 +87,10 @@ class InmService:
|
||||||
material = i.material
|
material = i.material
|
||||||
warehouse = i.warehouse
|
warehouse = i.warehouse
|
||||||
mb, is_created = MaterialBatch.objects.get_or_create(
|
mb, is_created = MaterialBatch.objects.get_or_create(
|
||||||
material=material, warehouse=warehouse, batch=i.batch, defaults={"material": material, "warehouse": warehouse, "count": 0, "batch": i.batch}
|
material=material,
|
||||||
|
warehouse=warehouse,
|
||||||
|
batch=i.batch,
|
||||||
|
defaults={"material": material, "warehouse": warehouse, "count": 0, "batch": i.batch}
|
||||||
)
|
)
|
||||||
if in_or_out == 1:
|
if in_or_out == 1:
|
||||||
mb.count = mb.count + getattr(i, field)
|
mb.count = mb.count + getattr(i, field)
|
||||||
|
@ -107,8 +110,6 @@ class InmService:
|
||||||
mb.count = mb.count - getattr(i, field)
|
mb.count = mb.count - getattr(i, field)
|
||||||
if mb.count < 0:
|
if mb.count < 0:
|
||||||
raise ParseError("批次库存不足,操作失败")
|
raise ParseError("批次库存不足,操作失败")
|
||||||
elif mb.count == 0:
|
|
||||||
mb.delete()
|
|
||||||
else:
|
else:
|
||||||
mb.save()
|
mb.save()
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -45,7 +45,7 @@ class MaterialBatchViewSet(ListModelMixin, CustomGenericViewSet):
|
||||||
物料批次
|
物料批次
|
||||||
"""
|
"""
|
||||||
perms_map = {'get': '*'}
|
perms_map = {'get': '*'}
|
||||||
queryset = MaterialBatch.objects.all()
|
queryset = MaterialBatch.objects.filter(count__gt=0)
|
||||||
serializer_class = MaterialBatchSerializer
|
serializer_class = MaterialBatchSerializer
|
||||||
retrieve_serializer_class = MaterialBatchDetailSerializer
|
retrieve_serializer_class = MaterialBatchDetailSerializer
|
||||||
select_related_fields = ['warehouse', 'material']
|
select_related_fields = ['warehouse', 'material']
|
||||||
|
|
Loading…
Reference in New Issue