diff --git a/InvenTree/InvenTree/models.py b/InvenTree/InvenTree/models.py
index f607ffa19a..6c2d10d866 100644
--- a/InvenTree/InvenTree/models.py
+++ b/InvenTree/InvenTree/models.py
@@ -61,7 +61,7 @@ class InvenTreeTree(models.Model):
return acceptable
@property
- def path(self):
+ def parentpath(self):
""" Return the parent path of this category
Todo:
@@ -70,11 +70,16 @@ class InvenTreeTree(models.Model):
"""
if self.parent:
- return self.parent.path + [self.parent]
+ return self.parent.parentpath + [self.parent]
else:
return []
-
- return parent_path
+
+ @property
+ def path(self):
+ if self.parent:
+ return "/".join([p.name for p in self.parentpath]) + "/" + self.name
+ else:
+ return self.name
def __setattr__(self, attrname, val):
""" Custom Attribute Setting function
@@ -118,10 +123,7 @@ class InvenTreeTree(models.Model):
This is recursive - Make it not so.
"""
- if self.parent:
- return "/".join([p.name for p in self.path]) + "/" + self.name
- else:
- return self.name
+ return self.path
class Meta:
diff --git a/InvenTree/part/admin.py b/InvenTree/part/admin.py
index 34e1ad40e6..fce0c2d257 100644
--- a/InvenTree/part/admin.py
+++ b/InvenTree/part/admin.py
@@ -2,12 +2,15 @@ from django.contrib import admin
from .models import PartCategory, Part
-admin.site.register(Part)
+class PartAdmin(admin.ModelAdmin):
+
+ list_display = ('name', 'IPN', 'category')
# Custom form for PartCategory
class PartCategoryAdmin(admin.ModelAdmin):
- # TODO - Only let valid parents be displayed
- pass
+
+ list_display = ('name', 'path', 'description')
+admin.site.register(Part, PartAdmin)
admin.site.register(PartCategory, PartCategoryAdmin)
\ No newline at end of file
diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py
index 12394719e4..5fe39656bf 100644
--- a/InvenTree/part/models.py
+++ b/InvenTree/part/models.py
@@ -20,6 +20,9 @@ class Part(models.Model):
description = models.CharField(max_length=250, blank=True)
IPN = models.CharField(max_length=100, blank=True)
category = models.ForeignKey(PartCategory, on_delete=models.CASCADE)
+ minimum_stock = models.IntegerField(default=0)
+ units = models.CharField(max_length=20, default="pcs", blank=True)
+ trackable = models.BooleanField(default=False)
def __str__(self):
if self.IPN:
@@ -33,4 +36,18 @@ class Part(models.Model):
verbose_name = "Part"
verbose_name_plural = "Parts"
-
\ No newline at end of file
+class PartRevision(models.Model):
+ """ A PartRevision represents a change-notification to a Part
+ A Part may go through several revisions in its lifetime,
+ which should be tracked.
+ UniqueParts can have a single associated PartRevision
+ """
+
+ part = models.ForeignKey(Part, on_delete=models.CASCADE)
+
+ name = models.CharField(max_length=100)
+ description = models.CharField(max_length=500)
+ revision_date = models.DateField(auto_now_add = True)
+
+ def __str__(self):
+ return self.name
\ No newline at end of file
diff --git a/InvenTree/part/templates/part/category.html b/InvenTree/part/templates/part/category.html
index 70d4bd6246..8e999ea96c 100644
--- a/InvenTree/part/templates/part/category.html
+++ b/InvenTree/part/templates/part/category.html
@@ -1,6 +1,6 @@
{# Construct the category path #}
Category/
-{% for path_item in category.path %}
+{% for path_item in category.parentpath %}
{{ path_item.name }}/
{% endfor %}
diff --git a/InvenTree/project/admin.py b/InvenTree/project/admin.py
index 043b785587..f266fb3612 100644
--- a/InvenTree/project/admin.py
+++ b/InvenTree/project/admin.py
@@ -2,6 +2,15 @@ from django.contrib import admin
from .models import ProjectCategory, Project, ProjectPart
-admin.site.register(ProjectCategory)
-admin.site.register(Project)
-admin.site.register(ProjectPart)
\ No newline at end of file
+class ProjectCategoryAdmin(admin.ModelAdmin):
+ list_display = ('name', 'path', 'description')
+
+class ProjectAdmin(admin.ModelAdmin):
+ list_display = ('name', 'description', 'category')
+
+class ProjectPartAdmin(admin.ModelAdmin):
+ list_display = ('part', 'project', 'quantity')
+
+admin.site.register(ProjectCategory, ProjectCategoryAdmin)
+admin.site.register(Project, ProjectAdmin)
+admin.site.register(ProjectPart, ProjectPartAdmin)
\ No newline at end of file
diff --git a/InvenTree/stock/admin.py b/InvenTree/stock/admin.py
index 0ddf5d0b3e..4a6b7be4c0 100644
--- a/InvenTree/stock/admin.py
+++ b/InvenTree/stock/admin.py
@@ -2,5 +2,11 @@ from django.contrib import admin
from .models import Warehouse, StockItem
-admin.site.register(Warehouse)
-admin.site.register(StockItem)
\ No newline at end of file
+class WarehouseAdmin(admin.ModelAdmin):
+ list_display = ('name', 'path', 'description')
+
+class StockItemAdmin(admin.ModelAdmin):
+ list_display = ('part', 'quantity', 'location', 'updated')
+
+admin.site.register(Warehouse, WarehouseAdmin)
+admin.site.register(StockItem, StockItemAdmin)
\ No newline at end of file
diff --git a/InvenTree/supplier/admin.py b/InvenTree/supplier/admin.py
index 74b182d9f8..4b76c26e0f 100644
--- a/InvenTree/supplier/admin.py
+++ b/InvenTree/supplier/admin.py
@@ -2,5 +2,8 @@ from django.contrib import admin
from .models import Supplier, SupplierPart
-admin.site.register(Supplier)
+class SupplierAdmin(admin.ModelAdmin):
+ list_display=('name','URL','contact')
+
+admin.site.register(Supplier, SupplierAdmin)
admin.site.register(SupplierPart)
\ No newline at end of file
diff --git a/InvenTree/track/admin.py b/InvenTree/track/admin.py
index 51037c0176..b6077f2080 100644
--- a/InvenTree/track/admin.py
+++ b/InvenTree/track/admin.py
@@ -2,4 +2,7 @@ from django.contrib import admin
from .models import UniquePart
-admin.site.register(UniquePart)
\ No newline at end of file
+class UniquePartAdmin(admin.ModelAdmin):
+ list_display = ('part', 'revision', 'serial', 'creation_date')
+
+admin.site.register(UniquePart, UniquePartAdmin)
\ No newline at end of file
diff --git a/InvenTree/track/models.py b/InvenTree/track/models.py
index 3de10e9cde..145ada6021 100644
--- a/InvenTree/track/models.py
+++ b/InvenTree/track/models.py
@@ -3,7 +3,7 @@ from __future__ import unicode_literals
from django.db import models
from django.contrib.auth.models import User
-from part.models import Part
+from part.models import Part, PartRevision
class UniquePart(models.Model):
""" A unique instance of a Part object.
@@ -12,11 +12,20 @@ class UniquePart(models.Model):
"""
part = models.ForeignKey(Part, on_delete=models.CASCADE)
- created = models.DateField(auto_now_add=True,
+
+ revision = models.ForeignKey(PartRevision,
+ on_delete=models.CASCADE,
+ blank=True,
+ null=True)
+
+ creation_date = models.DateField(auto_now_add=True,
editable=False)
serial = models.IntegerField()
createdBy = models.ForeignKey(User)
+
+ def __str__(self):
+ return self.part.name
class PartTrackingInfo(models.Model):
""" Single data-point in the life of a UniquePart