From 4fe19e3a6af437f01aa78f773f3f3d351887d2fe Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 6 Dec 2021 10:20:33 +0800 Subject: [PATCH] =?UTF-8?q?sale=20=E4=BA=8B=E5=8A=A1=E6=80=A7=E5=88=9B?= =?UTF-8?q?=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/sam/serializers.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hb_server/apps/sam/serializers.py b/hb_server/apps/sam/serializers.py index 320ceed..b28a913 100644 --- a/hb_server/apps/sam/serializers.py +++ b/hb_server/apps/sam/serializers.py @@ -1,3 +1,4 @@ +from django.db import transaction from rest_framework import serializers from apps.inm.models import IProduct @@ -71,6 +72,7 @@ class SaleCreateSerializer(serializers.ModelSerializer): attrs['product'] = order.product return super().validate(attrs) + @transaction.atomic def create(self, validated_data): iproducts = validated_data.pop('iproducts') sale = Sale.objects.create(**validated_data)