From d10ba5edc3abf7c06a63d2841dee5437faecf2c5 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 17 Sep 2020 00:55:54 -0700 Subject: [PATCH] handle case where stock item does not have a location set; also show header --- InvenTree/build/templates/build/allocate.html | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/InvenTree/build/templates/build/allocate.html b/InvenTree/build/templates/build/allocate.html index 37906b2c63..36aebff870 100644 --- a/InvenTree/build/templates/build/allocate.html +++ b/InvenTree/build/templates/build/allocate.html @@ -50,6 +50,15 @@ InvenTree | Allocate Parts return {{ build.quantity }} * row.quantity - sumAllocations(row); } + function setExpandedAllocatedLocation(row) { + // Handle case when stock item does not have a location set + if (row.location_detail == null) { + return 'No stock location set'; + } else { + return row.location_detail.pathstring; + } + } + function reloadTable() { // Reload the build allocation table buildTable.bootstrapTable('refresh'); @@ -146,7 +155,7 @@ InvenTree | Allocate Parts subTable.bootstrapTable({ data: row.allocations, - showHeader: false, + showHeader: true, columns: [ { width: '50%', @@ -177,7 +186,7 @@ InvenTree | Allocate Parts title: '{% trans "Location" %}', formatter: function(value, row, index, field) { {% if build.status == BuildStatus.COMPLETE %} - var text = row.location_detail.pathstring; + var text = setExpandedAllocatedLocation(row); var url = `/stock/location/${row.location}/`; {% else %} var text = row.stock_item_detail.location_name;