From a4aec425be63be743fd7562edfb0a24122458185 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 2 May 2019 00:12:28 +1000 Subject: [PATCH] Render better build description in complete form - List of items to be removed from stock - Detail of what will be created --- InvenTree/build/templates/build/complete.html | 19 +++++++++++++++---- InvenTree/build/views.py | 10 +++++++++- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/InvenTree/build/templates/build/complete.html b/InvenTree/build/templates/build/complete.html index ce1577259d..506f766c44 100644 --- a/InvenTree/build/templates/build/complete.html +++ b/InvenTree/build/templates/build/complete.html @@ -4,10 +4,21 @@ Build: {{ build.title }} - {{ build.quantity }} x {{ build.part.name }}
Are you sure you want to mark this build as complete? -
-Completing the build will perform the following actions: +
+{% if taking %} +The following items will be removed from stock: +{% else %} +No parts have been allocated to this build. +{% endif %} +
+The following items will be created: + + {% endblock %} \ No newline at end of file diff --git a/InvenTree/build/views.py b/InvenTree/build/views.py index 76558d87ee..f429980c4e 100644 --- a/InvenTree/build/views.py +++ b/InvenTree/build/views.py @@ -95,6 +95,7 @@ class BuildComplete(AjaxUpdateView): if build.part.default_location is not None: try: location = StockLocation.objects.get(pk=build.part.default_location.id) + initials['location'] = location except StockLocation.DoesNotExist: pass @@ -106,8 +107,15 @@ class BuildComplete(AjaxUpdateView): - Build information is required """ + build = self.get_object() + + # Build object context = super(BuildComplete, self).get_context_data(**kwargs).copy() - context['build'] = self.get_object() + context['build'] = build + + # Items to be removed from stock + taking = BuildItem.objects.filter(build=build.id) + context['taking'] = taking return context