diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py index 5cf0b0c544..f0a3312b39 100644 --- a/InvenTree/InvenTree/settings.py +++ b/InvenTree/InvenTree/settings.py @@ -513,9 +513,7 @@ CURRENCIES = CONFIG.get( ], ) -BASE_CURRENCY = CONFIG.get('base_currency', 'USD') - -EXCHANGE_BACKEND = 'InvenTree.exchange.InvenTreeManualExchangeBackend' +EXCHANGE_BACKEND = 'InvenTree.exchange.ExchangeRateHostBackend' # Extract email settings from the config file email_config = CONFIG.get('email', {}) diff --git a/InvenTree/InvenTree/tasks.py b/InvenTree/InvenTree/tasks.py index b81b4e6de4..ad33232fe0 100644 --- a/InvenTree/InvenTree/tasks.py +++ b/InvenTree/InvenTree/tasks.py @@ -169,22 +169,19 @@ def update_exchange_rates(): try: import common.models from django.conf import settings - from djmoney.contrib.exchange.backends import FixerBackend + from InvenTree.exchange import ExchangeRateHostBackend except AppRegistryNotReady: # Apps not yet loaded! return - fixer_api_key = common.models.InvenTreeSetting.get_setting('INVENTREE_FIXER_API_KEY', '').strip() - - if not fixer_api_key: - # API key not provided - return - - backend = FixerBackend(access_key=fixer_api_key) + backend = ExchangeRateHostBackend() + print(f"Updating exchange rates from {backend.url}") currencies = ','.join(settings.CURRENCIES) - base = settings.BASE_CURRENCY + base = common.models.InvenTreeSetting.get_setting('INVENTREE_DEFAULT_CURRENCY') + + print(f"Using base currency '{base}'") backend.update_rates(base_currency=base, symbols=currencies) diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index e499e9b801..99712b2a93 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -87,12 +87,6 @@ class InvenTreeSetting(models.Model): 'choices': djmoney.settings.CURRENCY_CHOICES, }, - 'INVENTREE_FIXER_API_KEY': { - 'name': _('fixer.io API key'), - 'description': _('API key for fixer.io currency conversion service'), - 'default': '', - }, - 'INVENTREE_DOWNLOAD_FROM_URL': { 'name': _('Download from URL'), 'description': _('Allow download of remote images and files from external URL'), diff --git a/InvenTree/templates/InvenTree/settings/global.html b/InvenTree/templates/InvenTree/settings/global.html index 5c5dccfb2a..a0347490d0 100644 --- a/InvenTree/templates/InvenTree/settings/global.html +++ b/InvenTree/templates/InvenTree/settings/global.html @@ -20,7 +20,6 @@ {% include "InvenTree/settings/setting.html" with key="INVENTREE_BASE_URL" icon="fa-globe" %} {% include "InvenTree/settings/setting.html" with key="INVENTREE_COMPANY_NAME" icon="fa-building" %} {% include "InvenTree/settings/setting.html" with key="INVENTREE_DEFAULT_CURRENCY" icon="fa-dollar-sign" %} - {% include "InvenTree/settings/setting.html" with key="INVENTREE_FIXER_API_KEY" icon="fa-key" %} {% include "InvenTree/settings/setting.html" with key="INVENTREE_DOWNLOAD_FROM_URL" icon="fa-cloud-download-alt" %}