From ad1d0680b116b75f089899634ba1774f8cdeb443 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 13 Aug 2024 15:06:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20mlogbupdate=20=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 | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/wpm/serializers.py b/apps/wpm/serializers.py index 089fff16..faee3cfb 100644 --- a/apps/wpm/serializers.py +++ b/apps/wpm/serializers.py @@ -417,9 +417,20 @@ class MlogbInUpdateSerializer(CustomModelSerializer): class MlogbOutUpdateSerializer(CustomModelSerializer): class Meta: model = Mlogb - fields = ['id', 'batch', 'count_real', 'count_ok', 'count_notok', - 'count_n_hs', 'count_n_qp', 'count_n_swen', 'count_n_bb', - 'count_n_wm', 'count_n_md', 'count_n_xh'] + fields = "__all__" + read_only_fields = EXCLUDE_FIELDS_BASE + ['mlog', 'mtask', 'wm_in', 'material_in', 'material_out', 'count_use', 'count_break'] + + def validate(self, attrs): + count_notok = 0 + for i in attrs: + if 'count_n_' in i: + count_notok = count_notok + attrs[i] + attrs['count_notok'] = count_notok + if attrs['count_real'] >= attrs['count_ok'] + attrs['count_notok']: + pass + else: + raise ValidationError('生产数量不能小于合格数量') + return attrs class MlogRevertSerializer(serializers.Serializer): change_reason = serializers.CharField(label='撤回原因')