Fix table_filters.js

This commit is contained in:
Oliver 2021-07-29 11:52:50 +10:00
parent a222efda33
commit 28bf5bfdbc
2 changed files with 20 additions and 16 deletions

View File

@ -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):

View File

@ -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