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:
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user