mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Fixes for BuildOrder forms
This commit is contained in:
parent
13ca076f42
commit
be6ecd9587
@ -80,6 +80,7 @@ class BuildSerializer(InvenTreeModelSerializer):
|
|||||||
'completed',
|
'completed',
|
||||||
'completion_date',
|
'completion_date',
|
||||||
'destination',
|
'destination',
|
||||||
|
'parent',
|
||||||
'part',
|
'part',
|
||||||
'part_detail',
|
'part_detail',
|
||||||
'overdue',
|
'overdue',
|
||||||
|
@ -10,6 +10,11 @@ function buildFormFields() {
|
|||||||
title: {},
|
title: {},
|
||||||
part: {},
|
part: {},
|
||||||
quantity: {},
|
quantity: {},
|
||||||
|
parent: {
|
||||||
|
filters: {
|
||||||
|
part_detail: true,
|
||||||
|
}
|
||||||
|
},
|
||||||
batch: {},
|
batch: {},
|
||||||
target_date: {},
|
target_date: {},
|
||||||
take_from: {},
|
take_from: {},
|
||||||
@ -48,6 +53,14 @@ function newBuildOrder(options={}) {
|
|||||||
fields.part.value = options.part;
|
fields.part.value = options.part;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.quantity) {
|
||||||
|
fields.quantity.value = options.quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.parent) {
|
||||||
|
fields.parent.value = options.parent;
|
||||||
|
}
|
||||||
|
|
||||||
constructForm(`/api/build/`, {
|
constructForm(`/api/build/`, {
|
||||||
fields: fields,
|
fields: fields,
|
||||||
follow: true,
|
follow: true,
|
||||||
@ -409,14 +422,10 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
|
|||||||
var idx = $(this).closest('tr').attr('data-index');
|
var idx = $(this).closest('tr').attr('data-index');
|
||||||
var row = $(table).bootstrapTable('getData')[idx];
|
var row = $(table).bootstrapTable('getData')[idx];
|
||||||
|
|
||||||
// Launch form to create a new build order
|
newBuildOrder({
|
||||||
launchModalForm('{% url "build-create" %}', {
|
part: pk,
|
||||||
follow: true,
|
parent: buildId,
|
||||||
data: {
|
quantity: requiredQuantity(row) - sumAllocations(row),
|
||||||
part: pk,
|
|
||||||
parent: buildId,
|
|
||||||
quantity: requiredQuantity(row) - sumAllocations(row),
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1117,13 +1126,9 @@ function loadBuildPartsTable(table, options={}) {
|
|||||||
var idx = $(this).closest('tr').attr('data-index');
|
var idx = $(this).closest('tr').attr('data-index');
|
||||||
var row = $(table).bootstrapTable('getData')[idx];
|
var row = $(table).bootstrapTable('getData')[idx];
|
||||||
|
|
||||||
// Launch form to create a new build order
|
newBuildOrder({
|
||||||
launchModalForm('{% url "build-create" %}', {
|
part: pk,
|
||||||
follow: true,
|
parent: options.build,
|
||||||
data: {
|
|
||||||
part: pk,
|
|
||||||
parent: options.build,
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1204,6 +1204,9 @@ function renderModelData(name, model, data, parameters, options) {
|
|||||||
case 'supplierpart':
|
case 'supplierpart':
|
||||||
renderer = renderSupplierPart;
|
renderer = renderSupplierPart;
|
||||||
break;
|
break;
|
||||||
|
case 'build':
|
||||||
|
renderer = renderBuild;
|
||||||
|
break;
|
||||||
case 'owner':
|
case 'owner':
|
||||||
renderer = renderOwner;
|
renderer = renderOwner;
|
||||||
break;
|
break;
|
||||||
|
@ -70,6 +70,27 @@ function renderStockLocation(name, data, parameters, options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function renderBuild(name, data, parameters, options) {
|
||||||
|
|
||||||
|
var image = '';
|
||||||
|
|
||||||
|
if (data.part_detail && data.part_detail.thumbnail) {
|
||||||
|
image = data.part_detail.thumbnail;
|
||||||
|
} else {
|
||||||
|
image = `/static/img/blank_image.png`;
|
||||||
|
}
|
||||||
|
|
||||||
|
var html = `<img src='${image}' class='select2-thumbnail'>`;
|
||||||
|
|
||||||
|
html += `<span><b>${data.reference}</b></span> - ${data.quantity} x ${data.part_detail.full_name}`;
|
||||||
|
html += `<span class='float-right'>{% trans "Build ID" %}: ${data.pk}</span>`;
|
||||||
|
|
||||||
|
html += `<p><i>${data.title}</i></p>`;
|
||||||
|
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Renderer for "Part" model
|
// Renderer for "Part" model
|
||||||
function renderPart(name, data, parameters, options) {
|
function renderPart(name, data, parameters, options) {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user