mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Prevent expired stock from being added to a sales order
This commit is contained in:
parent
9b086560cb
commit
580e7599a0
@ -24,6 +24,8 @@ from company.models import Company, SupplierPart
|
|||||||
from stock.models import StockItem, StockLocation
|
from stock.models import StockItem, StockLocation
|
||||||
from part.models import Part
|
from part.models import Part
|
||||||
|
|
||||||
|
from common.models import InvenTreeSetting
|
||||||
|
|
||||||
from . import forms as order_forms
|
from . import forms as order_forms
|
||||||
|
|
||||||
from InvenTree.views import AjaxView, AjaxCreateView, AjaxUpdateView, AjaxDeleteView
|
from InvenTree.views import AjaxView, AjaxCreateView, AjaxUpdateView, AjaxDeleteView
|
||||||
@ -1359,7 +1361,8 @@ class SalesOrderAllocationCreate(AjaxCreateView):
|
|||||||
try:
|
try:
|
||||||
line = SalesOrderLineItem.objects.get(pk=line_id)
|
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
|
# Ensure the part reference matches
|
||||||
queryset = queryset.filter(part=line.part)
|
queryset = queryset.filter(part=line.part)
|
||||||
@ -1369,6 +1372,10 @@ class SalesOrderAllocationCreate(AjaxCreateView):
|
|||||||
|
|
||||||
queryset = queryset.exclude(pk__in=allocated)
|
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
|
form.fields['item'].queryset = queryset
|
||||||
|
|
||||||
# Hide the 'line' field
|
# Hide the 'line' field
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
{% load inventree_extras %}
|
||||||
{% block page_title %}
|
{% block page_title %}
|
||||||
InvenTree | {% trans "Index" %}
|
InvenTree | {% trans "Index" %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@ -22,7 +23,10 @@ InvenTree | {% trans "Index" %}
|
|||||||
<div class='col-sm-4'>
|
<div class='col-sm-4'>
|
||||||
{% if roles.stock.view %}
|
{% if roles.stock.view %}
|
||||||
{% include "InvenTree/low_stock.html" with collapse_id="order" %}
|
{% include "InvenTree/low_stock.html" with collapse_id="order" %}
|
||||||
|
{% settings_value "STOCK_ENABLE_EXPIRY" as expiry %}
|
||||||
|
{% if expiry %}
|
||||||
{% include "InvenTree/expired_stock.html" with collapse_id="expired" %}
|
{% include "InvenTree/expired_stock.html" with collapse_id="expired" %}
|
||||||
|
{% endif %}
|
||||||
{% include "InvenTree/required_stock_build.html" with collapse_id="stock_to_build" %}
|
{% include "InvenTree/required_stock_build.html" with collapse_id="stock_to_build" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user