diff --git a/InvenTree/InvenTree/helpers.py b/InvenTree/InvenTree/helpers.py index d71f7d87c7..b5cecf764d 100644 --- a/InvenTree/InvenTree/helpers.py +++ b/InvenTree/InvenTree/helpers.py @@ -439,7 +439,7 @@ def extract_serial_numbers(serials, expected_quantity, next_number: int): # Helper function to check for duplicated numbers def add_sn(sn): if sn in numbers: - errors.append(_('Duplicate serial: {sn}').format(n=n)) + errors.append(_('Duplicate serial: {sn}').format(sn=sn)) else: numbers.append(sn) @@ -504,10 +504,14 @@ def extract_serial_numbers(serials, expected_quantity, next_number: int): errors.append(_("Invalid group: {g}").format(g=group)) # At this point, we assume that the "group" is just a single serial value - # Note: At this point it is treated only as a string elif group: - add_sn(group) + try: + # First attempt to add as an integer value + add_sn(int(group)) + except (ValueError): + # As a backup, add as a string value + add_sn(group) # No valid input group detected else: diff --git a/InvenTree/InvenTree/status.py b/InvenTree/InvenTree/status.py index cc9df701c6..181f431574 100644 --- a/InvenTree/InvenTree/status.py +++ b/InvenTree/InvenTree/status.py @@ -14,6 +14,8 @@ from django_q.monitor import Stat from django.conf import settings +import InvenTree.ready + logger = logging.getLogger("inventree") @@ -56,6 +58,12 @@ def is_email_configured(): configured = True + if InvenTree.ready.isInTestMode(): + return False + + if InvenTree.ready.isImportingData(): + return False + if not settings.EMAIL_HOST: configured = False @@ -89,6 +97,14 @@ def check_system_health(**kwargs): result = True + if InvenTree.ready.isInTestMode(): + # Do not perform further checks if we are running unit tests + return False + + if InvenTree.ready.isImportingData(): + # Do not perform further checks if we are importing data + return False + if not is_worker_running(**kwargs): # pragma: no cover result = False logger.warning(_("Background worker check failed"))