InvenTree/InvenTree/common/settings.py

47 lines
930 B
Python
Raw Normal View History

"""
User-configurable settings for the common app
"""
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from moneyed import CURRENCIES
2021-07-01 08:32:07 +00:00
from django.conf import settings
2021-05-27 05:45:38 +00:00
import common.models
def currency_code_default():
"""
Returns the default currency code (or USD if not specified)
"""
2021-06-30 21:36:46 +00:00
code = common.models.InvenTreeSetting.get_setting('INVENTREE_DEFAULT_CURRENCY')
if code not in CURRENCIES:
code = 'USD'
return code
2021-07-01 08:37:16 +00:00
def currency_code_mappings():
2021-07-01 08:32:07 +00:00
"""
Returns the current currency choices
"""
return [(a, CURRENCIES[a].name) for a in settings.CURRENCIES]
2021-07-01 08:32:07 +00:00
2021-07-01 08:41:23 +00:00
def currency_codes():
"""
Returns the current currency codes
"""
return [a for a in settings.CURRENCIES]
def stock_expiry_enabled():
"""
Returns True if the stock expiry feature is enabled
"""
2021-05-27 05:45:38 +00:00
return common.models.InvenTreeSetting.get_setting('STOCK_ENABLE_EXPIRY')