mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge pull request #2632 from SchrodingersGat/build-serial-number-guess
Build output allocation tweak
This commit is contained in:
commit
6c32f5c60d
@ -1515,8 +1515,22 @@ function allocateStockToBuild(build_id, part_id, bom_items, options={}) {
|
|||||||
// ID of the associated "build output" (or null)
|
// ID of the associated "build output" (or null)
|
||||||
var output_id = options.output || null;
|
var output_id = options.output || null;
|
||||||
|
|
||||||
|
var auto_fill_filters = {};
|
||||||
|
|
||||||
var source_location = options.source_location;
|
var source_location = options.source_location;
|
||||||
|
|
||||||
|
if (output_id) {
|
||||||
|
// Request information on the particular build output (stock item)
|
||||||
|
inventreeGet(`/api/stock/${output_id}/`, {}, {
|
||||||
|
success: function(output) {
|
||||||
|
if (output.quantity == 1 && output.serial != null) {
|
||||||
|
auto_fill_filters.serial = output.serial;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function renderBomItemRow(bom_item, quantity) {
|
function renderBomItemRow(bom_item, quantity) {
|
||||||
|
|
||||||
var pk = bom_item.pk;
|
var pk = bom_item.pk;
|
||||||
@ -1703,7 +1717,9 @@ function allocateStockToBuild(build_id, part_id, bom_items, options={}) {
|
|||||||
required: true,
|
required: true,
|
||||||
render_part_detail: true,
|
render_part_detail: true,
|
||||||
render_location_detail: true,
|
render_location_detail: true,
|
||||||
|
render_stock_id: false,
|
||||||
auto_fill: true,
|
auto_fill: true,
|
||||||
|
auto_fill_filters: auto_fill_filters,
|
||||||
onSelect: function(data, field, opts) {
|
onSelect: function(data, field, opts) {
|
||||||
// Adjust the 'quantity' field based on availability
|
// Adjust the 'quantity' field based on availability
|
||||||
|
|
||||||
|
@ -1696,13 +1696,19 @@ function initializeRelatedField(field, fields, options={}) {
|
|||||||
} else if (field.auto_fill) {
|
} else if (field.auto_fill) {
|
||||||
// Attempt to auto-fill the field
|
// Attempt to auto-fill the field
|
||||||
|
|
||||||
var filters = field.filters || {};
|
var filters = {};
|
||||||
|
|
||||||
|
// Update with nominal field fields
|
||||||
|
Object.assign(filters, field.filters || {});
|
||||||
|
|
||||||
|
// Update with filters only used for initial filtering
|
||||||
|
Object.assign(filters, field.auto_fill_filters || {});
|
||||||
|
|
||||||
// Enforce pagination, limit to a single return (for fast query)
|
// Enforce pagination, limit to a single return (for fast query)
|
||||||
filters.limit = 1;
|
filters.limit = 1;
|
||||||
filters.offset = 0;
|
filters.offset = 0;
|
||||||
|
|
||||||
inventreeGet(field.api_url, field.filters || {}, {
|
inventreeGet(field.api_url, filters || {}, {
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
|
|
||||||
// Only a single result is available, given the provided filters
|
// Only a single result is available, given the provided filters
|
||||||
|
Loading…
Reference in New Issue
Block a user