mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-02 21:38:48 +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
|
URL: External URL for extra information
|
||||||
notes: Text notes
|
notes: Text notes
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Build {q} x {part}".format(q=self.quantity, part=str(self.part))
|
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:
|
if len(stock) == 1:
|
||||||
stock_item = stock[0]
|
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?
|
# Are there any parts available?
|
||||||
if stock_item.quantity > 0:
|
if stock_item.quantity > 0:
|
||||||
# Only take as many as are available
|
# Only take as many as are available
|
||||||
|
Loading…
x
Reference in New Issue
Block a user