From cdcfbf35ef9f5383b6c6d5f74949a30d8c7eead8 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 29 Oct 2024 14:50:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20SPLIT=5FFIELD=20=E6=94=B9=E4=B8=BA=20#?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/cm/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/cm/views.py b/apps/cm/views.py index f05b6a4c..30b3e0ed 100644 --- a/apps/cm/views.py +++ b/apps/cm/views.py @@ -8,6 +8,7 @@ from rest_framework.response import Response from apps.utils.viewsets import CustomGenericViewSet, RetrieveModelMixin, CustomListModelMixin # Create your views here. +SPLIT_FIELD = "#" class LableMatViewSet(CustomListModelMixin, RetrieveModelMixin, CustomGenericViewSet): perms_map = {"post": "*", "get": "*"} @@ -29,7 +30,7 @@ class LableMatViewSet(CustomListModelMixin, RetrieveModelMixin, CustomGenericVie raise NotFound("仓库明细不存在") obj, _ = LableMat.objects.get_or_create(state=10, material=mb.material, batch=mb.batch, defaults={"supplier": mb.supplier}) rdata = LabelMatSerializer(obj).data - rdata["code_label"] = f"mat:{obj.id}" + rdata["code_label"] = f"mat{SPLIT_FIELD}{obj.id}" return Response(rdata) @action(methods=["post"], detail=False, serializer_class=TidSerializer) @@ -46,7 +47,7 @@ class LableMatViewSet(CustomListModelMixin, RetrieveModelMixin, CustomGenericVie 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) rdata = LabelMatSerializer(obj).data - rdata["code_label"] = f"mat:{obj.id}" + rdata["code_label"] = f"mat{SPLIT_FIELD}{obj.id}" return Response(rdata) @action(methods=["post"], detail=False, serializer_class=TidSerializer) @@ -63,5 +64,5 @@ class LableMatViewSet(CustomListModelMixin, RetrieveModelMixin, CustomGenericVie raise NotFound("出入库明细不存在") obj, _ = LableMat.objects.get_or_create(state=10, material=mioitem.material, batch=mioitem.batch, defaults={"supplier": mioitem.mio.supplier}) rdata = LabelMatSerializer(obj).data - rdata["code_label"] = f"mat:{obj.id}" + rdata["code_label"] = f"mat{SPLIT_FIELD}{obj.id}" return Response(rdata)