2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-14 11:15:26 +00:00

Label printing fix (#489)

* Add check for modern label printing interface

* Update getLabelTemplates

* Fix typo

* Refactor / simplify

* Revert parameter type

* Update version number and release notes

* Refactor label printing function

- Will require some cleanup in the future
- Still needs testing

* Fix for modern printing

* Typo fix
This commit is contained in:
Oliver
2024-05-12 20:41:02 +10:00
committed by GitHub
parent 91cb24c74c
commit 3c0bca276d
13 changed files with 171 additions and 77 deletions

View File

@ -129,6 +129,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
selectAndPrintLabel(
context,
labels,
widget.part.pk,
"part",
"part=${widget.part.pk}"
);
@ -248,9 +249,16 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
allowLabelPrinting &= api.supportsMixin("labels");
if (allowLabelPrinting) {
_labels = await getLabelTemplates("part", {
"part": widget.part.pk.toString(),
});
String model_type = api.supportsModenLabelPrinting ? InvenTreePart().MODEL_TYPE : "part";
String item_key = api.supportsModenLabelPrinting ? "items" : "part";
_labels = await getLabelTemplates(
model_type,
{
item_key: widget.part.pk.toString()
}
);
}
if (mounted) {

View File

@ -193,6 +193,7 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
selectAndPrintLabel(
context,
labels,
widget.location!.pk,
"location",
"location=${widget.location!.pk}"
);
@ -247,9 +248,16 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
if (allowLabelPrinting) {
if (widget.location != null) {
_labels = await getLabelTemplates("location", {
"location": widget.location!.pk.toString()
});
String model_type = api.supportsModenLabelPrinting ? InvenTreeStockLocation().MODEL_TYPE : "location";
String item_key = api.supportsModenLabelPrinting ? "items" : "location";
_labels = await getLabelTemplates(
model_type,
{
item_key: widget.location!.pk.toString()
}
);
}
}

View File

@ -138,6 +138,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
selectAndPrintLabel(
context,
labels,
widget.item.pk,
"stock",
"item=${widget.item.pk}"
);
@ -264,10 +265,17 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
// Request information on labels available for this stock item
if (allowLabelPrinting) {
String model_type = api.supportsModenLabelPrinting ? InvenTreeStockLocation().MODEL_TYPE : "stock";
String item_key = api.supportsModenLabelPrinting ? "items" : "item";
// Clear the existing labels list
_labels = await getLabelTemplates("stock", {
"item": widget.item.pk.toString()
});
_labels = await getLabelTemplates(
model_type,
{
item_key: widget.item.pk.toString()
}
);
}
if (mounted) {