2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-05-05 14:58:50 +00:00

Build.getAutoAllocations() only selects parts from the designation location

This commit is contained in:
Oliver Walters 2019-05-10 19:03:45 +10:00
parent 468322fa9d
commit 3588161632
2 changed files with 6 additions and 0 deletions

View File

@ -21,6 +21,7 @@ class EditBuildForm(HelperForm):
'title', 'title',
'part', 'part',
'quantity', 'quantity',
'take_from',
'batch', 'batch',
'URL', 'URL',
'notes', 'notes',

View File

@ -146,6 +146,11 @@ class Build(models.Model):
stock = StockItem.objects.filter(part=item.sub_part) stock = StockItem.objects.filter(part=item.sub_part)
# Ensure that the available stock items are in the correct location
if self.take_from is not None:
# Filter for stock that is located downstream of the designated location
stock = stock.filter(location__in=[cat for cat in self.take_from.getUniqueChildren()])
# Only one StockItem to choose from? Default to that one! # Only one StockItem to choose from? Default to that one!
if len(stock) == 1: if len(stock) == 1:
stock_item = stock[0] stock_item = stock[0]