mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 05:05:42 +00:00 
			
		
		
		
	Added part category path string to serializer
This commit is contained in:
		| @@ -153,6 +153,12 @@ class Part(models.Model): | ||||
|         verbose_name = "Part" | ||||
|         verbose_name_plural = "Parts" | ||||
|  | ||||
|     @property | ||||
|     def category_path(self): | ||||
|         if self.category: | ||||
|             return self.category.pathstring | ||||
|         return '' | ||||
|  | ||||
|     @property | ||||
|     def available_stock(self): | ||||
|         """ | ||||
|   | ||||
| @@ -17,6 +17,7 @@ class PartSerializer(serializers.ModelSerializer): | ||||
|             'URL',  # Link to an external URL (optional) | ||||
|             'description', | ||||
|             'category', | ||||
|             'category_path', | ||||
|             'total_stock', | ||||
|             'available_stock', | ||||
|             'units', | ||||
|   | ||||
| @@ -33,7 +33,9 @@ function add_part(part) { | ||||
|  | ||||
|     // TODO - Work out how to add in category name + link... | ||||
|     if (part.category){ | ||||
|         text += "category: " + part.category; | ||||
|         text += '<a href="/part/category/' + part.category + '/">'; | ||||
|         text += part.category_path; | ||||
|         text += '</a>'; | ||||
|     } | ||||
|  | ||||
|     text += "</td>"; | ||||
|   | ||||
| @@ -10,10 +10,8 @@ | ||||
| {% include "part/category_subcategories.html" with children=children %} | ||||
| {% endif %} | ||||
|  | ||||
| {% if parts.all|length > 0%} | ||||
| <h4>Top Level Parts</h4> | ||||
| <h4>Parts</h4> | ||||
| {% include "part/category_parts.html" with parts=parts %} | ||||
| {% endif %} | ||||
|  | ||||
| <div class='container-fluid'> | ||||
| <a href="{% url 'category-create' %}"> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user