Skip to content

Commit

Permalink
Add exception handling for default template creatoin (#8209)
Browse files Browse the repository at this point in the history
  • Loading branch information
SchrodingersGat authored Sep 29, 2024
1 parent 33499d6 commit a71754b
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/backend/InvenTree/report/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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

0 comments on commit a71754b

Please sign in to comment.