From 2d21bf0626e632b46e3da66304cbc4bc50001a62 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 12 Apr 2019 22:09:50 +1000 Subject: [PATCH] Part BOM list now shows how many of each sub-item are available - If there are enough to build the available quantity is shown in green - Otherwise, shown in orange --- InvenTree/part/serializers.py | 1 + InvenTree/part/templates/part/bom.html | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/InvenTree/part/serializers.py b/InvenTree/part/serializers.py index 061bf06145..5746c00fdd 100644 --- a/InvenTree/part/serializers.py +++ b/InvenTree/part/serializers.py @@ -32,6 +32,7 @@ class PartBriefSerializer(serializers.ModelSerializer): 'url', 'name', 'description', + 'available_stock', ] diff --git a/InvenTree/part/templates/part/bom.html b/InvenTree/part/templates/part/bom.html index 723e0cad00..7b9e829686 100644 --- a/InvenTree/part/templates/part/bom.html +++ b/InvenTree/part/templates/part/bom.html @@ -85,10 +85,29 @@ }, { field: 'quantity', - title: 'Quantity', + title: 'Required', searchable: false, sortable: true }, + { + field: 'sub_part.available_stock', + title: 'Available', + searchable: false, + sortable: true, + formatter: function(value, row, index, field) { + var text = ""; + if (row.quantity < row.sub_part.available_stock) + { + text = "" + value + ""; + } + else + { + text = "" + value + ""; + } + + return renderLink(text, row.sub_part.url + "stock/"); + } + }, { formatter: function(value, row, index, field) { return editButton(row.url + 'edit') + ' ' + deleteButton(row.url + 'delete');