2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-17 12:35:46 +00:00

Add stock tracking code to indicate stock has been consumed by a build order

This commit is contained in:
Oliver
2022-02-25 15:56:09 +11:00
parent bb164ed72a
commit 9e3406efc9
3 changed files with 15 additions and 4 deletions

View File

@ -1167,7 +1167,12 @@ class BuildItem(models.Model):
if item.part.trackable:
# Split the allocated stock if there are more available than allocated
if item.quantity > self.quantity:
item = item.splitStock(self.quantity, None, user)
item = item.splitStock(
self.quantity,
None,
user,
code=StockHistoryCode.BUILD_CONSUMED,
)
# Make sure we are pointing to the new item
self.stock_item = item
@ -1178,7 +1183,11 @@ class BuildItem(models.Model):
item.save()
else:
# Simply remove the items from stock
item.take_stock(self.quantity, user)
item.take_stock(
self.quantity,
user,
code=StockHistoryCode.BUILD_CONSUMED
)
def getStockItemThumbnail(self):
"""