This commit is contained in:
Oliver Walters 2017-03-28 23:17:56 +11:00
parent 18c39e7680
commit 9aebdab1c2
2 changed files with 13 additions and 1 deletions

View File

@ -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

View File

@ -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")
return HttpResponse("This is the Tracking page")