From 34df19242cc8afcd4229dbe1dede7322242914de Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Wed, 17 Feb 2021 11:08:11 +1100 Subject: [PATCH] Adds more context data --- InvenTree/part/templates/part/part_base.html | 6 +++--- InvenTree/part/templates/part/stock_count.html | 6 +++--- InvenTree/part/templates/part/tabs.html | 4 ++-- InvenTree/part/views.py | 6 ++++++ 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/InvenTree/part/templates/part/part_base.html b/InvenTree/part/templates/part/part_base.html index 24c0c0b234..57821b4a89 100644 --- a/InvenTree/part/templates/part/part_base.html +++ b/InvenTree/part/templates/part/part_base.html @@ -119,18 +119,18 @@

{% trans "Available Stock" %}

-

{% decimal part.available_stock %}{% if part.units %} {{ part.units }}{% endif %}

+

{% decimal available %}{% if part.units %} {{ part.units }}{% endif %}

{% trans "In Stock" %} {% include "part/stock_count.html" %} - {% if part.on_order > 0 %} + {% if on_order > 0 %} {% trans "On Order" %} - {% decimal part.on_order %} + {% decimal on_order %} {% endif %} {% if required > 0 %} diff --git a/InvenTree/part/templates/part/stock_count.html b/InvenTree/part/templates/part/stock_count.html index 58e447b051..5b70995a22 100644 --- a/InvenTree/part/templates/part/stock_count.html +++ b/InvenTree/part/templates/part/stock_count.html @@ -1,10 +1,10 @@ {% load inventree_extras %} {% load i18n %} -{% decimal part.total_stock %} +{% decimal total_stock %} -{% if part.total_stock == 0 %} +{% if total_stock == 0 %} {% trans "No Stock" %} -{% elif part.total_stock < part.minimum_stock %} +{% elif total_stock < part.minimum_stock %} {% trans "Low Stock" %} {% endif %} \ No newline at end of file diff --git a/InvenTree/part/templates/part/tabs.html b/InvenTree/part/templates/part/tabs.html index 8bfaba4d89..32a62f94e9 100644 --- a/InvenTree/part/templates/part/tabs.html +++ b/InvenTree/part/templates/part/tabs.html @@ -15,12 +15,12 @@ {% endif %} {% if not part.virtual %} - {% trans "Stock" %} {% decimal part.total_stock %} + {% trans "Stock" %} {% decimal total_stock %} {% endif %} {% if part.component or part.salable or part.used_in_count > 0 %} - {% trans "Allocated" %} {% decimal part.allocation_count %} + {% trans "Allocated" %} {% decimal allocated %} {% endif %} {% if part.assembly %} diff --git a/InvenTree/part/views.py b/InvenTree/part/views.py index 42c48c8cab..745650b55d 100644 --- a/InvenTree/part/views.py +++ b/InvenTree/part/views.py @@ -793,12 +793,18 @@ class PartDetail(InvenTreeRoleMixin, DetailView): context['disabled'] = not part.active # Pre-calculate complex queries so they only need to be performed once + context['total_stock'] = part.total_stock + + context['quantity_being_built'] = part.quantity_being_built + context['required_build_order_quantity'] = part.required_build_order_quantity() context['allocated_build_order_quantity'] = part.build_order_allocation_count() context['required_sales_order_quantity'] = part.required_sales_order_quantity() context['allocated_sales_order_quantity'] = part.sales_order_allocation_count() + context['available'] = part.available_stock + context['on_order'] = part.on_order context['required'] = context['required_build_order_quantity'] + context['required_sales_order_quantity'] context['allocated'] = context['allocated_build_order_quantity'] + context['allocated_sales_order_quantity']