mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 12:06:44 +00:00
Added "ProjectRun" model
This commit is contained in:
parent
2b998a1931
commit
aafa8781d7
@ -11,7 +11,7 @@ class ProjectCategory(InvenTreeTree):
|
|||||||
Each ProjectCategory can contain zero-or-more child categories,
|
Each ProjectCategory can contain zero-or-more child categories,
|
||||||
and in turn can have zero-or-one parent category.
|
and in turn can have zero-or-one parent category.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "Project Category"
|
verbose_name = "Project Category"
|
||||||
verbose_name_plural = "Project Categories"
|
verbose_name_plural = "Project Categories"
|
||||||
@ -21,14 +21,14 @@ class Project(models.Model):
|
|||||||
""" A Project takes multiple Part objects.
|
""" A Project takes multiple Part objects.
|
||||||
A project can output zero-or-more Part objects
|
A project can output zero-or-more Part objects
|
||||||
"""
|
"""
|
||||||
|
|
||||||
name = models.CharField(max_length=100)
|
name = models.CharField(max_length=100)
|
||||||
description = models.CharField(max_length=500, blank=True)
|
description = models.CharField(max_length=500, blank=True)
|
||||||
category = models.ForeignKey(ProjectCategory, on_delete=models.CASCADE)
|
category = models.ForeignKey(ProjectCategory, on_delete=models.CASCADE)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def projectParts(self):
|
def projectParts(self):
|
||||||
""" Return a list of all project parts associated with this project
|
""" Return a list of all project parts associated with this project
|
||||||
@ -41,23 +41,37 @@ class ProjectPart(models.Model):
|
|||||||
The quantity of parts required for a single-run of that project is stored.
|
The quantity of parts required for a single-run of that project is stored.
|
||||||
The overage is the number of extra parts that are generally used for a single run.
|
The overage is the number of extra parts that are generally used for a single run.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Overage types
|
# Overage types
|
||||||
OVERAGE_PERCENT = 0
|
OVERAGE_PERCENT = 0
|
||||||
OVERAGE_ABSOLUTE = 1
|
OVERAGE_ABSOLUTE = 1
|
||||||
|
|
||||||
part = models.ForeignKey(Part, on_delete=models.CASCADE)
|
part = models.ForeignKey(Part, on_delete=models.CASCADE)
|
||||||
project = models.ForeignKey(Project, on_delete=models.CASCADE)
|
project = models.ForeignKey(Project, on_delete=models.CASCADE)
|
||||||
quantity = models.IntegerField(default=1)
|
quantity = models.PositiveIntegerField(default=1)
|
||||||
overage = models.FloatField(default=0)
|
overage = models.FloatField(default=0)
|
||||||
overage_type = models.IntegerField(
|
overage_type = models.PositiveIntegerField(
|
||||||
default=1,
|
default=1,
|
||||||
choices=[
|
choices=[
|
||||||
(OVERAGE_PERCENT, "Percent"),
|
(OVERAGE_PERCENT, "Percent"),
|
||||||
(OVERAGE_ABSOLUTE, "Absolute")
|
(OVERAGE_ABSOLUTE, "Absolute")
|
||||||
])
|
])
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{quan} x {name}".format(
|
return "{quan} x {name}".format(
|
||||||
name=self.part.name,
|
name=self.part.name,
|
||||||
quan=self.quantity)
|
quan=self.quantity)
|
||||||
|
|
||||||
|
class ProjectRun(models.Model):
|
||||||
|
""" A single run of a particular project.
|
||||||
|
Tracks the number of 'units' made in the project.
|
||||||
|
Provides functionality to update stock,
|
||||||
|
based on both:
|
||||||
|
a) Parts used (project inputs)
|
||||||
|
b) Parts produced (project outputs)
|
||||||
|
"""
|
||||||
|
|
||||||
|
project = models.ForeignKey(Project, on_delete=models.CASCADE)
|
||||||
|
quantity = models.PositiveIntegerField(default=1)
|
||||||
|
|
||||||
|
run_date = models.DateField(auto_now_add=True)
|
||||||
|
@ -9,9 +9,9 @@ from part.models import Part
|
|||||||
class Supplier(Company):
|
class Supplier(Company):
|
||||||
""" Represents a manufacturer or supplier
|
""" Represents a manufacturer or supplier
|
||||||
"""
|
"""
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Manufacturer(Company):
|
class Manufacturer(Company):
|
||||||
""" Represents a manfufacturer
|
""" Represents a manfufacturer
|
||||||
@ -37,13 +37,18 @@ class SupplierPart(models.Model):
|
|||||||
supplier = models.ForeignKey(Supplier,
|
supplier = models.ForeignKey(Supplier,
|
||||||
on_delete=models.CASCADE)
|
on_delete=models.CASCADE)
|
||||||
SKU = models.CharField(max_length=100)
|
SKU = models.CharField(max_length=100)
|
||||||
|
|
||||||
manufacturer = models.ForeignKey(Manufacturer, blank=True, null=True, on_delete=models.CASCADE)
|
manufacturer = models.ForeignKey(Manufacturer, blank=True, null=True, on_delete=models.CASCADE)
|
||||||
MPN = models.CharField(max_length=100, blank=True)
|
MPN = models.CharField(max_length=100, blank=True)
|
||||||
|
|
||||||
URL = models.URLField(blank=True)
|
URL = models.URLField(blank=True)
|
||||||
description = models.CharField(max_length=250, blank=True)
|
description = models.CharField(max_length=250, blank=True)
|
||||||
|
|
||||||
|
single_price = models.DecimalField(max_digits=10, decimal_places=3)
|
||||||
|
|
||||||
|
# packaging that the part is supplied in, e.g. "Reel"
|
||||||
|
packaging = models.CharField(max_length=50, blank=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{mpn} - {supplier}".format(
|
return "{mpn} - {supplier}".format(
|
||||||
mpn=self.MPN,
|
mpn=self.MPN,
|
||||||
@ -58,7 +63,7 @@ class SupplierPriceBreak(models.Model):
|
|||||||
|
|
||||||
part = models.ForeignKey(SupplierPart,
|
part = models.ForeignKey(SupplierPart,
|
||||||
on_delete=models.CASCADE)
|
on_delete=models.CASCADE)
|
||||||
quantity = models.IntegerField()
|
quantity = models.PositiveIntegerField()
|
||||||
cost = models.DecimalField(max_digits=10, decimal_places=3)
|
cost = models.DecimalField(max_digits=10, decimal_places=3)
|
||||||
currency = models.CharField(max_length=10,
|
currency = models.CharField(max_length=10,
|
||||||
blank=True)
|
blank=True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user