mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
switching out BASE_CURRENCY
This commit is contained in:
parent
92645d790b
commit
2c7a4a1246
@ -66,10 +66,11 @@ class InvenTreeConfig(AppConfig):
|
||||
from djmoney.contrib.exchange.models import ExchangeBackend
|
||||
from datetime import datetime, timedelta
|
||||
from InvenTree.tasks import update_exchange_rates
|
||||
from common.settings import currency_code_default
|
||||
except AppRegistryNotReady:
|
||||
pass
|
||||
|
||||
base_currency = settings.BASE_CURRENCY
|
||||
base_currency = currency_code_default()
|
||||
|
||||
update = False
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
from django.conf import settings as inventree_settings
|
||||
from common.settings import currency_code_default
|
||||
|
||||
from djmoney.contrib.exchange.backends.base import SimpleExchangeBackend
|
||||
|
||||
@ -22,7 +23,7 @@ class InvenTreeExchange(SimpleExchangeBackend):
|
||||
return {
|
||||
}
|
||||
|
||||
def update_rates(self, base_currency=inventree_settings.BASE_CURRENCY):
|
||||
def update_rates(self, base_currency=currency_code_default()):
|
||||
|
||||
symbols = ','.join(inventree_settings.CURRENCIES)
|
||||
|
||||
|
@ -522,10 +522,6 @@ for currency in CURRENCIES:
|
||||
print(f"Currency code '{currency}' is not supported")
|
||||
sys.exit(1)
|
||||
|
||||
BASE_CURRENCY = get_setting(
|
||||
'INVENTREE_BASE_CURRENCY',
|
||||
CONFIG.get('base_currency', 'USD')
|
||||
)
|
||||
|
||||
# Custom currency exchange backend
|
||||
EXCHANGE_BACKEND = 'InvenTree.exchange.InvenTreeExchange'
|
||||
|
@ -171,6 +171,7 @@ def update_exchange_rates():
|
||||
from InvenTree.exchange import InvenTreeExchange
|
||||
from djmoney.contrib.exchange.models import ExchangeBackend, Rate
|
||||
from django.conf import settings
|
||||
from common.settings import currency_code_default
|
||||
except AppRegistryNotReady:
|
||||
# Apps not yet loaded!
|
||||
logger.info("Could not perform 'update_exchange_rates' - App registry not ready")
|
||||
@ -192,7 +193,7 @@ def update_exchange_rates():
|
||||
backend = InvenTreeExchange()
|
||||
print(f"Updating exchange rates from {backend.url}")
|
||||
|
||||
base = settings.BASE_CURRENCY
|
||||
base = currency_code_default()
|
||||
|
||||
print(f"Using base currency '{base}'")
|
||||
|
||||
|
@ -21,6 +21,7 @@ from django.views.generic import ListView, DetailView, CreateView, FormView, Del
|
||||
from django.views.generic.base import RedirectView, TemplateView
|
||||
|
||||
from djmoney.contrib.exchange.models import ExchangeBackend, Rate
|
||||
from common.settings import currency_code_default
|
||||
|
||||
from part.models import Part, PartCategory
|
||||
from stock.models import StockLocation, StockItem
|
||||
@ -820,7 +821,7 @@ class CurrencySettingsView(TemplateView):
|
||||
ctx = super().get_context_data(**kwargs).copy()
|
||||
|
||||
ctx['settings'] = InvenTreeSetting.objects.all().order_by('key')
|
||||
ctx["base_currency"] = settings.BASE_CURRENCY
|
||||
ctx["base_currency"] = currency_code_default()
|
||||
ctx["currencies"] = settings.CURRENCIES
|
||||
|
||||
ctx["rates"] = Rate.objects.filter(backend="InvenTreeExchange")
|
||||
|
@ -2949,7 +2949,7 @@ class PartSalePriceBreakCreate(AjaxCreateView):
|
||||
|
||||
initials['part'] = self.get_part()
|
||||
|
||||
default_currency = settings.BASE_CURRENCY
|
||||
default_currency = inventree_settings.currency_code_default()
|
||||
currency = CURRENCIES.get(default_currency, None)
|
||||
|
||||
if currency is not None:
|
||||
|
Loading…
Reference in New Issue
Block a user