mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Improvements for build output completion
- Check if the output is fully allocated (throw error if not) - Reload tables after actions performed
This commit is contained in:
parent
bd7fef720d
commit
542b4113a1
@ -152,6 +152,10 @@ class BuildOutputSerializer(serializers.Serializer):
|
|||||||
if not output.is_building:
|
if not output.is_building:
|
||||||
raise ValidationError(_("This build output has already been completed"))
|
raise ValidationError(_("This build output has already been completed"))
|
||||||
|
|
||||||
|
# The build output must have all tracked parts allocated
|
||||||
|
if not build.isFullyAllocated(output):
|
||||||
|
raise ValidationError(_("This build output is not fully allocated"))
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -364,7 +364,11 @@ inventreeGet(
|
|||||||
outputs,
|
outputs,
|
||||||
{
|
{
|
||||||
success: function() {
|
success: function() {
|
||||||
|
// Reload the "in progress" table
|
||||||
$('#build-output-table').bootstrapTable('refresh');
|
$('#build-output-table').bootstrapTable('refresh');
|
||||||
|
|
||||||
|
// Reload the "completed" table
|
||||||
|
$('#build-stock-table').bootstrapTable('refresh');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -220,12 +220,12 @@ function completeBuildOutputs(build_id, outputs, options={}) {
|
|||||||
function renderBuildOutput(output, opts={}) {
|
function renderBuildOutput(output, opts={}) {
|
||||||
var pk = output.pk;
|
var pk = output.pk;
|
||||||
|
|
||||||
var quantity = '';
|
var output_html = imageHoverIcon(output.part_detail.thumbnail);
|
||||||
|
|
||||||
if (output.quantity == 1 && output.serial) {
|
if (output.quantity == 1 && output.serial) {
|
||||||
quantity = `{% trans "Serial Number" %}: ${output.serial}`;
|
output_html += `{% trans "Serial Number" %}: ${output.serial}`;
|
||||||
} else {
|
} else {
|
||||||
quantity = `{% trans "Quantity" %}: ${output.quantity}`;
|
output_html += `{% trans "Quantity" %}: ${output.quantity}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
var buttons = `<div class='btn-group float-right' role='group'>`;
|
var buttons = `<div class='btn-group float-right' role='group'>`;
|
||||||
@ -234,9 +234,21 @@ function completeBuildOutputs(build_id, outputs, options={}) {
|
|||||||
|
|
||||||
buttons += '</div>';
|
buttons += '</div>';
|
||||||
|
|
||||||
|
var field = constructField(
|
||||||
|
`outputs_output_${pk}`,
|
||||||
|
{
|
||||||
|
type: 'raw',
|
||||||
|
html: output_html,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
hideLabels: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
var html = `
|
var html = `
|
||||||
<tr id='output_row_${pk}'>
|
<tr id='output_row_${pk}'>
|
||||||
<td>${quantity}</td>
|
<td>${field}</td>
|
||||||
|
<td>${output.part_detail.full_name}</td>
|
||||||
<td>${buttons}</td>
|
<td>${buttons}</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
|
|
||||||
@ -253,7 +265,7 @@ function completeBuildOutputs(build_id, outputs, options={}) {
|
|||||||
var html = `
|
var html = `
|
||||||
<table class='table table-striped table-condensed' id='build-complete-table'>
|
<table class='table table-striped table-condensed' id='build-complete-table'>
|
||||||
<thead>
|
<thead>
|
||||||
<th>{% trans "Output" %}</th>
|
<th colspan='2'>{% trans "Output" %}</th>
|
||||||
<th><!-- Actions --></th>
|
<th><!-- Actions --></th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -481,6 +493,9 @@ function loadBuildOutputTable(build_info, options={}) {
|
|||||||
rows,
|
rows,
|
||||||
{
|
{
|
||||||
output: pk,
|
output: pk,
|
||||||
|
success: function() {
|
||||||
|
$(table).bootstrapTable('refresh');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -1296,10 +1311,13 @@ function allocateStockToBuild(build_id, part_id, bom_items, options={}) {
|
|||||||
remaining = 0;
|
remaining = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We only care about entries which are not yet fully allocated
|
||||||
|
if (remaining > 0) {
|
||||||
table_entries += renderBomItemRow(bom_item, remaining);
|
table_entries += renderBomItemRow(bom_item, remaining);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (bom_items.length == 0) {
|
if (table_entries.length == 0) {
|
||||||
|
|
||||||
showAlertDialog(
|
showAlertDialog(
|
||||||
'{% trans "Select Parts" %}',
|
'{% trans "Select Parts" %}',
|
||||||
|
@ -1843,6 +1843,8 @@ function constructInput(name, parameters, options) {
|
|||||||
case 'candy':
|
case 'candy':
|
||||||
func = constructCandyInput;
|
func = constructCandyInput;
|
||||||
break;
|
break;
|
||||||
|
case 'raw':
|
||||||
|
func = constructRawInput;
|
||||||
default:
|
default:
|
||||||
// Unsupported field type!
|
// Unsupported field type!
|
||||||
break;
|
break;
|
||||||
@ -2086,6 +2088,17 @@ function constructCandyInput(name, parameters) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Construct a "raw" field input
|
||||||
|
* No actual field data!
|
||||||
|
*/
|
||||||
|
function constructRawInput(name, parameters) {
|
||||||
|
|
||||||
|
return parameters.html;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Construct a 'help text' div based on the field parameters
|
* Construct a 'help text' div based on the field parameters
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user