mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Limit user choices in the manual part allocation form
This commit is contained in:
parent
bbf46c4580
commit
763e0a991c
@ -149,7 +149,7 @@ class Build(models.Model):
|
||||
# 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()])
|
||||
stock = stock.filter(location__in=[loc for loc in self.take_from.getUniqueChildren()])
|
||||
|
||||
# Only one StockItem to choose from? Default to that one!
|
||||
if len(stock) == 1:
|
||||
|
@ -374,6 +374,16 @@ class BuildItemCreate(AjaxCreateView):
|
||||
query = query.filter(part=part_id)
|
||||
|
||||
if build_id is not None:
|
||||
try:
|
||||
build = Build.objects.get(id=build_id)
|
||||
|
||||
if build.take_from is not None:
|
||||
# Limit query to stock items that are downstream of the 'take_from' location
|
||||
query = query.filter(location__in=[loc for loc in build.take_from.getUniqueChildren()])
|
||||
|
||||
except Build.DoesNotExist:
|
||||
pass
|
||||
|
||||
# Exclude StockItem objects which are already allocated to this build and part
|
||||
query = query.exclude(id__in=[item.stock_item.id for item in BuildItem.objects.filter(build=build_id, stock_item__part=part_id)])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user