diff --git a/src/backend/InvenTree/report/apps.py b/src/backend/InvenTree/report/apps.py index c5c874f79ea..83e29796148 100644 --- a/src/backend/InvenTree/report/apps.py +++ b/src/backend/InvenTree/report/apps.py @@ -125,12 +125,14 @@ def create_default_labels(self): # Read the existing template file data = template_file.open('r').read() - logger.info("Creating new label template: '%s'", template['name']) - - # Create a new entry - report.models.LabelTemplate.objects.create( - **template, template=ContentFile(data, os.path.basename(filename)) - ) + try: + # Create a new entry + report.models.LabelTemplate.objects.create( + **template, template=ContentFile(data, os.path.basename(filename)) + ) + logger.info("Creating new label template: '%s'", template['name']) + except Exception: + pass def create_default_reports(self): """Create default report templates.""" @@ -212,9 +214,11 @@ def create_default_reports(self): # Read the existing template file data = template_file.open('r').read() - logger.info("Creating new report template: '%s'", template['name']) - # Create a new entry - report.models.ReportTemplate.objects.create( - **template, template=ContentFile(data, os.path.basename(filename)) - ) + try: + report.models.ReportTemplate.objects.create( + **template, template=ContentFile(data, os.path.basename(filename)) + ) + logger.info("Created new report template: '%s'", template['name']) + except Exception: + pass