From dad594dc7ac9bf51a949827f3b95d3f3512a8c20 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 1 May 2018 08:55:51 +1000 Subject: [PATCH] Tweaked build detail page --- InvenTree/build/models.py | 14 ++++++++++++++ InvenTree/build/templates/build/detail.html | 8 ++++---- 2 files changed, 18 insertions(+), 4 deletions(-) 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 %}