mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-04 07:05:41 +00:00 
			
		
		
		
	Add exception handling for default template creatoin (#8209)
This commit is contained in:
		@@ -125,12 +125,14 @@ class ReportConfig(AppConfig):
 | 
				
			|||||||
            # Read the existing template file
 | 
					            # Read the existing template file
 | 
				
			||||||
            data = template_file.open('r').read()
 | 
					            data = template_file.open('r').read()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            logger.info("Creating new label template: '%s'", template['name'])
 | 
					            try:
 | 
				
			||||||
 | 
					                # Create a new entry
 | 
				
			||||||
            # Create a new entry
 | 
					                report.models.LabelTemplate.objects.create(
 | 
				
			||||||
            report.models.LabelTemplate.objects.create(
 | 
					                    **template, template=ContentFile(data, os.path.basename(filename))
 | 
				
			||||||
                **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):
 | 
					    def create_default_reports(self):
 | 
				
			||||||
        """Create default report templates."""
 | 
					        """Create default report templates."""
 | 
				
			||||||
@@ -212,9 +214,11 @@ class ReportConfig(AppConfig):
 | 
				
			|||||||
            # Read the existing template file
 | 
					            # Read the existing template file
 | 
				
			||||||
            data = template_file.open('r').read()
 | 
					            data = template_file.open('r').read()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            logger.info("Creating new report template: '%s'", template['name'])
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            # Create a new entry
 | 
					            # Create a new entry
 | 
				
			||||||
            report.models.ReportTemplate.objects.create(
 | 
					            try:
 | 
				
			||||||
                **template, template=ContentFile(data, os.path.basename(filename))
 | 
					                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
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user