diff --git a/InvenTree/report/models.py b/InvenTree/report/models.py index ba8672f8c1..c2b5d729fe 100644 --- a/InvenTree/report/models.py +++ b/InvenTree/report/models.py @@ -175,6 +175,10 @@ class ReportTemplateBase(ReportBase): context = self.get_context_data(request) + context['media'] = settings.MEDIA_ROOT + + context['report_name'] = self.name + context['report_description'] = self.description context['request'] = request context['user'] = request.user context['datetime'] = datetime.datetime.now() @@ -194,8 +198,16 @@ class ReportTemplateBase(ReportBase): raise ValidationError("Enable LaTeX support in config.yaml") elif self.extension in ['.htm', '.html']: # Render HTML template to PDF - wp = WeasyprintReportMixin(request, self.template_name, **kwargs) - return wp.render_to_response(context, **kwargs) + wp = WeasyprintReportMixin( + request, + self.template_name, + base_url=request.build_absolute_uri("/"), + presentational_hints=True, + **kwargs) + + return wp.render_to_response( + context, + **kwargs) enabled = models.BooleanField( default=True, diff --git a/InvenTree/templates/js/report.js b/InvenTree/templates/js/report.js index da84433bac..6e47706917 100644 --- a/InvenTree/templates/js/report.js +++ b/InvenTree/templates/js/report.js @@ -10,6 +10,15 @@ function selectTestReport(reports, items, options={}) { * (via AJAX) from the server. */ + // If there is only a single report available, just print! + if (reports.length == 1) { + if (options.success) { + options.success(reports[0].pk); + } + + return; + } + var modal = options.modal || '#modal-form'; var report_list = makeOptionsList(