From 213d6550d3d81f011e5f16f13da9986ab0774858 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 5 Jan 2021 00:54:05 +1100 Subject: [PATCH] Add new setock settings --- InvenTree/common/models.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index fa1d4dc5c9..ab1e7cf049 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -139,6 +139,20 @@ class InvenTreeSetting(models.Model): 'validator': bool, }, + 'STOCK_ALLOW_EXPIRED_SALE': { + 'name': _('Sell Expired Stock'), + 'description': _('Allow sale of expired stock'), + 'default': False, + 'validator': bool, + }, + + 'STOCK_ALLOW_EXPIRED_BUILD': { + 'name': _('Build Expired Stock'), + 'description': _('Allow building with expired stock'), + 'default': False, + 'validator': bool, + }, + 'BUILDORDER_REFERENCE_PREFIX': { 'name': _('Build Order Reference Prefix'), 'description': _('Prefix value for build order reference'), @@ -479,6 +493,19 @@ class InvenTreeSetting(models.Model): return InvenTree.helpers.str2bool(self.value) + def is_int(self): + """ + Check if the setting is required to be an integer value: + + - int / 'int' = any integer value + - 'pos' / 'positive' = any positive integer value (including zero) + - 'neg' / 'negative' = any negative integer value (including zero) + """ + + valiator = InvenTreeSetting.get_setting_validator(self.key) + + return validator in [int, 'int', 'pos', 'positive', 'neg', 'negative'] + class PriceBreak(models.Model): """