[19.0][FIX] stock_request: avoid RecursionError on cyclic move_orig_ids - #103
Conversation
|
Hi @etobella, @LoisRForgeFlow, |
|
Hi @etobella, @LoisRForgeFlow, |
|
Hi @LoisRForgeFlow @etobella , when you have a moment, could you give this one a quick look? 🙏 It's a small, self-contained fix: _get_all_origin_moves walked move_orig_ids recursively without tracking visited moves, so a cyclic graph (returning both legs of a two-step inter-warehouse transfer that share a transit location) makes the stock.request.order form unopenable with RecursionError. The change only makes that traversal iterative and cycle-safe, and it ships a regression test. Thanks a lot! |
LoisRForgeFlow
left a comment
There was a problem hiding this comment.
I tested the regression test and indeed is correct. Thanks for the patch!
|
@etobella Unless you have anything against, this is good to merge from my side. |
| "name": "Stock Request", | ||
| "summary": "Internal request for stock", | ||
| "version": "19.0.1.0.1", | ||
| "version": "19.0.1.0.2", |
There was a problem hiding this comment.
No need to bump the version manually; it will be bumped automatically when the PR is merged.
There was a problem hiding this comment.
@BhaveshHeliconia I've already removed the bump, thanks (sometimes we add it manually because it lets us include the PRs in our CI/CD)
_get_all_origin_moves walked move_orig_ids recursively without tracking the moves already visited. Returning both legs of a two-step inter-warehouse transfer that share a transit location links each leg's return move back to the other, so move_orig_ids becomes circular. Computing move_ids / picking_ids then recurses infinitely and raises RecursionError, and the stock.request.order form fails to load (RPC_ERROR / OwlError on onWillStart). Make the traversal iterative and keep the already-visited moves in the accumulator, so any cyclic move_orig_ids graph a user can build from the UI is handled safely.
7328c11 to
bf11993
Compare
|
This PR has the |
|
/ocabot merge patch |
|
On my way to merge this fine PR! |
|
Congratulations, your PR was merged at 72e0550. Thanks a lot for contributing to OCA. ❤️ |
Description
Opening the stock request order form crashes with
RecursionError: maximum recursion depth exceeded(RPC_ERROR / OwlError ononWillStart) whenever the underlyingmove_orig_idsgraph is circular. Stock and quantities stay correct — only the traceability compute breaks.This happens when both legs of a two-step inter-warehouse transfer (which share a common transit location) are returned: each leg's return move ends up linked back to the other, forming a cycle in
move_orig_ids.stock.request._get_all_origin_moveswalkedmove_orig_idsrecursively without tracking the moves already visited, so on such a cycle it recurses infinitely. It is reached from_compute_move_ids→_compute_picking_ids(stock_request) →_compute_picking_ids(stock_request_order).Change
_get_all_origin_movesiterative and cycle-safe: keep the already-visited moves in the accumulator and never revisit them. Nomove_orig_idsgraph a user can build from the UI should raiseRecursionError.How to test
An automated test (
test_compute_move_ids_cyclic_origin_moves) reproduces the cycle and asserts the compute no longer raises.