Repository navigation
[bug] Fix broken build complete transition - #12696
Merged
SchrodingersGat merged 6 commits intoAug 24, 2026
Merged
Conversation
✅ Deploy Preview for inventree-web-pui-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #12696 +/- ##
==========================================
- Coverage 86.82% 86.81% -0.01%
==========================================
Files 1456 1455 -1
Lines 97652 97641 -11
Branches 11330 11321 -9
==========================================
- Hits 84786 84767 -19
- Misses 12800 12808 +8
Partials 66 66
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Bug Description
Recent update to
django-fsm2in #12507 has caused thebuild_completetransition to fail when running with thedjango-q2background worker.Overview
#12507 transitioned to
django-fsm2which provides decorators for state machine transition functions. For the most part this is a good refactor, however it has introduced a serious bug which causes build order line items to not be properly consumed when a build is completed.The
complete_buildmethod looks like this:This does two things, in sequence:
Later on, the background task then runs:
However, this now exits early as the build status has already been marked as COMPLETE. This is revealed in worker logs, that the
complete_buildbackground task exits early.Final State
The build is marked as complete, however the underlying build line allocations are not completed, and not consumed against the build order. Additionally, the allocated stock item quantity values are not reduced.
Bug Fix
If the completion task is offloaded to the background worker, the status is not changed - this is deferred to the background task instead
Fixing Corrupted Data
Luckily, this bug has not been pushed to stable and was only introduced a few days ago. However, there is a chance that users running on
latesthave completed build orders and left orphaned build allocations.To address this, run
invoke dev.shellfrom the InvenTree command line context, and run the following: