Fix display of parts currently being built

This commit is contained in:
Oliver Walters 2021-02-17 13:14:27 +11:00
parent ba542dcbdb
commit fcc35f2260
2 changed files with 13 additions and 7 deletions

View File

@ -1094,16 +1094,22 @@ class Part(MPTTModel):
@property
def quantity_being_built(self):
""" Return the current number of parts currently being built
"""
Return the current number of parts currently being built.
Note: This is the total quantity of Build orders, *not* the number of build outputs.
In this fashion, it is the "projected" quantity of builds
"""
stock_items = self.stock_items.filter(is_building=True)
builds = self.active_builds
query = stock_items.aggregate(
quantity=Coalesce(Sum('quantity'), Decimal(0))
)
quantity = 0
return query['quantity']
for build in builds:
# The remaining items in the build
quantity += build.remaining
return quantity
def build_order_allocations(self):
"""

View File

@ -164,7 +164,7 @@
{% if quantity_being_built > 0 %}
<tr>
<td></td>
<td>{% trans "Underway" %}</td>
<td>{% trans "Building" %}</td>
<td>{% decimal quantity_being_built %}</td>
</tr>
{% endif %}