From d3f999d2c8b8929c9c84af7fc58079f943ece5ac Mon Sep 17 00:00:00 2001 From: caoqianming Date: Wed, 16 Mar 2022 16:11:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B6=E4=BB=96=E5=87=BA=E5=BA=93=E4=B8=8D?= =?UTF-8?q?=E5=8F=AF=E6=93=8D=E4=BD=9C=E6=88=90=E5=93=81=E6=88=96=E5=8D=8A?= =?UTF-8?q?=E6=88=90=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/inm/serializers.py | 3 +++ hb_server/apps/inm/views.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/hb_server/apps/inm/serializers.py b/hb_server/apps/inm/serializers.py index 357084d..c5df25b 100644 --- a/hb_server/apps/inm/serializers.py +++ b/hb_server/apps/inm/serializers.py @@ -2,6 +2,7 @@ from rest_framework import exceptions from rest_framework import serializers from apps.inm.models import FIFO, FIFOItem, FIFOItemProduct, IProduct, MaterialBatch, WareHouse, Inventory +from apps.mtm.models import Material from apps.pum.models import PuOrder, Vendor from apps.qm.models import TestRecord, TestRecordItem from apps.sam.serializers import OrderSimpleSerializer @@ -173,6 +174,8 @@ class FIFOOutOtherSerializer(serializers.ModelSerializer): obj.save() for i in details: mb = i.pop('material_batch') + if mb.material.type in [Material.MA_TYPE_GOOD, Material.MA_TYPE_HALFGOOD]: + raise ValidationError('不可直接出成品或半成品') i['material'] = mb.material i['batch'] = mb.batch i['warehouse'] = mb.warehouse diff --git a/hb_server/apps/inm/views.py b/hb_server/apps/inm/views.py index fcc454f..c528834 100644 --- a/hb_server/apps/inm/views.py +++ b/hb_server/apps/inm/views.py @@ -163,6 +163,7 @@ class FIFOViewSet(ListModelMixin, DestroyModelMixin, GenericViewSet): return super().destroy(request, *args, **kwargs) @action(methods=['post'], detail=False, perms_map={'post': 'fifo_in_pur'}, serializer_class=FIFOInPurSerializer) + @transaction.atomic() def in_pur(self, request, pk=None): """ 采购入库 @@ -174,6 +175,7 @@ class FIFOViewSet(ListModelMixin, DestroyModelMixin, GenericViewSet): @action(methods=['post'], detail=False, perms_map={'post': 'fifo_in_other'}, serializer_class=FIFOInOtherSerializer) + @transaction.atomic() def in_other(self, request, pk=None): """ 其他入库 @@ -185,6 +187,7 @@ class FIFOViewSet(ListModelMixin, DestroyModelMixin, GenericViewSet): @action(methods=['post'], detail=False, perms_map={'post': 'fifo_out_other'}, serializer_class=FIFOOutOtherSerializer) + @transaction.atomic() def out_other(self, request, pk=None): """ 其他出库