Merge pull request #900 from SchrodingersGat/stock-display-improvements

Stock display improvements
This commit is contained in:
Oliver 2020-08-09 21:26:26 +10:00 committed by GitHub
commit 1f5d81ef93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 3 deletions

View File

@ -477,6 +477,17 @@ class StockList(generics.ListCreateAPIView):
if customer:
queryset = queryset.filter(customer=customer)
# Filter if items have been sent to a customer (any customer)
sent_to_customer = params.get('sent_to_customer', None)
if sent_to_customer is not None:
sent_to_customer = str2bool(sent_to_customer)
if sent_to_customer:
queryset = queryset.exclude(customer=None)
else:
queryset = queryset.filter(customer=None)
# Filter by "serialized" status?
serialized = params.get('serialized', None)
@ -507,6 +518,7 @@ class StockList(generics.ListCreateAPIView):
if serial_number_lte is not None:
queryset = queryset.filter(serial__lte=serial_number_lte)
# Filter by "in_stock" status
in_stock = params.get('in_stock', None)
if in_stock is not None:

View File

@ -1,4 +1,5 @@
{% load i18n %}
{% load status_codes %}
/* Stock API functions
* Requires api.js to be loaded first
@ -460,12 +461,26 @@ function loadStockTable(table, options) {
var html = renderLink(val, `/stock/item/${row.pk}/`);
if (row.allocated) {
html += `<span class='fas fa-bookmark label-right' title='{% trans "StockItem has been allocated" %}'></span>`;
html += `<span class='fas fa-bookmark label-right' title='{% trans "Stock item has been allocated" %}'></span>`;
}
if (row.customer) {
html += `<span class='fas fa-user-tie label-right' title='{% trans "Stock item has been assigned to customer" %}'></span>`;
} else if (row.build_order) {
html += `<span class='fas fa-tools label-right' title='{% trans "Stock item was assigned to a build order" %}'></span>`;
} else if (row.sales_order) {
html += `<span class='fas fa-dollar-sign label-right' title='{% trans "Stock item was assigned to a sales order" %}'></span>`;
}
// Special stock status codes
// 65 = "REJECTED"
if (row.status == 65) {
html += `<span class='fas fa-times-circle label-right' title='{% trans "Stock item has been rejected" %}'></span>`;
}
// 70 = "LOST"
if (row.status == 70) {
html += `<span class='fas fa-question-circle label-right' title='{% trans "StockItem is lost" %}'></span>`;
else if (row.status == 70) {
html += `<span class='fas fa-question-circle label-right' title='{% trans "Stock item is lost" %}'></span>`;
}
if (row.quantity <= 0) {

View File

@ -57,6 +57,11 @@ function getAvailableTableFilters(tableKey) {
title: '{% trans "In Stock" %}',
description: '{% trans "Show items which are in stock" %}',
},
sent_to_customer: {
type: 'bool',
title: '{% trans "Sent to customer" %}',
description: '{% trans "Show items which have been assigned to a customer" %}',
},
serialized: {
type: 'bool',
title: '{% trans "Is Serialized" %}',