Add a stock item transaction when installing items into a build output

This commit is contained in:
Oliver Walters 2022-04-28 22:58:58 +10:00
parent f531e354b9
commit b63352ce20

View File

@ -1260,7 +1260,7 @@ class BuildItem(models.Model):
})
@transaction.atomic
def complete_allocation(self, user):
def complete_allocation(self, user, notes=''):
"""
Complete the allocation of this BuildItem into the output stock item.
@ -1286,8 +1286,13 @@ class BuildItem(models.Model):
self.save()
# Install the stock item into the output
item.belongs_to = self.install_into
item.save()
self.install_into.installStockItem(
item,
self.quantity,
user,
notes
)
else:
# Simply remove the items from stock
item.take_stock(