diff --git a/apps/wpm/serializers.py b/apps/wpm/serializers.py index c654ee8e..4b5ab5ff 100644 --- a/apps/wpm/serializers.py +++ b/apps/wpm/serializers.py @@ -951,9 +951,19 @@ class HandoverSerializer(CustomModelSerializer): if 'send_dept' not in attrs and 'send_mgroup' not in attrs: raise ParseError('送料车间和送料工段必须有一个') t_count = 0 + tracking = attrs["material"].tracking for ind, item in enumerate(attrs['handoverb']): wm = item["wm"] - t_count += item["count"] + if tracking == Material.MA_TRACKING_SINGLE: + handoverbw = item["handoverbw"] + if handoverbw: + t_count += len(handoverbw) + elif wm.count == item["count"]: + t_count += item["count"] + else: + raise ParseError(f'第{ind+1}行-请提供交接物料明细编号') + else: + t_count += item["count"] # if wm.mgroup and wm.mgroup != attrs['send_mgroup']: # raise ParseError(f'第{ind+1}物料与交接工段不一致') # if wm.belong_dept and wm.belong_dept != attrs['send_dept']: @@ -970,9 +980,6 @@ class HandoverSerializer(CustomModelSerializer): recive_mgroup = attrs.get("recive_mgroup", None) if recive_mgroup is None: raise ParseError('返工交接需指定工段') - material:Material = attrs["material"] - if material.tracking == Material.MA_TRACKING_SINGLE: - attrs["count"] = len(attrs["handoverb"]) return attrs class Meta: