2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-02-06 13:25:53 +00:00

[bug] Trim stock allocation (#11060)

* Trim stock allocation

- Handle condition where allocated quantity exceeds available stock
- Prevent silent failure of build completion

* Fix display in buildallocatedstock table

* Consolidate table columns

* Fetch substitutes for BOM table
This commit is contained in:
Oliver
2025-12-23 12:16:51 +11:00
committed by GitHub
parent 9d2ac521ef
commit c1d7f2a300
4 changed files with 19 additions and 20 deletions

View File

@@ -1887,7 +1887,7 @@ class BuildItem(InvenTree.models.InvenTreeMetadataModel):
return self.build_line.bom_item if self.build_line else None
@transaction.atomic
def complete_allocation(self, quantity=None, notes='', user=None) -> None:
def complete_allocation(self, quantity=None, notes: str = '', user=None) -> None:
"""Complete the allocation of this BuildItem into the output stock item.
Arguments:
@@ -1910,9 +1910,7 @@ class BuildItem(InvenTree.models.InvenTreeMetadataModel):
# Ensure we are not allocating more than available
if quantity > item.quantity:
raise ValidationError({
'quantity': _('Allocated quantity exceeds available stock quantity')
})
quantity = item.quantity
# Split the allocated stock if there are more available than allocated
if item.quantity > quantity: