2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-12 10:05:39 +00:00

peppa pig

This commit is contained in:
Oliver Walters
2017-03-28 23:31:41 +11:00
parent 14f60e1292
commit b5dc22f33a
3 changed files with 15 additions and 18 deletions

View File

@ -7,11 +7,10 @@ from django.core.exceptions import ObjectDoesNotExist
from InvenTree.models import InvenTreeTree
class PartCategory(InvenTreeTree):
class PartCategory(InvenTreeTree):
""" PartCategory provides hierarchical organization of Part objects.
"""
class Meta:
verbose_name = "Part Category"
verbose_name_plural = "Part Categories"
@ -28,21 +27,18 @@ 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(
ipn = self.IPN,
name = self.name)
ipn=self.IPN,
name=self.name)
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
@ -50,7 +46,6 @@ class Part(models.Model):
return self.stockitem_set.all()
@property
def stock(self):
""" Return the total stock quantity for this part.
@ -64,7 +59,6 @@ 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
@ -82,7 +76,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,
@ -96,6 +90,5 @@ class PartRevision(models.Model):
description = models.CharField(max_length=500)
revision_date = models.DateField(auto_now_add = True)
def __str__(self):
return self.name
return self.name