2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 13:05:42 +00:00

Merge remote-tracking branch 'inventree/master' into partial-shipment

# Conflicts:
#	InvenTree/order/api.py
This commit is contained in:
Oliver
2021-12-04 09:35:54 +11:00
18 changed files with 4326 additions and 428 deletions

View File

@ -808,6 +808,13 @@ function loadPurchaseOrderTable(table, options) {
var html = renderLink(value, `/order/purchase-order/${row.pk}/`);
html += purchaseOrderStatusDisplay(
row.status,
{
classes: 'float-right',
}
);
if (row.overdue) {
html += makeIconBadge('fa-calendar-times icon-red', '{% trans "Order is overdue" %}');
}
@ -832,14 +839,6 @@ function loadPurchaseOrderTable(table, options) {
field: 'description',
title: '{% trans "Description" %}',
},
{
field: 'status',
title: '{% trans "Status" %}',
sortable: true,
formatter: function(value, row) {
return purchaseOrderStatusDisplay(row.status, row.status_text);
}
},
{
field: 'creation_date',
title: '{% trans "Date" %}',
@ -1149,7 +1148,7 @@ function loadPurchaseOrderLineItemTable(table, options={}) {
field: 'buttons',
title: '',
formatter: function(value, row, index, field) {
var html = `<div class='btn-group'>`;
var html = `<div class='btn-group' role='group'>`;
var pk = row.pk;

View File

@ -29,6 +29,7 @@
loadParametricPartTable,
loadPartCategoryTable,
loadPartParameterTable,
loadPartPurchaseOrderTable,
loadPartTable,
loadPartTestTemplateTable,
loadPartVariantTable,
@ -712,6 +713,180 @@ function loadPartParameterTable(table, url, options) {
}
/*
* Construct a table showing a list of purchase orders for a given part.
*
* This requests API data from the PurchaseOrderLineItem endpoint
*/
function loadPartPurchaseOrderTable(table, part_id, options={}) {
options.params = options.params || {};
// Construct API filterset
options.params.base_part = part_id;
options.params.part_detail = true;
options.params.order_detail = true;
var filters = loadTableFilters('partpurchaseorders');
for (var key in options.params) {
filters[key] = options.params[key];
}
setupFilterList('purchaseorderlineitem', $(table), '#filter-list-partpurchaseorders');
$(table).inventreeTable({
url: '{% url "api-po-line-list" %}',
queryParams: filters,
name: 'partpurchaseorders',
original: options.params,
showColumns: true,
uniqueId: 'pk',
formatNoMatches: function() {
return '{% trans "No purchase orders found" %}';
},
onPostBody: function() {
$(table).find('.button-line-receive').click(function() {
var pk = $(this).attr('pk');
var line_item = $(table).bootstrapTable('getRowByUniqueId', pk);
if (!line_item) {
console.log('WARNING: getRowByUniqueId returned null');
return;
}
receivePurchaseOrderItems(
line_item.order,
[
line_item,
],
{
success: function() {
$(table).bootstrapTable('refresh');
}
}
);
});
},
columns: [
{
field: 'order',
title: '{% trans "Purchase Order" %}',
switchable: false,
formatter: function(value, row) {
var order = row.order_detail;
if (!order) {
return '-';
}
var ref = global_settings.PURCHASEORDER_REFERENCE_PREFIX + order.reference;
var html = renderLink(ref, `/order/purchase-order/${order.pk}/`);
html += purchaseOrderStatusDisplay(
order.status,
{
classes: 'float-right',
}
);
return html;
},
},
{
field: 'supplier',
title: '{% trans "Supplier" %}',
switchable: true,
formatter: function(value, row) {
if (row.supplier_part_detail && row.supplier_part_detail.supplier_detail) {
var supp = row.supplier_part_detail.supplier_detail;
var html = imageHoverIcon(supp.thumbnail || supp.image);
html += ' ' + renderLink(supp.name, `/company/${supp.pk}/`);
return html;
} else {
return '-';
}
}
},
{
field: 'sku',
title: '{% trans "SKU" %}',
switchable: true,
formatter: function(value, row) {
if (row.supplier_part_detail) {
var supp = row.supplier_part_detail;
return renderLink(supp.SKU, `/supplier-part/${supp.pk}/`);
} else {
return '-';
}
},
},
{
field: 'mpn',
title: '{% trans "MPN" %}',
switchable: true,
formatter: function(value, row) {
if (row.supplier_part_detail && row.supplier_part_detail.manufacturer_part_detail) {
var manu = row.supplier_part_detail.manufacturer_part_detail;
return renderLink(manu.MPN, `/manufacturer-part/${manu.pk}/`);
}
}
},
{
field: 'quantity',
title: '{% trans "Quantity" %}',
},
{
field: 'received',
title: '{% trans "Received" %}',
switchable: true,
},
{
field: 'purchase_price',
title: '{% trans "Price" %}',
switchable: true,
formatter: function(value, row) {
var formatter = new Intl.NumberFormat(
'en-US',
{
style: 'currency',
currency: row.purchase_price_currency,
}
);
return formatter.format(row.purchase_price);
}
},
{
field: 'actions',
title: '',
formatter: function(value, row) {
if (row.received >= row.quantity) {
// Already recevied
return `<span class='badge bg-success rounded-pill'>{% trans "Received" %}</span>`;
} else {
var html = `<div class='btn-group' role='group'>`;
var pk = row.pk;
html += makeIconButton('fa-sign-in-alt', 'button-line-receive', pk, '{% trans "Receive line item" %}');
html += `</div>`;
return html;
}
}
}
],
});
}
function loadRelatedPartsTable(table, part_id, options={}) {
/*
* Load table of "related" parts