diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 6c7da027e3..dd05862271 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -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): """ diff --git a/InvenTree/part/serializers.py b/InvenTree/part/serializers.py index 922d08f315..902c2b16a1 100644 --- a/InvenTree/part/serializers.py +++ b/InvenTree/part/serializers.py @@ -17,6 +17,7 @@ class PartSerializer(serializers.ModelSerializer): 'URL', # Link to an external URL (optional) 'description', 'category', + 'category_path', 'total_stock', 'available_stock', 'units', diff --git a/InvenTree/part/templates/part/category_parts.html b/InvenTree/part/templates/part/category_parts.html index dadebe7818..a878d8ed4f 100644 --- a/InvenTree/part/templates/part/category_parts.html +++ b/InvenTree/part/templates/part/category_parts.html @@ -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 += ''; + text += part.category_path; + text += ''; } text += ""; diff --git a/InvenTree/part/templates/part/index.html b/InvenTree/part/templates/part/index.html index dc00191271..94d939f27e 100644 --- a/InvenTree/part/templates/part/index.html +++ b/InvenTree/part/templates/part/index.html @@ -10,10 +10,8 @@ {% include "part/category_subcategories.html" with children=children %} {% endif %} -{% if parts.all|length > 0%} -

Top Level Parts

+

Parts

{% include "part/category_parts.html" with parts=parts %} -{% endif %}