From ec03e0cc22f4f079414a32464506c0ae80d7ed66 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 14 Mar 2023 23:25:31 +1100 Subject: [PATCH] Add "return orders" list to company detail page --- .../company/templates/company/detail.html | 100 +++++++++++++++--- .../company/templates/company/sidebar.html | 2 + .../order/templates/order/return_orders.html | 3 +- InvenTree/templates/js/translated/order.js | 26 ----- .../templates/js/translated/purchase_order.js | 19 ---- 5 files changed, 86 insertions(+), 64 deletions(-) diff --git a/InvenTree/company/templates/company/detail.html b/InvenTree/company/templates/company/detail.html index f9094b89f3..f6b83aa889 100644 --- a/InvenTree/company/templates/company/detail.html +++ b/InvenTree/company/templates/company/detail.html @@ -138,6 +138,8 @@ +{% if company.is_customer %} +{% if roles.sales_order.view %}
@@ -163,8 +165,9 @@
+{% endif %} -{% if company.is_customer %} +{% if roles.stock.view %}

{% trans "Assigned Stock" %}

@@ -181,6 +184,42 @@
{% endif %} +{% if roles.return_order.view %} +
+
+
+

{% trans "Return Orders" %}

+ {% include "spacer.html" %} +
+ {% if roles.return_order.add %} + + {% endif %} +
+
+
+
+
+
+
+ {% if report_enabled %} + + {% endif %} + {% include "filter_list.html" with id="returnorder" %} +
+
+
+ +
+
+
+{% endif %} + +{% endif %} +
@@ -301,22 +340,6 @@ ); }); - {% if company.is_customer %} - // Callback function when the 'assigned stock' panel is loaded - onPanelLoad('assigned-stock', function() { - loadStockTable($("#assigned-stock-table"), { - params: { - customer: {{ company.id }}, - part_detail: true, - location_detail: true, - }, - url: "{% url 'api-stock-list' %}", - filterKey: "customerstock", - filterTarget: '#filter-list-customerstock', - }); - }); - {% endif %} - onPanelLoad('company-stock', function() { loadStockTable($('#stock-table'), { @@ -335,20 +358,63 @@ }); {% if company.is_customer %} + + // Callback function when the 'return orders' panel is loaded + onPanelLoad('return-orders', function() { + + {% if roles.return_order.view %} + loadReturnOrderTable('#return-order-table', { + params: { + customer: {{ company.pk }}, + } + }); + {% endif %} + + {% if roles.return_order.add %} + $('#new-return-order').click(function() { + createReturnOrder({ + customer: {{ company.pk }}, + }); + }); + {% endif %} + }); + + // Callback function when the 'assigned stock' panel is loaded + onPanelLoad('assigned-stock', function() { + + {% if roles.stock.view %} + loadStockTable($("#assigned-stock-table"), { + params: { + customer: {{ company.id }}, + part_detail: true, + location_detail: true, + }, + url: "{% url 'api-stock-list' %}", + filterKey: "customerstock", + filterTarget: '#filter-list-customerstock', + }); + {% endif %} + }); + + // Callback function when the 'sales orders' panel is loaded onPanelLoad('sales-orders', function() { + {% if roles.sales_order.view %} loadSalesOrderTable("#sales-order-table", { url: "{% url 'api-so-list' %}", params: { customer: {{ company.id }}, } }); + {% endif %} + {% if roles.salse_order.add %} $("#new-sales-order").click(function() { createSalesOrder({ customer: {{ company.pk }}, }); }); + {% endif %} }); {% endif %} diff --git a/InvenTree/company/templates/company/sidebar.html b/InvenTree/company/templates/company/sidebar.html index 0280f2b5b9..881701f577 100644 --- a/InvenTree/company/templates/company/sidebar.html +++ b/InvenTree/company/templates/company/sidebar.html @@ -21,6 +21,8 @@ {% include "sidebar_item.html" with label='sales-orders' text=text icon="fa-truck" %} {% trans "Assigned Stock Items" as text %} {% include "sidebar_item.html" with label='assigned-stock' text=text icon="fa-sign-out-alt" %} +{% trans "Return Orders" as text %} +{% include "sidebar_item.html" with label='return-orders' text=text icon="fa-undo" %} {% endif %} {% trans "Contacts" as text %} {% include "sidebar_item.html" with label='company-contacts' text=text icon="fa-users" %} diff --git a/InvenTree/order/templates/order/return_orders.html b/InvenTree/order/templates/order/return_orders.html index 03d708bba1..e305724e39 100644 --- a/InvenTree/order/templates/order/return_orders.html +++ b/InvenTree/order/templates/order/return_orders.html @@ -51,8 +51,7 @@ {% block js_ready %} {{ block.super }} -loadReturnOrderTable('#return-order-table', { -}); +loadReturnOrderTable('#return-order-table', {}); {% if report_enabled %} diff --git a/InvenTree/templates/js/translated/order.js b/InvenTree/templates/js/translated/order.js index 4c2c2801cc..46e063f181 100644 --- a/InvenTree/templates/js/translated/order.js +++ b/InvenTree/templates/js/translated/order.js @@ -20,34 +20,8 @@ */ /* exported - allocateStockToSalesOrder, - cancelPurchaseOrder, - cancelSalesOrder, - completePurchaseOrder, - completeSalesOrder, - completeSalesOrderShipment, - completePendingShipments, - createPurchaseOrder, - createPurchaseOrderLineItem, - createReturnOrder, - createSalesOrder, - createSalesOrderLineItem, - createSalesOrderShipment, - duplicatePurchaseOrder, - editPurchaseOrder, - editPurchaseOrderLineItem, - editSalesOrder, exportOrder, issuePurchaseOrder, - loadPurchaseOrderLineItemTable, - loadPurchaseOrderExtraLineTable - loadPurchaseOrderTable, - loadReturnOrderTable, - loadSalesOrderAllocationTable, - loadSalesOrderLineItemTable, - loadSalesOrderExtraLineTable - loadSalesOrderShipmentTable, - loadSalesOrderTable, newPurchaseOrderFromOrderWizard, newSupplierPartFromOrderWizard, orderParts, diff --git a/InvenTree/templates/js/translated/purchase_order.js b/InvenTree/templates/js/translated/purchase_order.js index f09c0084f8..c961cdca88 100644 --- a/InvenTree/templates/js/translated/purchase_order.js +++ b/InvenTree/templates/js/translated/purchase_order.js @@ -20,41 +20,22 @@ */ /* exported - allocateStockToSalesOrder, cancelPurchaseOrder, - cancelSalesOrder, completePurchaseOrder, - completeSalesOrder, - completeSalesOrderShipment, - completePendingShipments, createPurchaseOrder, createPurchaseOrderLineItem, - createReturnOrder, - createSalesOrder, - createSalesOrderLineItem, - createSalesOrderShipment, duplicatePurchaseOrder, editPurchaseOrder, editPurchaseOrderLineItem, - editSalesOrder, - exportOrder, issuePurchaseOrder, loadPurchaseOrderLineItemTable, loadPurchaseOrderExtraLineTable loadPurchaseOrderTable, - loadReturnOrderTable, - loadSalesOrderAllocationTable, - loadSalesOrderLineItemTable, - loadSalesOrderExtraLineTable - loadSalesOrderShipmentTable, - loadSalesOrderTable, newPurchaseOrderFromOrderWizard, newSupplierPartFromOrderWizard, orderParts, removeOrderRowFromOrderWizard, removePurchaseOrderLineItem, - loadOrderTotal, - extraLineFields, */