diff --git a/InvenTree/order/views.py b/InvenTree/order/views.py index d5658909bb..bd758e39fb 100644 --- a/InvenTree/order/views.py +++ b/InvenTree/order/views.py @@ -24,6 +24,8 @@ from company.models import Company, SupplierPart from stock.models import StockItem, StockLocation from part.models import Part +from common.models import InvenTreeSetting + from . import forms as order_forms from InvenTree.views import AjaxView, AjaxCreateView, AjaxUpdateView, AjaxDeleteView @@ -1359,7 +1361,8 @@ class SalesOrderAllocationCreate(AjaxCreateView): try: line = SalesOrderLineItem.objects.get(pk=line_id) - queryset = form.fields['item'].queryset + # Construct a queryset for allowable stock items + queryset = StockItem.objects.filter(StockItem.IN_STOCK_FILTER) # Ensure the part reference matches queryset = queryset.filter(part=line.part) @@ -1369,6 +1372,10 @@ class SalesOrderAllocationCreate(AjaxCreateView): queryset = queryset.exclude(pk__in=allocated) + # Exclude stock items which have expired + if not InvenTreeSetting.get_setting('STOCK_ALLOW_EXPIRED_SALE'): + queryset = queryset.exclude(StockItem.EXPIRED_FILTER) + form.fields['item'].queryset = queryset # Hide the 'line' field diff --git a/InvenTree/templates/InvenTree/index.html b/InvenTree/templates/InvenTree/index.html index d5b2c87148..9fcb818c7a 100644 --- a/InvenTree/templates/InvenTree/index.html +++ b/InvenTree/templates/InvenTree/index.html @@ -1,5 +1,6 @@ {% extends "base.html" %} {% load i18n %} +{% load inventree_extras %} {% block page_title %} InvenTree | {% trans "Index" %} {% endblock %} @@ -22,7 +23,10 @@ InvenTree | {% trans "Index" %}