2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-03 04:00:57 +00:00

Include quantity currently being build in Part API

This commit is contained in:
Oliver Walters
2020-03-26 17:43:02 +11:00
parent 41bbbdcd43
commit 6a78f6d451
2 changed files with 12 additions and 5 deletions

View File

@ -569,7 +569,12 @@ class Part(models.Model):
""" Return the current number of parts currently being built
"""
return sum([b.quantity for b in self.active_builds])
quantity = self.active_builds.aggregate(quantity=Sum('quantity'))['quantity']
if quantity is None:
quantity = 0
return quantity
@property
def build_allocation(self):