mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Ensure that a StockItem is not already allocated to a Build
This commit is contained in:
parent
7c70b31af4
commit
ff14b0b363
@ -32,7 +32,7 @@ class Build(models.Model):
|
||||
URL: External URL for extra information
|
||||
notes: Text notes
|
||||
"""
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return "Build {q} x {part}".format(q=self.quantity, part=str(self.part))
|
||||
|
||||
@ -137,6 +137,12 @@ class Build(models.Model):
|
||||
if len(stock) == 1:
|
||||
stock_item = stock[0]
|
||||
|
||||
# Check that we have not already allocated this stock-item against this build
|
||||
build_items = BuildItem.objects.filter(build=self, stock_item=stock_item)
|
||||
|
||||
if len(build_items) > 0:
|
||||
continue
|
||||
|
||||
# Are there any parts available?
|
||||
if stock_item.quantity > 0:
|
||||
# Only take as many as are available
|
||||
|
Loading…
Reference in New Issue
Block a user