mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Print part labels
This commit is contained in:
parent
c39f705ef7
commit
15cb1e0005
@ -394,7 +394,7 @@ class PartLabelMixin:
|
||||
|
||||
for key in ['part', 'part[]', 'parts', 'parts[]']:
|
||||
if key in params:
|
||||
parts = parts.getlist(key, [])
|
||||
parts = params.getlist(key, [])
|
||||
break
|
||||
|
||||
valid_ids = []
|
||||
|
@ -255,7 +255,7 @@ class LabelConfig(AppConfig):
|
||||
'file': 'part_label.html',
|
||||
'name': 'Part Label',
|
||||
'description': 'Simple part label',
|
||||
'width': 50,
|
||||
'width': 70,
|
||||
'height': 24,
|
||||
},
|
||||
]
|
||||
|
@ -268,6 +268,10 @@
|
||||
);
|
||||
});
|
||||
|
||||
$('#print-label').click(function() {
|
||||
printPartLabels([{{ part.pk }}]);
|
||||
});
|
||||
|
||||
$("#part-count").click(function() {
|
||||
launchModalForm("/stock/adjust/", {
|
||||
data: {
|
||||
|
@ -105,6 +105,61 @@ function printStockLocationLabels(locations, options={}) {
|
||||
}
|
||||
|
||||
|
||||
function printPartLabels(parts, options={}) {
|
||||
/**
|
||||
* Print labels for the provided parts
|
||||
*/
|
||||
|
||||
if (parts.length == 0) {
|
||||
showAlertDialog(
|
||||
'{% trans "Select Parts" %}',
|
||||
'{% trans "Part(s) must be selected before printing labels" %}',
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Request available labels from the server
|
||||
inventreeGet(
|
||||
'{% url "api-part-label-list" %}',
|
||||
{
|
||||
enabled: true,
|
||||
parts: parts,
|
||||
},
|
||||
{
|
||||
success: function(response) {
|
||||
|
||||
if (response.length == 0) {
|
||||
showAlertDialog(
|
||||
'{% trans "No Labels Found" %}',
|
||||
'{% trans "No labels found which match the selected part(s)" %}',
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Select label to print
|
||||
selectLabel(
|
||||
response,
|
||||
parts,
|
||||
{
|
||||
success: function(pk) {
|
||||
var url = `/api/label/part/${pk}/print/?`;
|
||||
|
||||
parts.forEach(function(part) {
|
||||
url += `parts[]=${part}&`;
|
||||
});
|
||||
|
||||
window.location.href = url;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function selectLabel(labels, items, options={}) {
|
||||
/**
|
||||
* Present the user with the available labels,
|
||||
|
Loading…
Reference in New Issue
Block a user