From 5b949b6f60bb296884063cb48b84516e0882a1a7 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 27 Mar 2022 07:45:45 +1100 Subject: [PATCH 001/231] Fix sorting for location column in part table --- InvenTree/templates/js/translated/stock.js | 166 +-------------------- 1 file changed, 1 insertion(+), 165 deletions(-) diff --git a/InvenTree/templates/js/translated/stock.js b/InvenTree/templates/js/translated/stock.js index b7f4162621..ade8bc5a0a 100644 --- a/InvenTree/templates/js/translated/stock.js +++ b/InvenTree/templates/js/translated/stock.js @@ -1770,6 +1770,7 @@ function loadStockTable(table, options) { col = { field: 'location_detail.pathstring', title: '{% trans "Location" %}', + sortName: 'location', formatter: function(value, row) { return locationDetail(row); } @@ -1912,172 +1913,8 @@ function loadStockTable(table, options) { original: original, showColumns: true, columns: columns, - {% if False %} - groupByField: options.groupByField || 'part', - groupBy: grouping, - groupByFormatter: function(field, id, data) { - - var row = data[0]; - - if (field == 'part_detail.full_name') { - - var html = imageHoverIcon(row.part_detail.thumbnail); - - html += row.part_detail.full_name; - html += ` (${data.length} {% trans "items" %})`; - - html += makePartIcons(row.part_detail); - - return html; - } else if (field == 'part_detail.IPN') { - var ipn = row.part_detail.IPN; - - if (ipn) { - return ipn; - } else { - return '-'; - } - } else if (field == 'part_detail.description') { - return row.part_detail.description; - } else if (field == 'packaging') { - var packaging = []; - - data.forEach(function(item) { - var pkg = item.packaging; - - if (!pkg) { - pkg = '-'; - } - - if (!packaging.includes(pkg)) { - packaging.push(pkg); - } - }); - - if (packaging.length > 1) { - return "..."; - } else if (packaging.length == 1) { - return packaging[0]; - } else { - return "-"; - } - } else if (field == 'quantity') { - var stock = 0; - var items = 0; - - data.forEach(function(item) { - stock += parseFloat(item.quantity); - items += 1; - }); - - stock = +stock.toFixed(5); - - return `${stock} (${items} {% trans "items" %})`; - } else if (field == 'status') { - var statii = []; - - data.forEach(function(item) { - var status = String(item.status); - - if (!status || status == '') { - status = '-'; - } - - if (!statii.includes(status)) { - statii.push(status); - } - }); - - // Multiple status codes - if (statii.length > 1) { - return "..."; - } else if (statii.length == 1) { - return stockStatusDisplay(statii[0]); - } else { - return "-"; - } - } else if (field == 'batch') { - var batches = []; - - data.forEach(function(item) { - var batch = item.batch; - - if (!batch || batch == '') { - batch = '-'; - } - - if (!batches.includes(batch)) { - batches.push(batch); - } - }); - - if (batches.length > 1) { - return "" + batches.length + " {% trans 'batches' %}"; - } else if (batches.length == 1) { - if (batches[0]) { - return batches[0]; - } else { - return '-'; - } - } else { - return '-'; - } - } else if (field == 'location_detail.pathstring') { - /* Determine how many locations */ - var locations = []; - - data.forEach(function(item) { - - var detail = locationDetail(item); - - if (!locations.includes(detail)) { - locations.push(detail); - } - }); - - if (locations.length == 1) { - // Single location, easy! - return locations[0]; - } else if (locations.length > 1) { - return "In " + locations.length + " {% trans 'locations' %}"; - } else { - return "{% trans 'Undefined location' %}"; - } - } else if (field == 'notes') { - var notes = []; - - data.forEach(function(item) { - var note = item.notes; - - if (!note || note == '') { - note = '-'; - } - - if (!notes.includes(note)) { - notes.push(note); - } - }); - - if (notes.length > 1) { - return '...'; - } else if (notes.length == 1) { - return notes[0] || '-'; - } else { - return '-'; - } - } else { - return ''; - } - }, - {% endif %} }); - /* - if (options.buttons) { - linkButtonsToSelection(table, options.buttons); - } - */ - var buttons = [ '#stock-print-options', '#stock-options', @@ -2092,7 +1929,6 @@ function loadStockTable(table, options) { buttons, ); - function stockAdjustment(action) { var items = $(table).bootstrapTable('getSelections'); From ce323d80ea4aadd1bbf56712450eccaae3e5e812 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 27 Mar 2022 20:29:59 +1100 Subject: [PATCH 002/231] Fix floating point issues --- InvenTree/templates/js/translated/build.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/InvenTree/templates/js/translated/build.js b/InvenTree/templates/js/translated/build.js index 46f7f32e42..fd88144f8b 100644 --- a/InvenTree/templates/js/translated/build.js +++ b/InvenTree/templates/js/translated/build.js @@ -1025,9 +1025,10 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { } // Store the required quantity in the row data - row.required = quantity; + // Prevent weird rounding issues + row.required = parseFloat(quantity.toFixed(15)); - return quantity; + return row.required; } function sumAllocations(row) { @@ -1043,9 +1044,9 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { quantity += item.quantity; }); - row.allocated = quantity; + row.allocated = parseFloat(quantity.toFixed(15)); - return quantity; + return row.allocated; } function setupCallbacks() { From ab7eda9d2c03cb96ac44d434c0d0bd640d40150c Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 27 Mar 2022 21:04:14 +1100 Subject: [PATCH 003/231] Add new button to navbar --- InvenTree/templates/navbar.html | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/InvenTree/templates/navbar.html b/InvenTree/templates/navbar.html index 126376a7dc..898171a552 100644 --- a/InvenTree/templates/navbar.html +++ b/InvenTree/templates/navbar.html @@ -89,9 +89,16 @@ {% endif %} {% include "search_form.html" %} From f2d053719885f8a6bc3ea0220aedb3e4013f067f Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 24 Apr 2022 15:12:03 +0200 Subject: [PATCH 173/231] set navbar message via config file --- InvenTree/config_template.yaml | 2 ++ InvenTree/templates/navbar.html | 9 +++++++-- InvenTree/templates/navbar_demo.html | 12 ------------ 3 files changed, 9 insertions(+), 14 deletions(-) delete mode 100644 InvenTree/templates/navbar_demo.html diff --git a/InvenTree/config_template.yaml b/InvenTree/config_template.yaml index 862d062787..1067910629 100644 --- a/InvenTree/config_template.yaml +++ b/InvenTree/config_template.yaml @@ -189,3 +189,5 @@ static_root: '/home/inventree/data/static' # customize: # login_message: | # InvenTree demo instance - Click here for login details +# navbar_message: | +# InvenTree demo mode diff --git a/InvenTree/templates/navbar.html b/InvenTree/templates/navbar.html index 3af7fe481f..f873d6f84c 100644 --- a/InvenTree/templates/navbar.html +++ b/InvenTree/templates/navbar.html @@ -8,6 +8,7 @@ {% navigation_enabled as plugin_nav %} {% inventree_demo_mode as demo %} {% inventree_show_about user as show_about %} +{% inventree_customize 'navbar_message' as navbar_message %}