mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Refactor the purchase-order table
- Filter by order status
This commit is contained in:
parent
ba7c0bdea0
commit
6a0c5b78ae
@ -104,8 +104,21 @@ function removePurchaseOrderLineItem(e) {
|
|||||||
function loadPurchaseOrderTable(table, options) {
|
function loadPurchaseOrderTable(table, options) {
|
||||||
/* Create a purchase-order table */
|
/* Create a purchase-order table */
|
||||||
|
|
||||||
|
var params = options.params || {};
|
||||||
|
|
||||||
|
var filters = loadTableFilters("build");
|
||||||
|
|
||||||
|
for (var key in params) {
|
||||||
|
filters[key] = params[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
setupFilterList("order", table);
|
||||||
|
|
||||||
table.inventreeTable({
|
table.inventreeTable({
|
||||||
url: options.url,
|
url: options.url,
|
||||||
|
queryParams: filters,
|
||||||
|
groupBy: false,
|
||||||
|
original: params,
|
||||||
formatNoMatches: function() { return "No purchase orders found"; },
|
formatNoMatches: function() { return "No purchase orders found"; },
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
@ -144,7 +157,7 @@ function loadPurchaseOrderTable(table, options) {
|
|||||||
field: 'status',
|
field: 'status',
|
||||||
title: 'Status',
|
title: 'Status',
|
||||||
formatter: function(value, row, index, field) {
|
formatter: function(value, row, index, field) {
|
||||||
return orderStatusLabel(row.status, row.status_text);
|
return orderStatusDisplay(row.status, row.status_text);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -155,37 +168,3 @@ function loadPurchaseOrderTable(table, options) {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function orderStatusLabel(code, label) {
|
|
||||||
/* Render a purchase-order status label. */
|
|
||||||
|
|
||||||
var html = "<span class='label";
|
|
||||||
|
|
||||||
switch (code) {
|
|
||||||
case 10: // pending
|
|
||||||
html += " label-info";
|
|
||||||
break;
|
|
||||||
case 20: // placed
|
|
||||||
html += " label-primary";
|
|
||||||
break;
|
|
||||||
case 30: // complete
|
|
||||||
html += " label-success";
|
|
||||||
break;
|
|
||||||
case 40: // cancelled
|
|
||||||
case 50: // lost
|
|
||||||
html += " label-warning";
|
|
||||||
break;
|
|
||||||
case 60: // returned
|
|
||||||
html += " label-danger";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
html += "'>";
|
|
||||||
html += label;
|
|
||||||
html += "</span>";
|
|
||||||
|
|
||||||
return html;
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
{% if order.status == OrderStatus.PENDING %}
|
|
||||||
<span class='label label-large label-info'>
|
|
||||||
{% elif order.status == OrderStatus.PLACED %}
|
|
||||||
<span class='label label-large label-primary'>
|
|
||||||
{% elif order.status == OrderStatus.COMPLETE %}
|
|
||||||
<span class='label label-large label-success'>
|
|
||||||
{% elif order.status == OrderStatus.CANCELLED or order.status == OrderStatus.RETURNED %}
|
|
||||||
<span class='label label-large label-warning'>
|
|
||||||
{% else %}
|
|
||||||
<span class='label label-large label-danger'>
|
|
||||||
{% endif %}
|
|
||||||
{{ order.get_status_display }}
|
|
||||||
</span>
|
|
@ -1,22 +0,0 @@
|
|||||||
<table class='table table-striped table-condensed po-table' id='po-table' {% if toolbar %}data-toolbar='{{ toolbar }}'{% endif %}>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th data-field='company' data-sortable='true' data-searchable='true'>Company</th>
|
|
||||||
<th data-field='reference' data-sortable='true' data-searchable='true'>Order Reference</th>
|
|
||||||
<th data-field='description' data-sortable='true' data-searchable='true'>Description</th>
|
|
||||||
<th data-field='status' data-sortable='true'>Status</th>
|
|
||||||
<th data-field='items' data-sortable='true'>Items</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for order in orders %}
|
|
||||||
<tr>
|
|
||||||
<td>{% include "hover_image.html" with image=order.supplier.image hover=True %}<a href="{{ order.supplier.get_absolute_url }}purchase-orders/">{{ order.supplier.name }}</a></td>
|
|
||||||
<td><a href="{% url 'po-detail' order.id %}">{{ order }}</a></td>
|
|
||||||
<td>{{ order.description }}</td>
|
|
||||||
<td>{% include "order/order_status.html" %}</td>
|
|
||||||
<td>{{ order.lines.count }}</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
@ -13,8 +13,11 @@ InvenTree | Purchase Orders
|
|||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<div id='table-buttons'>
|
<div id='table-buttons'>
|
||||||
<div class='btn-group' style='float: right;'>
|
<div class='button-toolbar container-fluid' style='float: right;'>
|
||||||
<button class='btn btn-primary' type='button' id='po-create' title='Create new purchase order'>New Purchase Order</button>
|
<button class='btn btn-primary' type='button' id='po-create' title='Create new purchase order'>New Purchase Order</button>
|
||||||
|
<div class='filter-list' id='filter-list-order'>
|
||||||
|
<!-- An empty div in which the filter list will be constructed -->
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
/*
|
||||||
|
* Status codes for the {{ label }} model.
|
||||||
|
*/
|
||||||
var {{ label }}Codes = {
|
var {{ label }}Codes = {
|
||||||
{% for opt in options %}'{{ opt.key }}': {
|
{% for opt in options %}'{{ opt.key }}': {
|
||||||
key: '{{ opt.key }}',
|
key: '{{ opt.key }}',
|
||||||
@ -6,6 +9,11 @@ var {{ label }}Codes = {
|
|||||||
},{% endfor %}
|
},{% endfor %}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Render the status for a {{ label }} object.
|
||||||
|
* Uses the values specified in "status_codes.py"
|
||||||
|
* This function is generated by the "status_codes.html" template
|
||||||
|
*/
|
||||||
function {{ label }}StatusDisplay(key) {
|
function {{ label }}StatusDisplay(key) {
|
||||||
|
|
||||||
key = String(key);
|
key = String(key);
|
||||||
|
Loading…
Reference in New Issue
Block a user