fix(spp_drims): show only reachable states on the dispatch status bar - #392
Draft
emjay0921 wants to merge 1 commit into
Draft
fix(spp_drims): show only reachable states on the dispatch status bar#392emjay0921 wants to merge 1 commit into
emjay0921 wants to merge 1 commit into
Conversation
action_create_dispatch confirms a request dispatch the moment it creates it, so a dispatch never sits in Draft. Both Draft and Waiting were still drawn as greyed-out steps on the form, inherited from stock.picking. Core renders two status bars for stock.picking, split on picking_type_code. A dispatch is outgoing, so it picks up the non-incoming one with draft,confirmed,assigned,done. Narrow that bar to exclude dispatches and add a dispatch-only bar showing assigned,done, rather than editing the shared statusbar_visible — which would have dropped Draft from every non-incoming transfer in the database. The three bars' conditions are mutually exclusive, so exactly one renders per picking. Waiting is hidden as a *future* step only, and deliberately so: contrary to the ticket's rationale it is genuinely reachable. DRIMS allocation writes quantity_allocated on the request line and creates no Odoo reservation, so two requests can allocate the same units and whichever dispatches second has nothing to reserve and lands in confirmed. That is safe here because the statusbar widget always renders the current value even when it is excluded from statusbar_visible (getAllItems filters on `value === currentValue || visibleSelection.includes(value)`), so a dispatch short of stock still shows Waiting to warehouse staff. Both facts are covered by tests so neither gets "simplified" later on a false assumption, and the mutual exclusivity test evaluates the real invisible expressions per picking kind rather than matching strings. OP#1086
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 19.0 #392 +/- ##
=======================================
Coverage 72.27% 72.27%
=======================================
Files 1010 1008 -2
Lines 60741 60739 -2
=======================================
Hits 43900 43900
+ Misses 16841 16839 -2
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
emjay0921
marked this pull request as draft
August 4, 2026 02:14
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.
Why is this change needed?
action_create_dispatchconfirms a request dispatch the moment it creates it, so a dispatch never sits in Draft. Both Draft and Waiting were still drawn as greyed-out steps on the form, inherited fromstock.picking— visual clutter, and two states warehouse staff can never reach.How was the change implemented?
Core renders two status bars for
stock.picking, split onpicking_type_code:statusbar_visibledraft,assigned,donedraft,confirmed,assigned,doneA dispatch is outgoing, so it picks up the second one. Rather than editing that shared
statusbar_visible— which would have dropped Draft from every non-incoming transfer in the database — this narrows it to exclude dispatches and adds a third, dispatch-only bar:draft,assigned,done— untoucheddraft,confirmed,assigned,done— unchangedassigned,doneThe three conditions are mutually exclusive, so exactly one bar renders per picking. There is a test that evaluates the real
invisibleexpressions against four picking shapes to pin that, rather than pattern-matching the attribute strings.A correction to the ticket's rationale
The ticket states Waiting is unreachable because "stock is already reserved from the allocation step". That is not the case, and it was worth checking before hiding the state.
_allocate_stock_fifoonly writesquantity_allocatedon the request line; it creates no Odoo reservation. So two requests can allocate the same units before either dispatches, and the second finds nothing to reserve. Reproduced on a dev instance:Hiding Waiting is nevertheless safe, for a reason specific to the widget:
getAllItems()filters the selection withvalue === currentValue || visibleSelection.includes(value)(statusbar_field.js), so an excluded state still renders when it is the current one. Waiting therefore disappears only as a greyed-out future step — a dispatch genuinely short of stock still displays Waiting and stays visible to warehouse staff. That is what makes the AC implementable as written.Both facts are covered by tests (
test_dispatch_is_confirmed_on_creation_never_draft,test_waiting_state_is_reachable_for_a_dispatch) so neither gets "simplified" later on a false assumption.Worth noting for whoever reviews: unlike x2many
create/delete,statusbar_visiblegenuinely is read from the field tag (statusbar_field.js:372,visibleSelection: attrs.statusbar_visible?...), which is why core sets it that way.New unit tests
spp_drims/tests/test_dispatch_statusbar.py— 5 tests:assigned,done, correctly conditioned.Unit tests executed by the author
Full module suite:
All 5 new tests confirmed executing by name in the log.
./spp lint(ruff, ruff-format, prettier) passes on all three files.Also verified the combined arch on a fresh database: three status bars, with the conditions above.
How to test manually
demo-scripts/ds-openspp2-op1086-spp_drims-20260803-01.pybuilds one picking per case on a fresh DB, including a dispatch genuinely stuck in Waiting (via the real allocation race, not a contrived write).Related links
Notes for the reviewer
readme/HISTORY.mdand the manifest version are deliberately untouched — per our convention those land on19.0after merge, to avoid conflicts between concurrent PRs on the same module.This branch is independent of #390 (OP#1087) and #391 (OP#1057). It only touches the
<header>region ofstock_picking_views.xml, whereas #391 touches the Operations field in the same file, so they occupy different hunks and should merge in either order.🤖 Generated with Claude Code