diff --git a/docs/docs/report/context_variables.md b/docs/docs/report/context_variables.md
index 10180a0504..e6fe9bb698 100644
--- a/docs/docs/report/context_variables.md
+++ b/docs/docs/report/context_variables.md
@@ -16,7 +16,6 @@ In addition to the model-specific context variables, the following global contex
| base_url | The base URL for the InvenTree instance |
| date | Current date, represented as a Python datetime.date object |
| datetime | Current datetime, represented as a Python datetime object |
-| request | The Django request object associated with the printing process |
| template | The report template instance which is being rendered against |
| template_description | Description of the report template |
| template_name | Name of the report template |
diff --git a/src/backend/InvenTree/plugin/base/label/mixins.py b/src/backend/InvenTree/plugin/base/label/mixins.py
index 68236ec29f..a60c1b0d71 100644
--- a/src/backend/InvenTree/plugin/base/label/mixins.py
+++ b/src/backend/InvenTree/plugin/base/label/mixins.py
@@ -147,6 +147,9 @@ class LabelPrintingMixin:
N = len(items)
+ if N <= 0:
+ raise ValidationError(_('No items provided to print'))
+
# Generate a label output for each provided item
for item in items:
context = label.get_context(item, request)
@@ -177,9 +180,13 @@ class LabelPrintingMixin:
self.print_label(**print_args)
else:
# Offload the print task to the background worker
- # Exclude the 'pdf_file' object - cannot be pickled
- kwargs.pop('pdf_file', None)
+ # Exclude the 'pdf_file' object - cannot be pickled
+ print_args.pop('pdf_file', None)
+
+ # Exclude the 'context' object - cannot be pickled
+ print_args.pop('context', None)
+
offload_task(plugin_label.print_label, self.plugin_slug(), **print_args)
# Update the progress of the print job
diff --git a/src/backend/InvenTree/report/models.py b/src/backend/InvenTree/report/models.py
index 053e6cdaeb..05584b5588 100644
--- a/src/backend/InvenTree/report/models.py
+++ b/src/backend/InvenTree/report/models.py
@@ -246,7 +246,6 @@ class ReportTemplateBase(MetadataMixin, InvenTree.models.InvenTreeModel):
'base_url': get_base_url(request=request),
'date': InvenTree.helpers.current_date(),
'datetime': InvenTree.helpers.current_time(),
- 'request': request,
'template': self,
'template_description': self.description,
'template_name': self.name,
diff --git a/src/backend/InvenTree/stock/models.py b/src/backend/InvenTree/stock/models.py
index 17a4385a39..f1787fb34f 100644
--- a/src/backend/InvenTree/stock/models.py
+++ b/src/backend/InvenTree/stock/models.py
@@ -2158,7 +2158,7 @@ class StockItem(
def testResultList(self, **kwargs):
"""Return a list of test-result objects for this StockItem."""
- return self.testResultMap(**kwargs).values()
+ return list(self.testResultMap(**kwargs).values())
def requiredTestStatus(self):
"""Return the status of the tests required for this StockItem.
diff --git a/src/frontend/src/components/buttons/PrintingActions.tsx b/src/frontend/src/components/buttons/PrintingActions.tsx
index 81c5d8ddd6..3f14e49eeb 100644
--- a/src/frontend/src/components/buttons/PrintingActions.tsx
+++ b/src/frontend/src/components/buttons/PrintingActions.tsx
@@ -15,11 +15,13 @@ import { ActionDropdown } from '../items/ActionDropdown';
export function PrintingActions({
items,
+ hidden,
enableLabels,
enableReports,
modelType
}: {
items: number[];
+ hidden?: boolean;
enableLabels?: boolean;
enableReports?: boolean;
modelType?: ModelType;
@@ -79,8 +81,6 @@ export function PrintingActions({
mixin: 'labels'
},
onValueChange: (value: string, record?: any) => {
- console.log('onValueChange:', value, record);
-
if (record?.key && record?.key != pluginKey) {
setPluginKey(record.key);
}
@@ -100,6 +100,7 @@ export function PrintingActions({
},
successMessage: t`Label printing completed successfully`,
onFormSuccess: (response: any) => {
+ setPluginKey('');
if (!response.complete) {
// TODO: Periodically check for completion (requires server-side changes)
notifications.show({
@@ -164,28 +165,30 @@ export function PrintingActions({
}
return (
- <>
- {reportModal.modal}
- {labelModal.modal}
- }
- disabled={!enabled}
- actions={[
- {
- name: t`Print Labels`,
- icon: ,
- onClick: () => labelModal.open(),
- hidden: !enableLabels
- },
- {
- name: t`Print Reports`,
- icon: ,
- onClick: () => reportModal.open(),
- hidden: !enableReports
- }
- ]}
- />
- >
+ !hidden && (
+ <>
+ {reportModal.modal}
+ {labelModal.modal}
+ }
+ disabled={!enabled}
+ actions={[
+ {
+ name: t`Print Labels`,
+ icon: ,
+ onClick: () => labelModal.open(),
+ hidden: !enableLabels
+ },
+ {
+ name: t`Print Reports`,
+ icon: ,
+ onClick: () => reportModal.open(),
+ hidden: !enableReports
+ }
+ ]}
+ />
+ >
+ )
);
}
diff --git a/src/frontend/src/components/forms/ApiForm.tsx b/src/frontend/src/components/forms/ApiForm.tsx
index 2317f3e8e0..c9b660174e 100644
--- a/src/frontend/src/components/forms/ApiForm.tsx
+++ b/src/frontend/src/components/forms/ApiForm.tsx
@@ -144,10 +144,12 @@ export function OptionsApiForm({
if (error.response) {
invalidResponse(error.response.status);
} else {
+ notifications.hide('form-error');
notifications.show({
title: t`Form Error`,
message: error.message,
- color: 'red'
+ color: 'red',
+ id: 'form-error'
});
}
return false;
diff --git a/src/frontend/src/pages/stock/LocationDetail.tsx b/src/frontend/src/pages/stock/LocationDetail.tsx
index e3c83dea6d..462faa7075 100644
--- a/src/frontend/src/pages/stock/LocationDetail.tsx
+++ b/src/frontend/src/pages/stock/LocationDetail.tsx
@@ -294,6 +294,7 @@ export default function Stock() {
,