From a95e77c429ae58ab5b5c8d9b0d37b9c0742b8578 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 18 May 2019 12:17:57 +1000 Subject: [PATCH] Pre-fill allocation count --- InvenTree/build/templates/build/allocation_item.html | 2 +- InvenTree/part/templatetags/inventree_extras.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/InvenTree/build/templates/build/allocation_item.html b/InvenTree/build/templates/build/allocation_item.html index 96520008bb..f5af9ef6f4 100644 --- a/InvenTree/build/templates/build/allocation_item.html +++ b/InvenTree/build/templates/build/allocation_item.html @@ -25,7 +25,7 @@ Allocated:
- 0 + {% part_allocation_count build item.sub_part %}
diff --git a/InvenTree/part/templatetags/inventree_extras.py b/InvenTree/part/templatetags/inventree_extras.py index c06854227c..b17c5bf9e8 100644 --- a/InvenTree/part/templatetags/inventree_extras.py +++ b/InvenTree/part/templatetags/inventree_extras.py @@ -14,6 +14,13 @@ def multiply(x, y, *args, **kwargs): return x * y +@register.simple_tag() +def part_allocation_count(build, part, *args, **kwargs): + """ Return the total number of allocated to """ + + return build.getAllocatedQuantity(part) + + @register.simple_tag() def inventree_version(*args, **kwargs): """ Return InvenTree version string """