diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py
index d893206126..52f38bea18 100644
--- a/InvenTree/common/models.py
+++ b/InvenTree/common/models.py
@@ -242,6 +242,13 @@ class InvenTreeSetting(models.Model):
'validator': bool,
},
+ 'STOCK_GROUP_BY_PART': {
+ 'name': _('Group by Part'),
+ 'description': _('Group stock items by part reference in table views'),
+ 'default': True,
+ 'validator': bool,
+ },
+
'BUILDORDER_REFERENCE_PREFIX': {
'name': _('Build Order Reference Prefix'),
'description': _('Prefix value for build order reference'),
diff --git a/InvenTree/templates/InvenTree/settings/stock.html b/InvenTree/templates/InvenTree/settings/stock.html
index 588f01e0e9..9c82202a02 100644
--- a/InvenTree/templates/InvenTree/settings/stock.html
+++ b/InvenTree/templates/InvenTree/settings/stock.html
@@ -15,11 +15,12 @@
{% include "InvenTree/settings/header.html" %}
- {% include "InvenTree/settings/setting.html" with key="STOCK_ENABLE_EXPIRY" %}
- {% include "InvenTree/settings/setting.html" with key="STOCK_STALE_DAYS" %}
- {% include "InvenTree/settings/setting.html" with key="STOCK_ALLOW_EXPIRED_SALE" %}
- {% include "InvenTree/settings/setting.html" with key="STOCK_ALLOW_EXPIRED_BUILD" %}
- {% include "InvenTree/settings/setting.html" with key="STOCK_OWNERSHIP_CONTROL" %}
+ {% include "InvenTree/settings/setting.html" with key="STOCK_GROUP_BY_PART" icon="fa-layer-group" %}
+ {% include "InvenTree/settings/setting.html" with key="STOCK_ENABLE_EXPIRY" icon="fa-stopwatch" %}
+ {% include "InvenTree/settings/setting.html" with key="STOCK_STALE_DAYS" icon="fa-calendar" %}
+ {% include "InvenTree/settings/setting.html" with key="STOCK_ALLOW_EXPIRED_SALE" icon="fa-truck" %}
+ {% include "InvenTree/settings/setting.html" with key="STOCK_ALLOW_EXPIRED_BUILD" icon="fa-tools" %}
+ {% include "InvenTree/settings/setting.html" with key="STOCK_OWNERSHIP_CONTROL" icon="fa-users" %}
{% endblock %}
diff --git a/InvenTree/templates/js/stock.js b/InvenTree/templates/js/stock.js
index 4ffcc2aee4..f1794f3664 100644
--- a/InvenTree/templates/js/stock.js
+++ b/InvenTree/templates/js/stock.js
@@ -327,11 +327,13 @@ function loadStockTable(table, options) {
url: options.url || "{% url 'api-stock-list' %}",
queryParams: filters,
customSort: customGroupSorter,
- groupBy: true,
name: 'stock',
original: original,
showColumns: true,
+ {% settings_value 'STOCK_GROUP_BY_PART' as group_by_part %}
+ {% if group_by_part %}
groupByField: options.groupByField || 'part',
+ groupBy: true,
groupByFormatter: function(field, id, data) {
var row = data[0];
@@ -363,9 +365,9 @@ function loadStockTable(table, options) {
var packaging = [];
data.forEach(function(item) {
- var pkg = String(item.packaging);
+ var pkg = item.packaging;
- if (!pkg || pkg == '') {
+ if (!pkg) {
pkg = '-';
}
@@ -491,6 +493,7 @@ function loadStockTable(table, options) {
return '';
}
},
+ {% endif %}
columns: [
{
checkbox: true,