diff --git a/InvenTree/company/templates/company/index.html b/InvenTree/company/templates/company/index.html index d4193960d3..17b737b670 100644 --- a/InvenTree/company/templates/company/index.html +++ b/InvenTree/company/templates/company/index.html @@ -55,6 +55,7 @@ InvenTree | Supplier List { field: 'description', title: 'Description', + sortable: true, }, { field: 'website', @@ -69,6 +70,7 @@ InvenTree | Supplier List { field: 'part_count', title: 'Parts', + sortable: true, formatter: function(value, row, index, field) { return renderLink(value, row.url + 'parts/'); } diff --git a/InvenTree/stock/templates/stock/item.html b/InvenTree/stock/templates/stock/item.html index 87abe0adfe..7bf6ff4e29 100644 --- a/InvenTree/stock/templates/stock/item.html +++ b/InvenTree/stock/templates/stock/item.html @@ -49,6 +49,10 @@
This stock item is serialized - it has a unique serial number and the quantity cannot be adjusted.
+ {% elif item.delete_on_deplete %} +
+ This stock item will be automatically deleted when all stock is depleted. +
{% endif %} @@ -221,6 +225,7 @@ item: {{ item.id }}, }, reload: true, + follow: true, } ); } diff --git a/InvenTree/stock/views.py b/InvenTree/stock/views.py index 6ecdf1f3a2..1431cb3693 100644 --- a/InvenTree/stock/views.py +++ b/InvenTree/stock/views.py @@ -10,6 +10,7 @@ from django.views.generic.edit import FormMixin from django.views.generic import DetailView, ListView from django.forms.models import model_to_dict from django.forms import HiddenInput +from django.urls import reverse from django.utils.translation import ugettext as _ @@ -310,6 +311,19 @@ class StockAdjust(AjaxView, FormMixin): data['success'] = result + # Special case - Single Stock Item + # If we deplete the stock item, we MUST redirect to a new view + single_item = len(self.stock_items) == 1 + + if result and single_item: + + # Was the entire stock taken? + item = self.stock_items[0] + + if item.quantity == 0: + # Instruct the form to redirect + data['url'] = reverse('stock-index') + return self.renderJsonResponse(request, form, data=data) def do_action(self):