2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 21:15:41 +00:00

Adds a simple endpoint for accessing serial number information for a Part instance

- This is not included by default in the "part detail" endpoint as it must be calculated!
This commit is contained in:
Oliver
2021-11-27 00:11:18 +11:00
parent 8eb5e79070
commit ef7a9b5152
4 changed files with 52 additions and 2 deletions

View File

@ -54,6 +54,7 @@ function inventreeGet(url, filters={}, options={}) {
data: filters,
dataType: 'json',
contentType: 'application/json',
async: (options.async == false) ? false : true,
success: function(response) {
if (options.success) {
options.success(response);

View File

@ -80,6 +80,20 @@ function serializeStockItem(pk, options={}) {
notes: {},
};
if (options.part) {
// Work out the next available serial number
inventreeGet(`/api/part/${options.part}/serial-numbers/`, {}, {
success: function(data) {
if (data.next) {
options.fields.serial_numbers.placeholder = `{% trans "Next available serial number" %}: ${data.next}`;
} else if (data.latest) {
options.fields.serial_numbers.placeholder = `{% trans "Latest serial number" %}: ${data.latest}`;
}
},
async: false,
});
}
constructForm(url, options);
}