From 88df774aefce8798d925ffc988f5d18528958d24 Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 25 Nov 2021 14:42:44 +1100 Subject: [PATCH] Add part detail filter to PartRelated serializer --- InvenTree/part/serializers.py | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/InvenTree/part/serializers.py b/InvenTree/part/serializers.py index c7c89834fb..e30b0ba4de 100644 --- a/InvenTree/part/serializers.py +++ b/InvenTree/part/serializers.py @@ -225,20 +225,6 @@ class PartBriefSerializer(InvenTreeModelSerializer): ] -class PartRelationSerializer(InvenTreeModelSerializer): - """ - Serializer for a PartRelated model - """ - - class Meta: - model = PartRelated - fields = [ - 'pk', - 'part_1', - 'part_2', - ] - - class PartSerializer(InvenTreeModelSerializer): """ Serializer for complete detail information of a part. Used when displaying all details of a single component. @@ -402,6 +388,25 @@ class PartSerializer(InvenTreeModelSerializer): ] +class PartRelationSerializer(InvenTreeModelSerializer): + """ + Serializer for a PartRelated model + """ + + part_1_detail = PartSerializer(source='part_1', read_only=True, many=False) + part_2_detail = PartSerializer(source='part_1', read_only=True, many=False) + + class Meta: + model = PartRelated + fields = [ + 'pk', + 'part_1', + 'part_1_detail', + 'part_2', + 'part_2_detail', + ] + + class PartStarSerializer(InvenTreeModelSerializer): """ Serializer for a PartStar object """