mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-30 20:55:42 +00:00 
			
		
		
		
	| @@ -243,6 +243,12 @@ class PartList(generics.ListCreateAPIView): | |||||||
|             else: |             else: | ||||||
|                 item['category__name'] = None |                 item['category__name'] = None | ||||||
|  |  | ||||||
|  |             # Rename "URL" to "link" to distinguish from lower-case "url", | ||||||
|  |             # which is the web address of the item itself | ||||||
|  |             if 'URL' in item.keys(): | ||||||
|  |                 item['link'] = item['URL'] | ||||||
|  |                 del item['URL'] | ||||||
|  |  | ||||||
|         return Response(data) |         return Response(data) | ||||||
|  |  | ||||||
|     def get_queryset(self): |     def get_queryset(self): | ||||||
|   | |||||||
| @@ -78,12 +78,16 @@ class PartSerializer(InvenTreeModelSerializer): | |||||||
|     Used when displaying all details of a single component. |     Used when displaying all details of a single component. | ||||||
|     """ |     """ | ||||||
|  |  | ||||||
|     url = serializers.CharField(source='get_absolute_url', read_only=True) |     allocated_stock = serializers.FloatField(source='allocation_count', read_only=True) | ||||||
|     image = serializers.CharField(source='get_image_url', read_only=True) |     bom_items = serializers.IntegerField(source='bom_count', read_only=True) | ||||||
|     thumbnail = serializers.CharField(source='get_thumbnail_url', read_only=True) |     building = serializers.FloatField(source='quantity_being_built', read_only=False) | ||||||
|     category_name = serializers.CharField(source='category_path', read_only=True) |     category_name = serializers.CharField(source='category_path', read_only=True) | ||||||
|  |     image = serializers.CharField(source='get_image_url', read_only=True) | ||||||
|     allocated_stock = serializers.IntegerField(source='allocation_count', 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) | ||||||
|  |     link = serializers.CharField(source='URL') | ||||||
|  |     used_in = serializers.IntegerField(source='used_in_count', read_only=True) | ||||||
|  |  | ||||||
|     @staticmethod |     @staticmethod | ||||||
|     def setup_eager_loading(queryset): |     def setup_eager_loading(queryset): | ||||||
| @@ -97,31 +101,34 @@ class PartSerializer(InvenTreeModelSerializer): | |||||||
|         model = Part |         model = Part | ||||||
|         partial = True |         partial = True | ||||||
|         fields = [ |         fields = [ | ||||||
|             'pk', |             'active', | ||||||
|             'url',  # Link to the part detail page |             'allocated_stock', | ||||||
|  |             'assembly', | ||||||
|  |             'bom_items', | ||||||
|  |             'building', | ||||||
|             'category', |             'category', | ||||||
|             'category_name', |             'category_name', | ||||||
|             'image', |             'component', | ||||||
|             'thumbnail', |             'description', | ||||||
|             'full_name', |             'full_name', | ||||||
|             'name', |             'image', | ||||||
|             'IPN', |             'IPN', | ||||||
|             'is_template', |             'is_template', | ||||||
|             'variant_of', |  | ||||||
|             'description', |  | ||||||
|             'keywords', |             'keywords', | ||||||
|             'URL', |             'link', | ||||||
|             'total_stock', |             'name', | ||||||
|             'allocated_stock', |             'notes', | ||||||
|             'on_order', |             'on_order', | ||||||
|             'units', |             'pk', | ||||||
|             'trackable', |  | ||||||
|             'assembly', |  | ||||||
|             'component', |  | ||||||
|             'trackable', |  | ||||||
|             'purchaseable', |             'purchaseable', | ||||||
|             'salable', |             'salable', | ||||||
|             'active', |             'thumbnail', | ||||||
|  |             'trackable', | ||||||
|  |             'total_stock', | ||||||
|  |             'units', | ||||||
|  |             'used_in', | ||||||
|  |             'url',  # Link to the part detail page | ||||||
|  |             'variant_of', | ||||||
|             'virtual', |             'virtual', | ||||||
|         ] |         ] | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user