mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-17 04:25:42 +00:00
Exclude expired stock from builds
This commit is contained in:
@ -27,6 +27,8 @@ from InvenTree.helpers import increment, getSetting, normalize
|
||||
from InvenTree.validators import validate_build_order_reference
|
||||
from InvenTree.models import InvenTreeAttachment
|
||||
|
||||
from common.models import InvenTreeSetting
|
||||
|
||||
import InvenTree.fields
|
||||
|
||||
from stock import models as StockModels
|
||||
@ -819,6 +821,10 @@ class Build(MPTTModel):
|
||||
location__in=[loc for loc in self.take_from.getUniqueChildren()]
|
||||
)
|
||||
|
||||
# Exclude expired stock items
|
||||
if not InvenTreeSetting.get_setting('STOCK_ALLOW_EXPIRED_BUILD'):
|
||||
items = items.exclude(StockModels.StockItem.EXPIRED_FILTER)
|
||||
|
||||
return items
|
||||
|
||||
@property
|
||||
|
@ -903,6 +903,7 @@ class BuildItemCreate(AjaxCreateView):
|
||||
|
||||
if self.build and self.part:
|
||||
available_items = self.build.availableStockItems(self.part, self.output)
|
||||
|
||||
form.fields['stock_item'].queryset = available_items
|
||||
|
||||
self.available_stock = form.fields['stock_item'].queryset.all()
|
||||
|
Reference in New Issue
Block a user