mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 19:46:46 +00:00
pepper
This commit is contained in:
parent
18c39e7680
commit
9aebdab1c2
@ -6,14 +6,17 @@ from django.core.exceptions import ObjectDoesNotExist
|
|||||||
|
|
||||||
from InvenTree.models import InvenTreeTree
|
from InvenTree.models import InvenTreeTree
|
||||||
|
|
||||||
|
|
||||||
class PartCategory(InvenTreeTree):
|
class PartCategory(InvenTreeTree):
|
||||||
""" PartCategory provides hierarchical organization of Part objects.
|
""" PartCategory provides hierarchical organization of Part objects.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "Part Category"
|
verbose_name = "Part Category"
|
||||||
verbose_name_plural = "Part Categories"
|
verbose_name_plural = "Part Categories"
|
||||||
|
|
||||||
|
|
||||||
class Part(models.Model):
|
class Part(models.Model):
|
||||||
""" Represents a """
|
""" Represents a """
|
||||||
|
|
||||||
@ -25,6 +28,7 @@ class Part(models.Model):
|
|||||||
units = models.CharField(max_length=20, default="pcs", blank=True)
|
units = models.CharField(max_length=20, default="pcs", blank=True)
|
||||||
trackable = models.BooleanField(default=False)
|
trackable = models.BooleanField(default=False)
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.IPN:
|
if self.IPN:
|
||||||
return "{name} ({ipn})".format(
|
return "{name} ({ipn})".format(
|
||||||
@ -33,10 +37,12 @@ class Part(models.Model):
|
|||||||
else:
|
else:
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "Part"
|
verbose_name = "Part"
|
||||||
verbose_name_plural = "Parts"
|
verbose_name_plural = "Parts"
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def stock_list(self):
|
def stock_list(self):
|
||||||
""" Return a list of all stock objects associated with this part
|
""" Return a list of all stock objects associated with this part
|
||||||
@ -44,6 +50,7 @@ class Part(models.Model):
|
|||||||
|
|
||||||
return self.stockitem_set.all()
|
return self.stockitem_set.all()
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def stock(self):
|
def stock(self):
|
||||||
""" Return the total stock quantity for this part.
|
""" Return the total stock quantity for this part.
|
||||||
@ -57,6 +64,7 @@ class Part(models.Model):
|
|||||||
result = stocks.aggregate(total=Sum('quantity'))
|
result = stocks.aggregate(total=Sum('quantity'))
|
||||||
return result['total']
|
return result['total']
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def projects(self):
|
def projects(self):
|
||||||
""" Return a list of unique projects that this part is associated with
|
""" Return a list of unique projects that this part is associated with
|
||||||
@ -74,6 +82,7 @@ class Part(models.Model):
|
|||||||
|
|
||||||
return projects
|
return projects
|
||||||
|
|
||||||
|
|
||||||
class PartRevision(models.Model):
|
class PartRevision(models.Model):
|
||||||
""" A PartRevision represents a change-notification to a Part
|
""" A PartRevision represents a change-notification to a Part
|
||||||
A Part may go through several revisions in its lifetime,
|
A Part may go through several revisions in its lifetime,
|
||||||
@ -87,5 +96,6 @@ class PartRevision(models.Model):
|
|||||||
description = models.CharField(max_length=500)
|
description = models.CharField(max_length=500)
|
||||||
revision_date = models.DateField(auto_now_add = True)
|
revision_date = models.DateField(auto_now_add = True)
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
@ -1,5 +1,7 @@
|
|||||||
from django.shortcuts import render, get_object_or_404
|
from django.shortcuts import render, get_object_or_404
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
|
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
return HttpResponse("This is the Tracking page")
|
return HttpResponse("This is the Tracking page")
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user