From 126e42a02284202e04ca0ef6cb5653a626e29ca4 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 6 Jun 2020 08:47:06 +1000 Subject: [PATCH] Add "IPN" column to stock list table --- .../InvenTree/static/script/inventree/tables.js | 2 -- InvenTree/build/templates/build/build_base.html | 4 ---- .../templates/company/supplier_part_stock.html | 5 ----- InvenTree/part/serializers.py | 3 +++ InvenTree/part/templates/part/part_app_base.html | 6 ------ InvenTree/stock/templates/stock/stock_app_base.html | 5 ----- InvenTree/templates/js/stock.html | 13 +++++++++++++ 7 files changed, 16 insertions(+), 22 deletions(-) diff --git a/InvenTree/InvenTree/static/script/inventree/tables.js b/InvenTree/InvenTree/static/script/inventree/tables.js index 0280b7cdd4..e319aa8440 100644 --- a/InvenTree/InvenTree/static/script/inventree/tables.js +++ b/InvenTree/InvenTree/static/script/inventree/tables.js @@ -107,8 +107,6 @@ $.fn.inventreeTable = function(options) { function customGroupSorter(sortName, sortOrder, sortData) { - console.log('got here'); - var order = sortOrder === 'desc' ? -1 : 1; sortData.sort(function(a, b) { diff --git a/InvenTree/build/templates/build/build_base.html b/InvenTree/build/templates/build/build_base.html index 8f5ec62663..fb84b467cf 100644 --- a/InvenTree/build/templates/build/build_base.html +++ b/InvenTree/build/templates/build/build_base.html @@ -111,10 +111,6 @@ src="{% static 'img/blank_image.png' %}" {% endblock %} -{% block js_load %} - -{% endblock %} - {% block js_ready %} $("#build-edit").click(function () { diff --git a/InvenTree/company/templates/company/supplier_part_stock.html b/InvenTree/company/templates/company/supplier_part_stock.html index 9f3157c0b5..b14f702504 100644 --- a/InvenTree/company/templates/company/supplier_part_stock.html +++ b/InvenTree/company/templates/company/supplier_part_stock.html @@ -14,11 +14,6 @@ {% endblock %} -{% block js_load %} -{{ block.super }} - -{% endblock %} - {% block js_ready %} {{ block.super }} diff --git a/InvenTree/part/serializers.py b/InvenTree/part/serializers.py index 4efe1fa613..f625a02c41 100644 --- a/InvenTree/part/serializers.py +++ b/InvenTree/part/serializers.py @@ -103,6 +103,9 @@ class PartBriefSerializer(InvenTreeModelSerializer): model = Part fields = [ 'pk', + 'IPN', + 'name', + 'revision', 'full_name', 'description', 'thumbnail', diff --git a/InvenTree/part/templates/part/part_app_base.html b/InvenTree/part/templates/part/part_app_base.html index 6956f61af4..3697fd136c 100644 --- a/InvenTree/part/templates/part/part_app_base.html +++ b/InvenTree/part/templates/part/part_app_base.html @@ -26,12 +26,6 @@ InvenTree | {% trans "Part List" %} {% endblock %} -{% block js_load %} -{{ block.super }} - - -{% endblock %} - {% block js_ready %} {{ block.super }} diff --git a/InvenTree/stock/templates/stock/stock_app_base.html b/InvenTree/stock/templates/stock/stock_app_base.html index 7f31ac21b0..9898df2040 100644 --- a/InvenTree/stock/templates/stock/stock_app_base.html +++ b/InvenTree/stock/templates/stock/stock_app_base.html @@ -22,11 +22,6 @@ InvenTree | Stock {% endif %} {% endblock %} -{% block js_load %} -{{ block.super }} - -{% endblock %} - {% block js_ready %} {{ block.super }} loadTree("{% url 'api-stock-tree' %}", diff --git a/InvenTree/templates/js/stock.html b/InvenTree/templates/js/stock.html index 14be8d9afe..789667b006 100644 --- a/InvenTree/templates/js/stock.html +++ b/InvenTree/templates/js/stock.html @@ -262,6 +262,7 @@ function loadStockTable(table, options) { customSort: customGroupSorter, groupBy: true, original: original, + showColumns: true, groupByField: options.groupByField || 'part', groupByFormatter: function(field, id, data) { @@ -273,6 +274,9 @@ function loadStockTable(table, options) { return imageHoverIcon(row.part_detail.thumbnail) + name + ' (' + data.length + ' items)'; } + else if (field == 'IPN') { + return row.part_detail.IPN; + } else if (field == 'part_description') { return row.part_detail.description; } @@ -403,6 +407,15 @@ function loadStockTable(table, options) { field: 'pk', title: 'ID', visible: false, + switchable: false, + }, + { + field: 'IPN', + title: 'IPN', + sortable: true, + formatter: function(value, row, index, field) { + return row.part_detail.IPN; + }, }, { field: 'part_name',