diff --git a/InvenTree/InvenTree/apps.py b/InvenTree/InvenTree/apps.py index 3b96266a8b..c515600247 100644 --- a/InvenTree/InvenTree/apps.py +++ b/InvenTree/InvenTree/apps.py @@ -9,7 +9,7 @@ from django.conf import settings from django.contrib.auth import get_user_model from django.core.exceptions import AppRegistryNotReady from django.db import transaction -from django.db.utils import IntegrityError +from django.db.utils import IntegrityError, OperationalError import InvenTree.conversion import InvenTree.tasks @@ -159,6 +159,8 @@ class InvenTreeConfig(AppConfig): if update: try: update_exchange_rates() + except OperationalError: + logger.warning("Could not update exchange rates - database not ready") except Exception as e: logger.error(f"Error updating exchange rates: {e} ({type(e)})") diff --git a/InvenTree/InvenTree/tasks.py b/InvenTree/InvenTree/tasks.py index 9c57a881c9..37e891f062 100644 --- a/InvenTree/InvenTree/tasks.py +++ b/InvenTree/InvenTree/tasks.py @@ -520,6 +520,8 @@ def update_exchange_rates(): # Remove any exchange rates which are not in the provided currencies Rate.objects.filter(backend="InvenTreeExchange").exclude(currency__in=currency_codes()).delete() + except OperationalError: + logger.warning("Could not update exchange rates - database not ready") except Exception as e: # pragma: no cover logger.error(f"Error updating exchange rates: {e} ({type(e)})")