mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +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,
|
||||
and in turn can have zero-or-one parent category.
|
||||
"""
|
||||
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Project Category"
|
||||
verbose_name_plural = "Project Categories"
|
||||
@ -21,14 +21,14 @@ class Project(models.Model):
|
||||
""" A Project takes multiple Part objects.
|
||||
A project can output zero-or-more Part objects
|
||||
"""
|
||||
|
||||
|
||||
name = models.CharField(max_length=100)
|
||||
description = models.CharField(max_length=500, blank=True)
|
||||
category = models.ForeignKey(ProjectCategory, on_delete=models.CASCADE)
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
@property
|
||||
def projectParts(self):
|
||||
""" 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 overage is the number of extra parts that are generally used for a single run.
|
||||
"""
|
||||
|
||||
|
||||
# Overage types
|
||||
OVERAGE_PERCENT = 0
|
||||
OVERAGE_ABSOLUTE = 1
|
||||
|
||||
|
||||
part = models.ForeignKey(Part, 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_type = models.IntegerField(
|
||||
overage_type = models.PositiveIntegerField(
|
||||
default=1,
|
||||
choices=[
|
||||
(OVERAGE_PERCENT, "Percent"),
|
||||
(OVERAGE_ABSOLUTE, "Absolute")
|
||||
])
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return "{quan} x {name}".format(
|
||||
name=self.part.name,
|
||||
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):
|
||||
""" Represents a manufacturer or supplier
|
||||
"""
|
||||
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
||||
class Manufacturer(Company):
|
||||
""" Represents a manfufacturer
|
||||
@ -37,13 +37,18 @@ class SupplierPart(models.Model):
|
||||
supplier = models.ForeignKey(Supplier,
|
||||
on_delete=models.CASCADE)
|
||||
SKU = models.CharField(max_length=100)
|
||||
|
||||
|
||||
manufacturer = models.ForeignKey(Manufacturer, blank=True, null=True, on_delete=models.CASCADE)
|
||||
MPN = models.CharField(max_length=100, blank=True)
|
||||
|
||||
|
||||
URL = models.URLField(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):
|
||||
return "{mpn} - {supplier}".format(
|
||||
mpn=self.MPN,
|
||||
@ -58,7 +63,7 @@ class SupplierPriceBreak(models.Model):
|
||||
|
||||
part = models.ForeignKey(SupplierPart,
|
||||
on_delete=models.CASCADE)
|
||||
quantity = models.IntegerField()
|
||||
quantity = models.PositiveIntegerField()
|
||||
cost = models.DecimalField(max_digits=10, decimal_places=3)
|
||||
currency = models.CharField(max_length=10,
|
||||
blank=True)
|
||||
|
Loading…
Reference in New Issue
Block a user