Reload the untracked stock table when allocation actions are performed

This commit is contained in:
Oliver 2022-04-29 12:59:20 +10:00
parent 51da1f02a8
commit 8fc34a21a6
2 changed files with 32 additions and 24 deletions

View File

@ -431,24 +431,32 @@ onPanelLoad('outputs', function() {
{% if build.active and build.has_untracked_bom_items %}
var build_info = {
pk: {{ build.pk }},
part: {{ build.part.pk }},
quantity: {{ build.quantity }},
{% if build.take_from %}
source_location: {{ build.take_from.pk }},
{% endif %}
tracked_parts: false,
};
function loadUntrackedStockTable() {
var build_info = {
pk: {{ build.pk }},
part: {{ build.part.pk }},
quantity: {{ build.quantity }},
{% if build.take_from %}
source_location: {{ build.take_from.pk }},
{% endif %}
tracked_parts: false,
};
$('#allocation-table-untracked').bootstrapTable('destroy');
// Load allocation table for un-tracked parts
loadBuildOutputAllocationTable(
build_info,
null,
{
search: true,
}
);
}
loadUntrackedStockTable();
// Load allocation table for un-tracked parts
loadBuildOutputAllocationTable(
build_info,
null,
{
search: true,
}
);
{% endif %}
$('#btn-create-output').click(function() {
@ -472,6 +480,7 @@ $("#btn-auto-allocate").on('click', function() {
{% if build.take_from %}
location: {{ build.take_from.pk }},
{% endif %}
onSuccess: loadUntrackedStockTable,
}
);
});
@ -503,9 +512,7 @@ $("#btn-allocate").on('click', function() {
{% if build.take_from %}
source_location: {{ build.take_from.pk }},
{% endif %}
success: function(data) {
$('#allocation-table-untracked').bootstrapTable('refresh');
}
success: loadUntrackedStockTable,
}
);
}
@ -514,6 +521,7 @@ $("#btn-allocate").on('click', function() {
$('#btn-unallocate').on('click', function() {
unallocateStock({{ build.id }}, {
table: '#allocation-table-untracked',
onSuccess: loadUntrackedStockTable,
});
});
@ -533,9 +541,7 @@ $('#allocate-selected-items').click(function() {
{% if build.take_from %}
source_location: {{ build.take_from.pk }},
{% endif %}
success: function(data) {
$('#allocation-table-untracked').bootstrapTable('refresh');
}
success: loadUntrackedStockTable,
}
);
});

View File

@ -2270,7 +2270,9 @@ function autoAllocateStockToBuild(build_id, bom_items=[], options={}) {
confirm: true,
preFormContent: html,
onSuccess: function(response) {
$('#allocation-table-untracked').bootstrapTable('refresh');
if (options.onSuccess) {
options.onSuccess(response);
}
}
});
}