feat: SPLIT_FIELD 改为 #

This commit is contained in:
caoqianming 2024-10-29 14:50:19 +08:00
parent 8d6939a4fc
commit cdcfbf35ef
1 changed files with 4 additions and 3 deletions

View File

@ -8,6 +8,7 @@ from rest_framework.response import Response
from apps.utils.viewsets import CustomGenericViewSet, RetrieveModelMixin, CustomListModelMixin from apps.utils.viewsets import CustomGenericViewSet, RetrieveModelMixin, CustomListModelMixin
# Create your views here. # Create your views here.
SPLIT_FIELD = "#"
class LableMatViewSet(CustomListModelMixin, RetrieveModelMixin, CustomGenericViewSet): class LableMatViewSet(CustomListModelMixin, RetrieveModelMixin, CustomGenericViewSet):
perms_map = {"post": "*", "get": "*"} perms_map = {"post": "*", "get": "*"}
@ -29,7 +30,7 @@ class LableMatViewSet(CustomListModelMixin, RetrieveModelMixin, CustomGenericVie
raise NotFound("仓库明细不存在") raise NotFound("仓库明细不存在")
obj, _ = LableMat.objects.get_or_create(state=10, material=mb.material, batch=mb.batch, defaults={"supplier": mb.supplier}) obj, _ = LableMat.objects.get_or_create(state=10, material=mb.material, batch=mb.batch, defaults={"supplier": mb.supplier})
rdata = LabelMatSerializer(obj).data rdata = LabelMatSerializer(obj).data
rdata["code_label"] = f"mat:{obj.id}" rdata["code_label"] = f"mat{SPLIT_FIELD}{obj.id}"
return Response(rdata) return Response(rdata)
@action(methods=["post"], detail=False, serializer_class=TidSerializer) @action(methods=["post"], detail=False, serializer_class=TidSerializer)
@ -46,7 +47,7 @@ class LableMatViewSet(CustomListModelMixin, RetrieveModelMixin, CustomGenericVie
raise NotFound("车间库存不存在") raise NotFound("车间库存不存在")
obj, _ = LableMat.objects.get_or_create(state=wm.state, material=wm.material, batch=wm.batch, notok_sign=wm.notok_sign, material_origin=wm.material_origin) obj, _ = LableMat.objects.get_or_create(state=wm.state, material=wm.material, batch=wm.batch, notok_sign=wm.notok_sign, material_origin=wm.material_origin)
rdata = LabelMatSerializer(obj).data rdata = LabelMatSerializer(obj).data
rdata["code_label"] = f"mat:{obj.id}" rdata["code_label"] = f"mat{SPLIT_FIELD}{obj.id}"
return Response(rdata) return Response(rdata)
@action(methods=["post"], detail=False, serializer_class=TidSerializer) @action(methods=["post"], detail=False, serializer_class=TidSerializer)
@ -63,5 +64,5 @@ class LableMatViewSet(CustomListModelMixin, RetrieveModelMixin, CustomGenericVie
raise NotFound("出入库明细不存在") raise NotFound("出入库明细不存在")
obj, _ = LableMat.objects.get_or_create(state=10, material=mioitem.material, batch=mioitem.batch, defaults={"supplier": mioitem.mio.supplier}) obj, _ = LableMat.objects.get_or_create(state=10, material=mioitem.material, batch=mioitem.batch, defaults={"supplier": mioitem.mio.supplier})
rdata = LabelMatSerializer(obj).data rdata = LabelMatSerializer(obj).data
rdata["code_label"] = f"mat:{obj.id}" rdata["code_label"] = f"mat{SPLIT_FIELD}{obj.id}"
return Response(rdata) return Response(rdata)