diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 0af382ec64..fab3c866bc 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -6,14 +6,17 @@ from django.core.exceptions import ObjectDoesNotExist from InvenTree.models import InvenTreeTree + class PartCategory(InvenTreeTree): """ PartCategory provides hierarchical organization of Part objects. """ + class Meta: verbose_name = "Part Category" verbose_name_plural = "Part Categories" + class Part(models.Model): """ Represents a """ @@ -25,6 +28,7 @@ class Part(models.Model): units = models.CharField(max_length=20, default="pcs", blank=True) trackable = models.BooleanField(default=False) + def __str__(self): if self.IPN: return "{name} ({ipn})".format( @@ -33,10 +37,12 @@ class Part(models.Model): else: return self.name + class Meta: verbose_name = "Part" verbose_name_plural = "Parts" + @property def stock_list(self): """ Return a list of all stock objects associated with this part @@ -44,6 +50,7 @@ class Part(models.Model): return self.stockitem_set.all() + @property def stock(self): """ Return the total stock quantity for this part. @@ -57,6 +64,7 @@ class Part(models.Model): result = stocks.aggregate(total=Sum('quantity')) return result['total'] + @property def projects(self): """ Return a list of unique projects that this part is associated with @@ -74,6 +82,7 @@ class Part(models.Model): return projects + class PartRevision(models.Model): """ A PartRevision represents a change-notification to a Part A Part may go through several revisions in its lifetime, @@ -87,5 +96,6 @@ class PartRevision(models.Model): 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/track/views.py b/InvenTree/track/views.py index 87db2335dc..16842c6008 100644 --- a/InvenTree/track/views.py +++ b/InvenTree/track/views.py @@ -1,5 +1,7 @@ from django.shortcuts import render, get_object_or_404 from django.http import HttpResponse + def index(request): - return HttpResponse("This is the Tracking page") \ No newline at end of file + return HttpResponse("This is the Tracking page") + \ No newline at end of file