2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-29 20:16:44 +00:00

switching out BASE_CURRENCY

This commit is contained in:
Matthias 2021-06-30 23:38:48 +02:00
parent 92645d790b
commit 2c7a4a1246
6 changed files with 9 additions and 9 deletions

View File

@ -66,10 +66,11 @@ class InvenTreeConfig(AppConfig):
from djmoney.contrib.exchange.models import ExchangeBackend from djmoney.contrib.exchange.models import ExchangeBackend
from datetime import datetime, timedelta from datetime import datetime, timedelta
from InvenTree.tasks import update_exchange_rates from InvenTree.tasks import update_exchange_rates
from common.settings import currency_code_default
except AppRegistryNotReady: except AppRegistryNotReady:
pass pass
base_currency = settings.BASE_CURRENCY base_currency = currency_code_default()
update = False update = False

View File

@ -1,4 +1,5 @@
from django.conf import settings as inventree_settings from django.conf import settings as inventree_settings
from common.settings import currency_code_default
from djmoney.contrib.exchange.backends.base import SimpleExchangeBackend from djmoney.contrib.exchange.backends.base import SimpleExchangeBackend
@ -22,7 +23,7 @@ class InvenTreeExchange(SimpleExchangeBackend):
return { 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) symbols = ','.join(inventree_settings.CURRENCIES)

View File

@ -522,10 +522,6 @@ for currency in CURRENCIES:
print(f"Currency code '{currency}' is not supported") print(f"Currency code '{currency}' is not supported")
sys.exit(1) sys.exit(1)
BASE_CURRENCY = get_setting(
'INVENTREE_BASE_CURRENCY',
CONFIG.get('base_currency', 'USD')
)
# Custom currency exchange backend # Custom currency exchange backend
EXCHANGE_BACKEND = 'InvenTree.exchange.InvenTreeExchange' EXCHANGE_BACKEND = 'InvenTree.exchange.InvenTreeExchange'

View File

@ -171,6 +171,7 @@ def update_exchange_rates():
from InvenTree.exchange import InvenTreeExchange from InvenTree.exchange import InvenTreeExchange
from djmoney.contrib.exchange.models import ExchangeBackend, Rate from djmoney.contrib.exchange.models import ExchangeBackend, Rate
from django.conf import settings from django.conf import settings
from common.settings import currency_code_default
except AppRegistryNotReady: except AppRegistryNotReady:
# Apps not yet loaded! # Apps not yet loaded!
logger.info("Could not perform 'update_exchange_rates' - App registry not ready") logger.info("Could not perform 'update_exchange_rates' - App registry not ready")
@ -192,7 +193,7 @@ def update_exchange_rates():
backend = InvenTreeExchange() backend = InvenTreeExchange()
print(f"Updating exchange rates from {backend.url}") print(f"Updating exchange rates from {backend.url}")
base = settings.BASE_CURRENCY base = currency_code_default()
print(f"Using base currency '{base}'") print(f"Using base currency '{base}'")

View File

@ -21,6 +21,7 @@ from django.views.generic import ListView, DetailView, CreateView, FormView, Del
from django.views.generic.base import RedirectView, TemplateView from django.views.generic.base import RedirectView, TemplateView
from djmoney.contrib.exchange.models import ExchangeBackend, Rate from djmoney.contrib.exchange.models import ExchangeBackend, Rate
from common.settings import currency_code_default
from part.models import Part, PartCategory from part.models import Part, PartCategory
from stock.models import StockLocation, StockItem from stock.models import StockLocation, StockItem
@ -820,7 +821,7 @@ class CurrencySettingsView(TemplateView):
ctx = super().get_context_data(**kwargs).copy() ctx = super().get_context_data(**kwargs).copy()
ctx['settings'] = InvenTreeSetting.objects.all().order_by('key') 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["currencies"] = settings.CURRENCIES
ctx["rates"] = Rate.objects.filter(backend="InvenTreeExchange") ctx["rates"] = Rate.objects.filter(backend="InvenTreeExchange")

View File

@ -2949,7 +2949,7 @@ class PartSalePriceBreakCreate(AjaxCreateView):
initials['part'] = self.get_part() initials['part'] = self.get_part()
default_currency = settings.BASE_CURRENCY default_currency = inventree_settings.currency_code_default()
currency = CURRENCIES.get(default_currency, None) currency = CURRENCIES.get(default_currency, None)
if currency is not None: if currency is not None: