diff --git a/InvenTree/build/models.py b/InvenTree/build/models.py index e70c6ef11e..c821ce171e 100644 --- a/InvenTree/build/models.py +++ b/InvenTree/build/models.py @@ -60,6 +60,20 @@ class Build(models.Model): # Notes can be attached to each build output notes = models.TextField(blank=True) + @property + def required_parts(self): + parts = [] + + for item in self.part.bom_items.all(): + part = {'part': item.sub_part, + 'per_build': item.quantity, + 'quantity': item.quantity * self.quantity + } + + parts.append(part) + + return parts + @property def is_active(self): """ Is this build active? diff --git a/InvenTree/build/templates/build/detail.html b/InvenTree/build/templates/build/detail.html index 3188ba50ed..7cf18e6abb 100644 --- a/InvenTree/build/templates/build/detail.html +++ b/InvenTree/build/templates/build/detail.html @@ -46,11 +46,11 @@ - {% for item in build.part.bom_items.all %} + {% for item in build.required_parts %} - {{ item.sub_part.name }} - {{ build.quantity }} × {{ item.quantity }} - {{ item.sub_part.total_stock }} + {{ item.part.name }} + {{ item.quantity }} + {{ item.part.total_stock }} {% endfor %}