From 2c7a4a124659824a607b6e2b62c1b8f371738111 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 30 Jun 2021 23:38:48 +0200 Subject: [PATCH] switching out BASE_CURRENCY --- InvenTree/InvenTree/apps.py | 3 ++- InvenTree/InvenTree/exchange.py | 3 ++- InvenTree/InvenTree/settings.py | 4 ---- InvenTree/InvenTree/tasks.py | 3 ++- InvenTree/InvenTree/views.py | 3 ++- InvenTree/part/views.py | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/InvenTree/InvenTree/apps.py b/InvenTree/InvenTree/apps.py index aeddb714a0..79269d7b74 100644 --- a/InvenTree/InvenTree/apps.py +++ b/InvenTree/InvenTree/apps.py @@ -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 diff --git a/InvenTree/InvenTree/exchange.py b/InvenTree/InvenTree/exchange.py index 0695e69f48..f5c1ad4d48 100644 --- a/InvenTree/InvenTree/exchange.py +++ b/InvenTree/InvenTree/exchange.py @@ -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) diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py index e0bc1ccb95..6c1d52487d 100644 --- a/InvenTree/InvenTree/settings.py +++ b/InvenTree/InvenTree/settings.py @@ -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' diff --git a/InvenTree/InvenTree/tasks.py b/InvenTree/InvenTree/tasks.py index f0fe504072..6397ea72e7 100644 --- a/InvenTree/InvenTree/tasks.py +++ b/InvenTree/InvenTree/tasks.py @@ -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}'") diff --git a/InvenTree/InvenTree/views.py b/InvenTree/InvenTree/views.py index 17caeb872d..9a5e7176a1 100644 --- a/InvenTree/InvenTree/views.py +++ b/InvenTree/InvenTree/views.py @@ -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") diff --git a/InvenTree/part/views.py b/InvenTree/part/views.py index 2f129dd30b..294f89223e 100644 --- a/InvenTree/part/views.py +++ b/InvenTree/part/views.py @@ -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: