feat:物料新增set_safe接口设置安全库存上下限
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
3c0088d18f
commit
b541b46d3d
|
|
@ -80,6 +80,19 @@ class MaterialViewSet(CustomModelViewSet):
|
||||||
obj.save()
|
obj.save()
|
||||||
return Response()
|
return Response()
|
||||||
|
|
||||||
|
@action(methods=['put'], detail=True, serializer_class=Serializer, perms_map={'put': '*'})
|
||||||
|
@transaction.atomic
|
||||||
|
def set_safe(self, request, *args, **kwargs):
|
||||||
|
"""设置安全库存上下限
|
||||||
|
|
||||||
|
count_safe 为下限, count_safe_upper 为上限
|
||||||
|
"""
|
||||||
|
obj: Material = self.get_object()
|
||||||
|
obj.count_safe = request.data.get('count_safe', None)
|
||||||
|
obj.count_safe_upper = request.data.get('count_safe_upper', None)
|
||||||
|
obj.save(update_fields=['count_safe', 'count_safe_upper', 'update_time'])
|
||||||
|
return Response()
|
||||||
|
|
||||||
@action(methods=['get'], detail=False, serializer_class=Serializer, perms_map={'get': '*'})
|
@action(methods=['get'], detail=False, serializer_class=Serializer, perms_map={'get': '*'})
|
||||||
def cates(self, request, *args, **kwargs):
|
def cates(self, request, *args, **kwargs):
|
||||||
res = Material.objects.exclude(cate='').exclude(cate=None).values_list('cate', flat=True).distinct()
|
res = Material.objects.exclude(cate='').exclude(cate=None).values_list('cate', flat=True).distinct()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue