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