diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index 3defdc3c13..935990e074 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -85,7 +85,7 @@ class BaseInvenTreeSetting(models.Model): # Convert to javascript compatible booleans if cls.validator_is_bool(validator): - value = 'true' if value else 'false' + value = value.lower() # Numerical values remain the same elif cls.validator_is_int(validator): diff --git a/InvenTree/templates/js/translated/table_filters.js b/InvenTree/templates/js/translated/table_filters.js index 930e19313d..9e173a7b37 100644 --- a/InvenTree/templates/js/translated/table_filters.js +++ b/InvenTree/templates/js/translated/table_filters.js @@ -121,7 +121,8 @@ function getAvailableTableFilters(tableKey) { // Filters for the "Stock" table if (tableKey == 'stock') { - return { + + var filters = { active: { type: 'bool', title: '{% trans "Active parts" %}', @@ -147,20 +148,6 @@ function getAvailableTableFilters(tableKey) { title: '{% trans "Depleted" %}', description: '{% trans "Show stock items which are depleted" %}', }, - - {% settings_value "STOCK_ENABLE_EXPIRY" as expiry %} - {% if expiry %} - expired: { - type: 'bool', - title: '{% trans "Expired" %}', - description: '{% trans "Show stock items which have expired" %}', - }, - stale: { - type: 'bool', - title: '{% trans "Stale" %}', - description: '{% trans "Show stock which is close to expiring" %}', - }, - {% endif %} in_stock: { type: 'bool', title: '{% trans "In Stock" %}', @@ -217,6 +204,23 @@ function getAvailableTableFilters(tableKey) { description: '{% trans "Show stock items which have a purchase price set" %}', }, }; + + // Optional filters if stock expiry functionality is enabled + if (global_settings.STOCK_ENABLE_EXPIRY) { + filters.expired = { + type: 'bool', + title: '{% trans "Expired" %}', + description: '{% trans "Show stock items which have expired" %}', + }; + + filters.stale = { + type: 'bool', + title: '{% trans "Stale" %}', + description: '{% trans "Show stock which is close to expiring" %}', + }; + } + + return filters; } // Filters for the 'stock test' table