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',
|
||||
'completion_date',
|
||||
'destination',
|
||||
'parent',
|
||||
'part',
|
||||
'part_detail',
|
||||
'overdue',
|
||||
|
@ -10,6 +10,11 @@ function buildFormFields() {
|
||||
title: {},
|
||||
part: {},
|
||||
quantity: {},
|
||||
parent: {
|
||||
filters: {
|
||||
part_detail: true,
|
||||
}
|
||||
},
|
||||
batch: {},
|
||||
target_date: {},
|
||||
take_from: {},
|
||||
@ -48,6 +53,14 @@ function newBuildOrder(options={}) {
|
||||
fields.part.value = options.part;
|
||||
}
|
||||
|
||||
if (options.quantity) {
|
||||
fields.quantity.value = options.quantity;
|
||||
}
|
||||
|
||||
if (options.parent) {
|
||||
fields.parent.value = options.parent;
|
||||
}
|
||||
|
||||
constructForm(`/api/build/`, {
|
||||
fields: fields,
|
||||
follow: true,
|
||||
@ -409,14 +422,10 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
|
||||
var idx = $(this).closest('tr').attr('data-index');
|
||||
var row = $(table).bootstrapTable('getData')[idx];
|
||||
|
||||
// Launch form to create a new build order
|
||||
launchModalForm('{% url "build-create" %}', {
|
||||
follow: true,
|
||||
data: {
|
||||
newBuildOrder({
|
||||
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 row = $(table).bootstrapTable('getData')[idx];
|
||||
|
||||
// Launch form to create a new build order
|
||||
launchModalForm('{% url "build-create" %}', {
|
||||
follow: true,
|
||||
data: {
|
||||
newBuildOrder({
|
||||
part: pk,
|
||||
parent: options.build,
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -1204,6 +1204,9 @@ function renderModelData(name, model, data, parameters, options) {
|
||||
case 'supplierpart':
|
||||
renderer = renderSupplierPart;
|
||||
break;
|
||||
case 'build':
|
||||
renderer = renderBuild;
|
||||
break;
|
||||
case 'owner':
|
||||
renderer = renderOwner;
|
||||
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
|
||||
function renderPart(name, data, parameters, options) {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user