From fa7a33dc9c8ffc753cfe26d0338a9df64d5b2129 Mon Sep 17 00:00:00 2001 From: simonkuehling Date: Tue, 21 Feb 2023 23:51:09 +0100 Subject: [PATCH] add missing units to Build Order view (#4386) (#4388) * add missing units to Build Order view (#4386) * JS styling fixes * more JS styling fixes --- InvenTree/templates/js/translated/build.js | 29 +++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/InvenTree/templates/js/translated/build.js b/InvenTree/templates/js/translated/build.js index 7d410a2a54..36c175a640 100644 --- a/InvenTree/templates/js/translated/build.js +++ b/InvenTree/templates/js/translated/build.js @@ -479,6 +479,9 @@ function completeBuildOutputs(build_id, outputs, options={}) { output_html += `{% trans "Serial Number" %}: ${output.serial}`; } else { output_html += `{% trans "Quantity" %}: ${output.quantity}`; + if (output.part_detail && output.part_detail.units) { + output_html += ` ${output.part_detail.units} `; + } } var buttons = `
`; @@ -637,6 +640,9 @@ function deleteBuildOutputs(build_id, outputs, options={}) { output_html += `{% trans "Serial Number" %}: ${output.serial}`; } else { output_html += `{% trans "Quantity" %}: ${output.quantity}`; + if (output.part_detail && output.part_detail.units) { + output_html += ` ${output.part_detail.units} `; + } } var buttons = `
`; @@ -1247,6 +1253,9 @@ function loadBuildOutputTable(build_info, options={}) { text = `{% trans "Serial Number" %}: ${row.serial}`; } else { text = `{% trans "Quantity" %}: ${row.quantity}`; + if (row.part_detail && row.part_detail.units) { + text += ` ${row.part_detail.units}`; + } } if (row.batch) { @@ -1748,6 +1757,9 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { text = `{% trans "Serial Number" %}: ${serial}`; } else { text = `{% trans "Quantity" %}: ${row.quantity}`; + if (row.part_detail && row.part_detail.units) { + text += ` ${row.part_detail.units}`; + } } var pk = row.stock_item || row.pk; @@ -1880,6 +1892,14 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { title: '{% trans "Quantity Per" %}', sortable: true, switchable: false, + formatter: function(value, row) { + var text = value; + + if (row.sub_part_detail && row.sub_part_detail.units) { + text += ` ${row.sub_part_detail.units}`; + } + return text; + } }, { field: 'available_stock', @@ -1903,6 +1923,9 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { if (available_stock > 0) { text += `${available_stock}`; + if (row.sub_part_detail && row.sub_part_detail.units) { + text += ` ${row.sub_part_detail.units}`; + } } var icons = ''; @@ -1953,7 +1976,11 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { formatter: function(value, row) { var required = requiredQuantity(row); var allocated = row.consumable ? required : allocatedQuantity(row); - return makeProgressBar(allocated, required); + var progressbar_text = `${allocated} / ${required}`; + if (row.sub_part_detail && row.sub_part_detail.units) { + progressbar_text += ` ${row.sub_part_detail.units}`; + } + return makeProgressBar(allocated, required, {text: progressbar_text}); }, sorter: function(valA, valB, rowA, rowB) { // Custom sorting function for progress bars