Load stocktake table for part

This commit is contained in:
Oliver 2022-12-16 14:43:20 +11:00
parent 480b3d5813
commit 4ed62d5597
3 changed files with 56 additions and 4 deletions

View File

@ -61,7 +61,7 @@
<h4>{% trans "Part Stocktake" %}</h4>
{% include "spacer.html" %}
<div class='btn-group' role='group'>
buttons
<!-- TODO: Buttons -->
</div>
</div>
</div>
@ -460,6 +460,11 @@
});
});
// Load the "stocktake" tab
onPanelLoad('stocktake', function() {
loadPartStocktakeTable({{ part.pk }});
});
// Load the "suppliers" tab
onPanelLoad('suppliers', function() {

View File

@ -1,4 +1,4 @@
{% load i18n %}
{% load inventree_extras %}
part scheduling information to appear here
<table class='table table-condensed table-striped' id='part-stocktake-table'></table>

View File

@ -33,6 +33,7 @@
loadPartTable,
loadPartTestTemplateTable,
loadPartSchedulingChart,
loadPartStocktakeTable,
loadPartVariantTable,
loadRelatedPartsTable,
loadSimplePartTable,
@ -682,9 +683,55 @@ function makePartIcons(part) {
}
/*
* Load table for part stocktake information
*/
function loadPartStocktakeTable(partId, options={}) {
var table = options.table || '#part-stocktake-table';
var params = options.params || {};
params.part = partId;
var filters = loadTableFilters('stocktake');
for (var key in params) {
filters[key] = params[key];
}
setupFilterList('stocktake', $(table), '#filter-list-stocktake');
$(table).inventreeTable({
url: '{% url "api-part-stocktake-list" %}',
queryParams: filters,
name: 'partstocktake',
original: options.params,
showColumns: true,
formatNoMatches: function() {
return '{% trans "No stocktake information available" %}';
},
columns: [
{
field: 'date',
title: '{% trans "Date" %}',
},
{
field: 'quantity',
title: '{% trans "Quantity" %}',
},
{
field: 'user',
title: '{% trans "User" %}',
}
]
});
}
/* Load part variant table
*/
function loadPartVariantTable(table, partId, options={}) {
/* Load part variant table
*/
var params = options.params || {};