Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues made in #7614 #7622

Merged
merged 4 commits into from
Jul 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions src/backend/InvenTree/plugin/builtin/labels/label_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ class InvenTreeLabelSheetPlugin(LabelPrintingMixin, SettingsMixin, InvenTreePlug
}

PrintingOptionsSerializer = LabelPrintingOptionsSerializer
debug = None

def in_debug_mode(self):
"""Check if the plugin is printing in debug mode."""
if self.debug is None:
self.debug = str2bool(self.get_setting('DEBUG'))

def print_labels(
self, label: LabelTemplate, output: LabelOutput, items: list, request, **kwargs
Expand Down Expand Up @@ -149,14 +143,15 @@ def print_labels(
# Render to a single HTML document
html_data = self.wrap_pages(pages, **document_data)

if self.in_debug_mode():
martonmiklos marked this conversation as resolved.
Show resolved Hide resolved
if str2bool(self.get_setting('DEBUG')):
# In debug mode return with the raw HTML
output.output = ContentFile(html_data, 'labels.html')
else:
# Render HTML to PDF
html = weasyprint.HTML(string=html_data)
document = html.render().write_pdf()

output.output = ContentFile(document, 'labels.pdf')
else:
output.output = ContentFile(html_data, 'labels.html')

output.progress = 100
output.complete = True
Expand Down
Loading