Add 'bom_items' and 'used_in' to Part detail API

This commit is contained in:
Oliver Walters 2020-04-05 15:39:55 +10:00
parent b4d66c6797
commit 1f172b3a57

View File

@ -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',