Add list of pending shipment to home page, with corresponding settings for user (#4775)

This commit is contained in:
miggland 2023-05-07 16:25:51 +02:00 committed by GitHub
parent 89dfb6186f
commit 84f8e33269
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 1 deletions

View File

@ -1875,6 +1875,13 @@ class InvenTreeUserSetting(BaseInvenTreeSetting):
'validator': bool,
},
'HOMEPAGE_SO_SHIPMENTS_PENDING': {
'name': _('Show pending SO shipments'),
'description': _('Show pending SO shipments on the homepage'),
'default': True,
'validator': bool,
},
'HOMEPAGE_NEWS': {
'name': _('Show News'),
'description': _('Show news on the homepage'),

View File

@ -301,7 +301,8 @@ loadPurchaseOrderTable("#table-po-overdue", {
{% settings_value 'HOMEPAGE_SO_OUTSTANDING' user=request.user as setting_so_outstanding %}
{% settings_value 'HOMEPAGE_SO_OVERDUE' user=request.user as setting_so_overdue %}
{% to_list setting_so_outstanding setting_so_overdue as settings_list_so %}
{% settings_value 'HOMEPAGE_SO_SHIPMENTS_PENDING' user=request.user as setting_so_shipments_pending %}
{% to_list setting_so_outstanding setting_so_overdue setting_so_shipments_pending as settings_list_so %}
{% if roles.sales_order.view and True in settings_list_so %}
addHeaderTitle('{% trans "Sales Orders" %}');
@ -328,6 +329,17 @@ loadSalesOrderTable("#table-so-overdue", {
});
{% endif %}
{% if setting_so_shipments_pending %}
addHeaderAction('so-shipments', '{% trans "Pending Shipments" %}', 'fa-truck-loading');
loadSalesOrderShipmentTable("#table-so-shipments", {
url: "{% url 'api-so-shipment-list' %}",
params: {
shipped: false,
},
show_so_reference: true,
});
{% endif %}
{% endif %}
{% settings_value 'HOMEPAGE_NEWS' user=request.user as setting_news %}

View File

@ -37,6 +37,7 @@
<tr><td colspan='5'></td></tr>
{% include "InvenTree/settings/setting.html" with key="HOMEPAGE_SO_OUTSTANDING" user_setting=True %}
{% include "InvenTree/settings/setting.html" with key="HOMEPAGE_SO_OVERDUE" user_setting=True %}
{% include "InvenTree/settings/setting.html" with key="HOMEPAGE_SO_SHIPMENTS_PENDING" user_setting=True %}
<tr><td colspan='5'></td></tr>
{% include "InvenTree/settings/setting.html" with key="HOMEPAGE_NEWS" user_setting=True %}
</tbody>

View File

@ -836,6 +836,9 @@ function loadSalesOrderShipmentTable(table, options={}) {
// Add callbacks for expand / collapse buttons
var prefix = options.shipped ? 'completed' : 'pending';
// Add option to show SO reference also
var show_so_reference = options.show_so_reference || false;
$(`#${prefix}-shipments-expand`).click(function() {
$(table).bootstrapTable('expandAllRows');
});
@ -931,6 +934,21 @@ function loadSalesOrderShipmentTable(table, options={}) {
checkbox: true,
switchable: false,
},
{
visible: show_so_reference,
field: 'order_detail',
title: '{% trans "Sales Order" %}',
switchable: false,
formatter: function(value, row) {
var html = renderLink(row.order_detail.reference, `/order/sales-order/${row.order}/`);
if (row.overdue) {
html += makeIconBadge('fa-calendar-times icon-red', '{% trans "Order is overdue" %}');
}
return html;
},
},
{
field: 'reference',
title: '{% trans "Shipment Reference" %}',