2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-30 12:36:45 +00:00

Bug fix for build order panel loading

This commit is contained in:
Oliver 2022-03-09 13:58:48 +11:00
parent 9f8f900e17
commit fe8ea5568f

View File

@ -396,174 +396,142 @@ function reloadTable() {
$('#allocation-table-untracked').bootstrapTable('refresh'); $('#allocation-table-untracked').bootstrapTable('refresh');
} }
onPanelLoad('allocate', function() { // Get the list of BOM items required for this build
inventreeGet(
'{% url "api-bom-list" %}',
{
part: {{ build.part.pk }},
sub_part_detail: true,
},
{
success: function(response) {
// Get the list of BOM items required for this build var build_info = {
inventreeGet( pk: {{ build.pk }},
'{% url "api-bom-list" %}', part: {{ build.part.pk }},
{ quantity: {{ build.quantity }},
part: {{ build.part.pk }}, bom_items: response,
sub_part_detail: true,
},
{
success: function(response) {
var build_info = {
pk: {{ build.pk }},
part: {{ build.part.pk }},
quantity: {{ build.quantity }},
bom_items: response,
{% if build.take_from %}
source_location: {{ build.take_from.pk }},
{% endif %}
{% if build.has_tracked_bom_items %}
tracked_parts: true,
{% else %}
tracked_parts: false,
{% endif %}
};
{% if build.active %}
loadBuildOutputTable(build_info);
linkButtonsToSelection(
'#build-output-table',
[
'#output-options',
'#multi-output-complete',
'#multi-output-delete',
]
);
$('#multi-output-complete').click(function() {
var outputs = $('#build-output-table').bootstrapTable('getSelections');
completeBuildOutputs(
build_info.pk,
outputs,
{
success: function() {
// Reload the "in progress" table
$('#build-output-table').bootstrapTable('refresh');
// Reload the "completed" table
$('#build-stock-table').bootstrapTable('refresh');
}
}
);
});
$('#multi-output-delete').click(function() {
var outputs = $('#build-output-table').bootstrapTable('getSelections');
deleteBuildOutputs(
build_info.pk,
outputs,
{
success: function() {
// Reload the "in progress" table
$('#build-output-table').bootstrapTable('refresh');
// Reload the "completed" table
$('#build-stock-table').bootstrapTable('refresh');
}
}
)
});
{% endif %}
{% if build.active and build.has_untracked_bom_items %}
// Load allocation table for un-tracked parts
loadBuildOutputAllocationTable(
build_info,
null,
{
search: true,
}
);
{% endif %}
}
}
);
$('#btn-create-output').click(function() {
createBuildOutput(
{{ build.pk }},
{
trackable_parts: {% if build.part.has_trackable_parts %}true{% else %}false{% endif%},
}
);
});
{% if build.active %}
$("#btn-auto-allocate").on('click', function() {
autoAllocateStockToBuild(
{{ build.pk }},
[],
{
{% if build.take_from %} {% if build.take_from %}
location: {{ build.take_from.pk }}, source_location: {{ build.take_from.pk }},
{% endif %} {% endif %}
} {% if build.has_tracked_bom_items %}
); tracked_parts: true,
}); {% else %}
tracked_parts: false,
{% endif %}
};
$("#btn-allocate").on('click', function() { {% if build.active %}
loadBuildOutputTable(build_info);
var bom_items = $("#allocation-table-untracked").bootstrapTable("getData"); linkButtonsToSelection(
'#build-output-table',
var incomplete_bom_items = []; [
'#output-options',
bom_items.forEach(function(bom_item) { '#multi-output-complete',
if (bom_item.required > bom_item.allocated) { '#multi-output-delete',
incomplete_bom_items.push(bom_item); ]
}
});
if (incomplete_bom_items.length == 0) {
showAlertDialog(
'{% trans "Allocation Complete" %}',
'{% trans "All untracked stock items have been allocated" %}',
); );
} else {
allocateStockToBuild( $('#multi-output-complete').click(function() {
{{ build.pk }}, var outputs = $('#build-output-table').bootstrapTable('getSelections');
{{ build.part.pk }},
incomplete_bom_items, completeBuildOutputs(
{ build_info.pk,
{% if build.take_from %} outputs,
source_location: {{ build.take_from.pk }}, {
{% endif %} success: function() {
success: function(data) { // Reload the "in progress" table
$('#allocation-table-untracked').bootstrapTable('refresh'); $('#build-output-table').bootstrapTable('refresh');
// Reload the "completed" table
$('#build-stock-table').bootstrapTable('refresh');
}
} }
);
});
$('#multi-output-delete').click(function() {
var outputs = $('#build-output-table').bootstrapTable('getSelections');
deleteBuildOutputs(
build_info.pk,
outputs,
{
success: function() {
// Reload the "in progress" table
$('#build-output-table').bootstrapTable('refresh');
// Reload the "completed" table
$('#build-stock-table').bootstrapTable('refresh');
}
}
)
});
{% endif %}
{% if build.active and build.has_untracked_bom_items %}
// Load allocation table for un-tracked parts
loadBuildOutputAllocationTable(
build_info,
null,
{
search: true,
} }
); );
{% endif %}
}
}
);
$('#btn-create-output').click(function() {
createBuildOutput(
{{ build.pk }},
{
trackable_parts: {% if build.part.has_trackable_parts %}true{% else %}false{% endif%},
}
);
});
{% if build.active %}
$("#btn-auto-allocate").on('click', function() {
autoAllocateStockToBuild(
{{ build.pk }},
[],
{
{% if build.take_from %}
location: {{ build.take_from.pk }},
{% endif %}
}
);
});
$("#btn-allocate").on('click', function() {
var bom_items = $("#allocation-table-untracked").bootstrapTable("getData");
var incomplete_bom_items = [];
bom_items.forEach(function(bom_item) {
if (bom_item.required > bom_item.allocated) {
incomplete_bom_items.push(bom_item);
} }
}); });
$('#btn-unallocate').on('click', function() { if (incomplete_bom_items.length == 0) {
unallocateStock({{ build.id }}, { showAlertDialog(
table: '#allocation-table-untracked', '{% trans "Allocation Complete" %}',
}); '{% trans "All untracked stock items have been allocated" %}',
}); );
} else {
$('#allocate-selected-items').click(function() {
var bom_items = $("#allocation-table-untracked").bootstrapTable("getSelections");
if (bom_items.length == 0) {
bom_items = $("#allocation-table-untracked").bootstrapTable('getData');
}
allocateStockToBuild( allocateStockToBuild(
{{ build.pk }}, {{ build.pk }},
{{ build.part.pk }}, {{ build.part.pk }},
bom_items, incomplete_bom_items,
{ {
{% if build.take_from %} {% if build.take_from %}
source_location: {{ build.take_from.pk }}, source_location: {{ build.take_from.pk }},
@ -573,19 +541,48 @@ onPanelLoad('allocate', function() {
} }
} }
); );
}); }
$("#btn-order-parts").click(function() {
launchModalForm("/order/purchase-order/order-parts/", {
data: {
build: {{ build.id }},
},
});
});
{% endif %}
}); });
$('#btn-unallocate').on('click', function() {
unallocateStock({{ build.id }}, {
table: '#allocation-table-untracked',
});
});
$('#allocate-selected-items').click(function() {
var bom_items = $("#allocation-table-untracked").bootstrapTable("getSelections");
if (bom_items.length == 0) {
bom_items = $("#allocation-table-untracked").bootstrapTable('getData');
}
allocateStockToBuild(
{{ build.pk }},
{{ build.part.pk }},
bom_items,
{
{% if build.take_from %}
source_location: {{ build.take_from.pk }},
{% endif %}
success: function(data) {
$('#allocation-table-untracked').bootstrapTable('refresh');
}
}
);
});
$("#btn-order-parts").click(function() {
launchModalForm("/order/purchase-order/order-parts/", {
data: {
build: {{ build.id }},
},
});
});
{% endif %}
enableSidebar('buildorder'); enableSidebar('buildorder');
{% endblock %} {% endblock %}