2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-13 08:21:26 +00:00

Update 'Build'

- Part model now has active_builds and inactive_builds properties
-
This commit is contained in:
Oliver
2018-04-17 20:25:43 +10:00
parent 256f8eb924
commit 0b40197cd2
7 changed files with 201 additions and 30 deletions

View File

@ -183,6 +183,28 @@ class Part(models.Model):
return total
@property
def active_builds(self):
""" Return a list of outstanding builds.
Builds marked as 'complete' or 'cancelled' are ignored
"""
return [b for b in self.builds.all() if b.is_active]
@property
def inactive_builds(self):
""" Return a list of inactive builds
"""
return [b for b in self.builds.all() if not b.is_active]
@property
def quantity_being_built(self):
""" Return the current number of parts currently being built
"""
return sum([b.quantity for b in self.active_builds])
@property
def total_stock(self):
""" Return the total stock quantity for this part.