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

Move BomItem into the Part app

- Does not make sense to keep these separate
- Removed bom app entirely
This commit is contained in:
Oliver
2018-04-14 14:19:03 +10:00
parent 1da6df0c5e
commit e30a089c76
15 changed files with 84 additions and 122 deletions

View File

@ -118,3 +118,32 @@ class Part(models.Model):
"""
class BomItem(models.Model):
""" A BomItem links a part to its component items.
A part can have a BOM (bill of materials) which defines
which parts are required (and in what quatity) to make it
"""
# A link to the parent part
# Each part will get a reverse lookup field 'bom_items'
part = models.ForeignKey(Part, on_delete=models.CASCADE, related_name='bom_items')
# A link to the child item (sub-part)
# Each part will get a reverse lookup field 'used_in'
sub_part = models.ForeignKey(Part, on_delete=models.CASCADE, related_name='used_in')
# Quantity required
quantity = models.PositiveIntegerField(default=1, validators=[MinValueValidator(0)])
class Meta:
verbose_name = "BOM Item"
# Prevent duplication of parent/child rows
unique_together = ('part', 'sub_part')
def __str__(self):
return "{par} -> {child} ({n})".format(
par=self.part.name,
child=self.sub_part.name,
n=self.quantity)