2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 04:55:44 +00:00

Adds a new API endpoint for creating build outputs

This commit is contained in:
Oliver
2022-02-15 12:51:48 +11:00
parent dc4c1f138b
commit f90a27d01d
4 changed files with 213 additions and 0 deletions

View File

@ -21,6 +21,7 @@
/* exported
allocateStockToBuild,
completeBuildOrder,
createBuildOutput,
editBuildOrder,
loadAllocationTable,
loadBuildOrderAllocationTable,
@ -175,6 +176,68 @@ function completeBuildOrder(build_id, options={}) {
}
/*
* Construct a new build output against the provided build
*/
function createBuildOutput(build_id, options) {
// Request build order information from the server
inventreeGet(
`/api/build/${build_id}/`,
{},
{
success: function(build) {
var html = '';
var trackable = build.part_detail.trackable;
var remaining = Math.max(0, build.quantity - build.completed);
var fields = {
quantity: {
value: remaining,
},
serial_numbers: {
hidden: !trackable,
required: options.trackable_parts || trackable,
},
batch_code: {},
auto_allocate: {},
};
if (options.trackable_parts) {
html += `
<div class='alert alert-block alert-info'>
{% trans "The Bill of Materials contains trackable parts" %}.<br>
{% trans "Build outputs must be generated individually" %}.
</div>
`;
}
if (trackable) {
html += `
<div class='alert alert-block alert-info'>
{% trans "Trackable parts can have serial numbers specified" %}<br>
{% trans "Enter serial numbers to generate multiple single build outputs" %}
</div>
`;
}
constructForm(`/api/build/${build_id}/create-output/`, {
method: 'POST',
title: '{% trans "Create Build Output" %}',
confirm: true,
fields: fields,
preFormContent: html,
});
}
}
);
}
/*
* Construct a set of output buttons for a particular build output
*/