From 627c50e465ec7b4a4e1ea7a49b6ffb42f7068205 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 20 Apr 2020 20:27:52 +1000 Subject: [PATCH] Render a table of sales orders --- .../static/script/inventree/order.js | 68 +++++++++++++++++++ .../templates/company/purchase_orders.html | 2 +- .../templates/company/sales_orders.html | 26 +++++++ InvenTree/order/serializers.py | 1 + 4 files changed, 96 insertions(+), 1 deletion(-) diff --git a/InvenTree/InvenTree/static/script/inventree/order.js b/InvenTree/InvenTree/static/script/inventree/order.js index d583ebcdc4..b48c0f4e64 100644 --- a/InvenTree/InvenTree/static/script/inventree/order.js +++ b/InvenTree/InvenTree/static/script/inventree/order.js @@ -144,11 +144,74 @@ function loadPurchaseOrderTable(table, options) { return imageHoverIcon(row.supplier_detail.image) + renderLink(row.supplier_detail.name, `/company/${row.supplier}/purchase-orders/`); } }, + { + sortable: true, + field: 'description', + title: 'Description', + }, + { + sortable: true, + field: 'status', + title: 'Status', + formatter: function(value, row, index, field) { + return orderStatusDisplay(row.status, row.status_text); + } + }, { sortable: true, field: 'creation_date', title: 'Date', }, + { + sortable: true, + field: 'line_items', + title: 'Items' + }, + ], + }); +} + +function loadSalesOrderTable(table, options) { + + options.params = options.params || {}; + options.params['customer_detail'] = true; + + var filters = loadTableFilters("table"); + + for (var key in options.params) { + filters[key] = options.params[key]; + } + + setupFilterList("order", $(table)); + + $(table).inventreeTable({ + url: options.url, + queryParams: filters, + groupBy: false, + original: options.params, + formatNoMatches: function() { return "No sales orders found"; }, + columns: [ + { + field: 'pk', + title: 'ID', + visible: false, + }, + { + sortable: true, + field: 'reference', + title: 'Sales Order', + formatter: function(value, row, index, field) { + return renderLink(value, `/order/sales-order/${row.pk}/`); + }, + }, + { + sortable: true, + field: 'customer_detail', + title: 'Customer', + formatter: function(value, row, index, field) { + return imageHoverIcon(row.customer_detail.image) + renderLink(row.customer_detail.name, `/company/${row.customer}/sales-orders/`); + } + }, { sortable: true, field: 'description', @@ -162,6 +225,11 @@ function loadPurchaseOrderTable(table, options) { return orderStatusDisplay(row.status, row.status_text); } }, + { + sortable: true, + field: 'creation_date', + title: 'Date', + }, { sortable: true, field: 'line_items', diff --git a/InvenTree/company/templates/company/purchase_orders.html b/InvenTree/company/templates/company/purchase_orders.html index 3f940a93e7..eac4066f2d 100644 --- a/InvenTree/company/templates/company/purchase_orders.html +++ b/InvenTree/company/templates/company/purchase_orders.html @@ -11,7 +11,7 @@
- +
diff --git a/InvenTree/company/templates/company/sales_orders.html b/InvenTree/company/templates/company/sales_orders.html index 57181b0667..7d5c7684bc 100644 --- a/InvenTree/company/templates/company/sales_orders.html +++ b/InvenTree/company/templates/company/sales_orders.html @@ -9,4 +9,30 @@

{% trans "Sales Orders" %}


+
+
+ +
+ +
+
+
+ + +
+ +{% endblock %} + +{% block js_ready %} +{{ block.super }} + + loadSalesOrderTable("#sales-order-table", { + url: "{% url 'api-so-list' %}?customer={{ company.id }}", + }); + + + $("#new-sales-order").click(function() { + // TODO - Create a new sales order + }); + {% endblock %} \ No newline at end of file diff --git a/InvenTree/order/serializers.py b/InvenTree/order/serializers.py index 9171a093a6..a1845b4c71 100644 --- a/InvenTree/order/serializers.py +++ b/InvenTree/order/serializers.py @@ -124,6 +124,7 @@ class SalseOrderSerializer(InvenTreeModelSerializer): 'issue_date', 'complete_date', 'creation_date', + 'description', 'line_items', 'link', 'reference',