2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 13:05:42 +00:00

Adds ability to partially scrap build outputs (#4846)

* BuildOrder updates:

- Use batch code generation when creating a new build output
- Allow partial scrapping of build outputs

* Fixes for stock table

* Bump API version

* Update unit tests
This commit is contained in:
Oliver
2023-05-18 14:04:57 +10:00
committed by GitHub
parent 120a710ad4
commit 327381357b
9 changed files with 107 additions and 13 deletions

View File

@ -1 +1 @@
<div class='filter-list d-flex flex-row form-row' id='filter-list-{{ id }}'><!-- Empty div for table filters --></div>
<div class='filter-list d-flex flex-row form-row' id='filter-list-{% if prefix %}{{ prefix }}{% endif %}{{ id }}'><!-- Empty div for table filters --></div>

View File

@ -463,7 +463,7 @@ function unallocateStock(build_id, options={}) {
/*
* Helper function to render a single build output in a modal form
*/
function renderBuildOutput(output, opts={}) {
function renderBuildOutput(output, options={}) {
let pk = output.pk;
let output_html = imageHoverIcon(output.part_detail.thumbnail);
@ -494,10 +494,31 @@ function renderBuildOutput(output, opts={}) {
}
);
let quantity_field = '';
if (options.adjust_quantity) {
quantity_field = constructField(
`outputs_quantity_${pk}`,
{
type: 'decimal',
value: output.quantity,
min_value: 0,
max_value: output.quantity,
required: true,
},
{
hideLabels: true,
}
);
quantity_field = `<td>${quantity_field}</td>`;
}
let html = `
<tr id='output_row_${pk}'>
<td>${field}</td>
<td>${output.part_detail.full_name}</td>
${quantity_field}
<td>${buttons}</td>
</tr>`;
@ -645,7 +666,9 @@ function scrapBuildOutputs(build_id, outputs, options={}) {
let table_entries = '';
outputs.forEach(function(output) {
table_entries += renderBuildOutput(output);
table_entries += renderBuildOutput(output, {
adjust_quantity: true,
});
});
var html = `
@ -660,6 +683,7 @@ function scrapBuildOutputs(build_id, outputs, options={}) {
<table class='table table-striped table-condensed' id='build-scrap-table'>
<thead>
<th colspan='2'>{% trans "Output" %}</th>
<th>{% trans "Quantity" %}</th>
<th><!-- Actions --></th>
</thead>
<tbody>
@ -701,11 +725,14 @@ function scrapBuildOutputs(build_id, outputs, options={}) {
outputs.forEach(function(output) {
let pk = output.pk;
let row = $(opts.modal).find(`#output_row_${pk}`);
let quantity = getFormFieldValue(`outputs_quantity_${pk}`, {}, opts);
if (row.exists()) {
data.outputs.push({
output: pk,
quantity: quantity,
});
output_pk_values.push(pk);
}
});

View File

@ -45,7 +45,7 @@
</div>
{% endif %}
{% endif %}
{% include "filter_list.html" with id="stock" %}
{% include "filter_list.html" with prefix=prefix id="stock" %}
</div>
</div>
</div>