Fix call to add_label_context (#7548)

- Remove reference to object_to_print
- Correctly pass model instance
This commit is contained in:
Oliver 2024-07-02 23:05:13 +10:00 committed by GitHub
parent dc3f2011fd
commit 0c293fa896
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 10 deletions

View File

@ -132,9 +132,7 @@ class LabelPrinterBaseDriver(BaseDriver):
item: The item to render the label with
request: The HTTP request object which triggered this print job
"""
label.object_to_print = item
response = self.machine_plugin.render_to_pdf(label, request, **kwargs)
label.object_to_print = None
response = self.machine_plugin.render_to_pdf(label, item, request, **kwargs)
return response
def render_to_pdf_data(
@ -163,9 +161,7 @@ class LabelPrinterBaseDriver(BaseDriver):
item: The item to render the label with
request: The HTTP request object which triggered this print job
"""
label.object_to_print = item
html = self.machine_plugin.render_to_html(label, request, **kwargs)
label.object_to_print = None
html = self.machine_plugin.render_to_html(label, item, request, **kwargs)
return html
def render_to_png(
@ -186,9 +182,7 @@ class LabelPrinterBaseDriver(BaseDriver):
pdf2image_kwargs (dict): Additional keyword arguments to pass to the
[`pdf2image.convert_from_bytes`](https://pdf2image.readthedocs.io/en/latest/reference.html#pdf2image.pdf2image.convert_from_bytes) method (optional)
"""
label.object_to_print = item
png = self.machine_plugin.render_to_png(label, request, **kwargs)
label.object_to_print = None
png = self.machine_plugin.render_to_png(label, item, request, **kwargs)
return png
required_overrides = [[print_label, print_labels]]

View File

@ -409,7 +409,7 @@ class LabelTemplate(TemplateUploadMixin, ReportTemplateBase):
for plugin in plugins:
# Let each plugin add its own context data
plugin.add_label_context(self, self.object_to_print, request, context)
plugin.add_label_context(self, instance, request, context)
return context