Skip to content

Commit

Permalink
Fix auto-allocation of build outputs (#5378) (#5379)
Browse files Browse the repository at this point in the history
- Creation of BuildItem objects was using old model references

(cherry picked from commit 668dab4)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
  • Loading branch information
github-actions[bot] and SchrodingersGat committed Aug 1, 2023
1 parent 699fb83 commit ca986cb
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions InvenTree/build/models.py
Expand Up @@ -719,14 +719,22 @@ def _add_tracking_entry(output, user):
if items.exists() and items.count() == 1:
stock_item = items[0]

# Allocate the stock item
BuildItem.objects.create(
build=self,
bom_item=bom_item,
stock_item=stock_item,
quantity=1,
install_into=output,
)
# Find the 'BuildLine' object which points to this BomItem
try:
build_line = BuildLine.objects.get(
build=self,
bom_item=bom_item
)

# Allocate the stock items against the BuildLine
BuildItem.objects.create(
build_line=build_line,
stock_item=stock_item,
quantity=1,
install_into=output,
)
except BuildLine.DoesNotExist:
pass

else:
"""Create a single build output of the given quantity."""
Expand Down

0 comments on commit ca986cb

Please sign in to comment.