From d815d84333b462857ff5d53cda5082e3d0cbc510 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 24 Apr 2025 16:00:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=8C=E5=96=84=E8=B4=9F=E6=95=B0?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wpm/serializers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/wpm/serializers.py b/apps/wpm/serializers.py index d5997d15..5ad0373a 100644 --- a/apps/wpm/serializers.py +++ b/apps/wpm/serializers.py @@ -680,7 +680,7 @@ class MlogbInSerializer(CustomModelSerializer): 'wm_in': {'required': True, "allow_empty": False}} def validate(self, attrs): - if attrs["count_use"] < 0 or attrs["count_pn_jgqbl"] < 0 or attrs["count_break"] < 0: + if attrs["count_use"] < 0 or attrs.get("count_pn_jgqbl", 0) < 0 or attrs["count_break"] < 0: raise ParseError('存在负数!') mlog:Mlog = attrs['mlog'] is_fix = mlog.is_fix @@ -747,7 +747,7 @@ class MlogbInUpdateSerializer(CustomModelSerializer): fields = ['id', 'count_use', 'count_pn_jgqbl', 'note', 'mlogbdefect'] def validate(self, attrs): - if attrs["count_use"] < 0 or attrs["count_pn_jgqbl"] < 0: + if attrs["count_use"] < 0 or attrs.get("count_pn_jgqbl", 0) < 0: raise ParseError('存在负数!') return attrs def update(self, instance, validated_data):