2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-03 20:20:58 +00:00

Merge remote-tracking branch 'inventree/master' into label-api

# Conflicts:
#	InvenTree/locale/de/LC_MESSAGES/django.po
#	InvenTree/locale/en/LC_MESSAGES/django.po
#	InvenTree/locale/es/LC_MESSAGES/django.po
This commit is contained in:
Oliver Walters
2021-01-14 23:56:23 +11:00
41 changed files with 2155 additions and 1811 deletions

View File

@ -255,6 +255,38 @@ function loadBomTable(table, options) {
});
*/
}
cols.push(
{
'field': 'can_build',
'title': '{% trans "Can Build" %}',
formatter: function(value, row, index, field) {
var can_build = 0;
if (row.quantity > 0) {
can_build = row.sub_part_detail.stock / row.quantity;
}
return +can_build.toFixed(2);
},
sorter: function(valA, valB, rowA, rowB) {
// Function to sort the "can build" quantity
var cb_a = 0;
var cb_b = 0;
if (rowA.quantity > 0) {
cb_a = rowA.sub_part_detail.stock / rowA.quantity;
}
if (rowB.quantity > 0) {
cb_b = rowB.sub_part_detail.stock / rowB.quantity;
}
return (cb_a > cb_b) ? 1 : -1;
},
sortable: true,
}
)
// Part notes
cols.push(

View File

@ -141,9 +141,9 @@ function loadPurchaseOrderTable(table, options) {
switchable: false,
},
{
sortable: true,
field: 'reference',
title: '{% trans "Purchase Order" %}',
sortable: true,
switchable: false,
formatter: function(value, row, index, field) {
@ -153,13 +153,19 @@ function loadPurchaseOrderTable(table, options) {
value = `${prefix}${value}`;
}
return renderLink(value, `/order/purchase-order/${row.pk}/`);
var html = renderLink(value, `/order/purchase-order/${row.pk}/`);
if (row.overdue) {
html += makeIconBadge('fa-calendar-times icon-red', '{% trans "Order is overdue" %}');
}
return html;
}
},
{
sortable: true,
field: 'supplier_detail',
title: '{% trans "Supplier" %}',
sortable: true,
formatter: function(value, row, index, field) {
return imageHoverIcon(row.supplier_detail.image) + renderLink(row.supplier_detail.name, `/company/${row.supplier}/purchase-orders/`);
}
@ -170,27 +176,32 @@ function loadPurchaseOrderTable(table, options) {
sortable: true,
},
{
sortable: true,
field: 'description',
title: '{% trans "Description" %}',
sortable: true,
},
{
sortable: true,
field: 'status',
title: '{% trans "Status" %}',
sortable: true,
formatter: function(value, row, index, field) {
return purchaseOrderStatusDisplay(row.status, row.status_text);
}
},
{
sortable: true,
field: 'creation_date',
title: '{% trans "Date" %}',
sortable: true,
},
{
field: 'target_date',
title: '{% trans "Target Date" %}',
sortable: true,
},
{
field: 'line_items',
title: '{% trans "Items" %}'
title: '{% trans "Items" %}',
sortable: true,
},
],
});

View File

@ -6,8 +6,18 @@
* Requires api.js to be loaded first
*/
/* Functions for interacting with stock management forms
*/
function stockStatusCodes() {
return [
{% for code in StockStatus.list %}
{
key: {{ code.key }},
text: "{{ code.value }}",
},
{% endfor %}
];
}
function removeStockRow(e) {
// Remove a selected row from a stock modal form
@ -590,6 +600,11 @@ function loadStockTable(table, options) {
return locationDetail(row);
}
},
{
field: 'stocktake_date',
title: '{% trans "Stocktake" %}',
sortable: true,
},
{% settings_value "STOCK_ENABLE_EXPIRY" as expiry %}
{% if expiry %}
{
@ -689,6 +704,93 @@ function loadStockTable(table, options) {
});
});
$("#multi-item-set-status").click(function() {
// Select and set the STATUS field for selected stock items
var selections = $("#stock-table").bootstrapTable('getSelections');
// Select stock status
var modal = '#modal-form';
var status_list = makeOptionsList(
stockStatusCodes(),
function(item) {
return item.text;
},
function (item) {
return item.key;
}
);
// Add an empty option at the start of the list
status_list.unshift('<option value="">---------</option>');
// Construct form
var html = `
<form method='post' action='' class='js-modal-form' enctype='multipart/form-data'>
<div class='form-group'>
<label class='control-label requiredField' for='id_status'>
{% trans "Stock Status" %}
</label>
<div class='controls'>
<select id='id_status' class='select form-control' name='label'>
${status_list}
</select>
</div>
</div>
</form>`;
openModal({
modal: modal,
});
modalEnable(modal, true);
modalSetTitle(modal, '{% trans "Set Stock Status" %}');
modalSetContent(modal, html);
attachSelect(modal);
modalSubmit(modal, function() {
var label = $(modal).find('#id_status');
var status_code = label.val();
closeModal(modal);
if (!status_code) {
showAlertDialog(
'{% trans "Select Status Code" %}',
'{% trans "Status code must be selected" %}'
);
return;
}
var requests = [];
selections.forEach(function(item) {
var url = `/api/stock/${item.pk}/`;
requests.push(
inventreePut(
url,
{
status: status_code,
},
{
method: 'PATCH',
success: function() {
}
}
)
);
});
$.when.apply($, requests).then(function() {
$("#stock-table").bootstrapTable('refresh');
});
})
});
$("#multi-item-delete").click(function() {
var selections = $("#stock-table").bootstrapTable("getSelections");

View File

@ -214,6 +214,10 @@ function getAvailableTableFilters(tableKey) {
type: 'bool',
title: '{% trans "Outstanding" %}',
},
overdue: {
type: 'bool',
title: '{% trans "Overdue" %}',
},
};
}