2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-02 03:30:54 +00:00

Fix bug in loading setting from cache (#5612)

* Fix bug in loading setting from cache

- Need to bring out "cache" key first, otherwise it gets included in the calculated cache key
- Reference: https://github.com/inventree/InvenTree/issues/5586

* Unit test fixes
This commit is contained in:
Oliver
2023-09-25 15:57:33 +10:00
committed by GitHub
parent 200bc5bd3d
commit 87a8755e1b
3 changed files with 14 additions and 4 deletions

View File

@ -450,6 +450,9 @@ class BaseInvenTreeSetting(models.Model):
**cls.get_filters(**kwargs),
}
# Unless otherwise specified, attempt to create the setting
create = kwargs.pop('create', True)
# Perform cache lookup by default
do_cache = kwargs.pop('cache', True)
@ -478,9 +481,6 @@ class BaseInvenTreeSetting(models.Model):
# Setting does not exist! (Try to create it)
if not setting:
# Unless otherwise specified, attempt to create the setting
create = kwargs.pop('create', True)
# Prevent creation of new settings objects when importing data
if InvenTree.ready.isImportingData() or not InvenTree.ready.canAppAccessDatabase(allow_test=True, allow_shell=True):
create = False

View File

@ -15,7 +15,7 @@ def currency_code_default():
from common.models import InvenTreeSetting
try:
code = InvenTreeSetting.get_setting('INVENTREE_DEFAULT_CURRENCY', create=False, cache=False)
code = InvenTreeSetting.get_setting('INVENTREE_DEFAULT_CURRENCY', create=True, cache=True)
except Exception: # pragma: no cover
# Database may not yet be ready, no need to throw an error here
code = ''