Render better build description in complete form

- List of items to be removed from stock
- Detail of what will be created
This commit is contained in:
Oliver Walters 2019-05-02 00:12:28 +10:00
parent 905d78e25c
commit a4aec425be
2 changed files with 24 additions and 5 deletions

View File

@ -4,10 +4,21 @@
<b>Build: {{ build.title }}</b> - {{ build.quantity }} x {{ build.part.name }}
<br>
Are you sure you want to mark this build as complete?
<br>
Completing the build will perform the following actions:
<hr>
{% if taking %}
The following items will be removed from stock:
<ul>
<li>Remove allocated parts from stock</li>
<li>Create {{ build.quantity }} new items in the selected location</li>
{% for item in taking %}
<li>{{ item.quantity }} x {{ item.stock_item.part.name }} from {{ item.stock_item.location }}</li>
{% endfor %}
</ul>
{% else %}
No parts have been allocated to this build.
{% endif %}
<hr>
The following items will be created:
<ul>
<li>{{ build.quantity }} x {{ build.part.name }}</li>
</ul>
{% endblock %}

View File

@ -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