From 1f172b3a57f14da275a5ae3d6dac3ebd356fd348 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 5 Apr 2020 15:39:55 +1000 Subject: [PATCH] Add 'bom_items' and 'used_in' to Part detail API --- InvenTree/part/serializers.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/InvenTree/part/serializers.py b/InvenTree/part/serializers.py index fe7483b399..3183a7caf9 100644 --- a/InvenTree/part/serializers.py +++ b/InvenTree/part/serializers.py @@ -78,16 +78,15 @@ class PartSerializer(InvenTreeModelSerializer): Used when displaying all details of a single component. """ - url = serializers.CharField(source='get_absolute_url', read_only=True) - image = serializers.CharField(source='get_image_url', read_only=True) - thumbnail = serializers.CharField(source='get_thumbnail_url', read_only=True) - category_name = serializers.CharField(source='category_path', read_only=True) - allocated_stock = serializers.FloatField(source='allocation_count', read_only=True) - - on_order = serializers.FloatField(read_only=True) - + bom_items = serializers.IntegerField(source='bom_count', read_only=True) building = serializers.FloatField(source='quantity_being_built', read_only=False) + category_name = serializers.CharField(source='category_path', read_only=True) + image = serializers.CharField(source='get_image_url', read_only=True) + on_order = serializers.FloatField(read_only=True) + thumbnail = serializers.CharField(source='get_thumbnail_url', read_only=True) + url = serializers.CharField(source='get_absolute_url', read_only=True) + used_in = serializers.IntegerField(source='used_in_count', read_only=True) @staticmethod def setup_eager_loading(queryset): @@ -103,6 +102,7 @@ class PartSerializer(InvenTreeModelSerializer): fields = [ 'pk', 'url', # Link to the part detail page + 'bom_items', 'category', 'category_name', 'image', @@ -120,6 +120,7 @@ class PartSerializer(InvenTreeModelSerializer): 'on_order', 'building', 'units', + 'used_in', 'trackable', 'assembly', 'component',