From 36d669d70d5053119c37c634155c56cb2f1f0a15 Mon Sep 17 00:00:00 2001
From: Oliver <oliver.henry.walters@gmail.com>
Date: Mon, 31 Jul 2023 10:07:12 +1000
Subject: [PATCH] Fix for label printing plugins (#5371)

- Don't pass pdf_file data to background process
- pre-rendered template data cannot be pickled
---
 InvenTree/plugin/base/label/mixins.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/InvenTree/plugin/base/label/mixins.py b/InvenTree/plugin/base/label/mixins.py
index 0186e69f57..a9fc619f72 100644
--- a/InvenTree/plugin/base/label/mixins.py
+++ b/InvenTree/plugin/base/label/mixins.py
@@ -116,6 +116,8 @@ class LabelPrintingMixin:
                 self.print_label(**print_args)
             else:
                 # Non-blocking print job
+
+                # Offload the print job to a background worker
                 self.offload_label(**print_args)
 
         # Return a JSON response to the user
@@ -151,6 +153,9 @@ class LabelPrintingMixin:
         Offloads a call to the 'print_label' method (of this plugin) to a background worker.
         """
 
+        # Exclude the 'pdf_file' object - cannot be pickled
+        kwargs.pop('pdf_file', None)
+
         offload_task(
             plugin_label.print_label,
             self.plugin_slug(),