Skip to content

[19.0][FIX] stock_request: avoid RecursionError on cyclic move_orig_ids - #103

Merged
OCA-git-bot merged 1 commit into
OCA:19.0from
adhoc-dev:19.0-t-73232-les
Sep 8, 2026
Merged

[19.0][FIX] stock_request: avoid RecursionError on cyclic move_orig_ids#103
OCA-git-bot merged 1 commit into
OCA:19.0from
adhoc-dev:19.0-t-73232-les

Conversation

@les-adhoc

@les-adhoc les-adhoc commented Aug 27, 2026

Copy link
Copy Markdown

Description

Opening the stock request order form crashes with RecursionError: maximum recursion depth exceeded (RPC_ERROR / OwlError on onWillStart) whenever the underlying move_orig_ids graph 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_moves walked move_orig_ids recursively 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

  • Make _get_all_origin_moves iterative and cycle-safe: keep the already-visited moves in the accumulator and never revisit them. No move_orig_ids graph a user can build from the UI should raise RecursionError.

How to test

  1. Create a stock request that generates a two-step transfer between two warehouses (route through the shared transit location).
  2. Validate the two pickings that are generated (outgoing from source, incoming to destination).
  3. On each of those two pickings, press Return and validate the returns.
  4. Re-open the stock request → before the fix the form fails to load; after, it opens normally.

An automated test (test_compute_move_ids_cyclic_origin_moves) reproduces the cycle and asserts the compute no longer raises.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @etobella, @LoisRForgeFlow,
some modules you are maintaining are being modified, check this out!

@les-adhoc les-adhoc closed this Aug 27, 2026
@les-adhoc les-adhoc reopened this Aug 27, 2026
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @etobella, @LoisRForgeFlow,
some modules you are maintaining are being modified, check this out!

@les-adhoc

Copy link
Copy Markdown
Author

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 LoisRForgeFlow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the regression test and indeed is correct. Thanks for the patch!

@LoisRForgeFlow

Copy link
Copy Markdown
Contributor

@etobella Unless you have anything against, this is good to merge from my side.

Comment thread stock_request/__manifest__.py Outdated
"name": "Stock Request",
"summary": "Internal request for stock",
"version": "19.0.1.0.1",
"version": "19.0.1.0.2",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to bump the version manually; it will be bumped automatically when the PR is merged.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.
@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@LoisRForgeFlow

Copy link
Copy Markdown
Contributor

/ocabot merge patch

@OCA-git-bot

Copy link
Copy Markdown
Contributor

On my way to merge this fine PR!
Prepared branch 19.0-ocabot-merge-pr-103-by-LoisRForgeFlow-bump-patch, awaiting test results.

@OCA-git-bot
OCA-git-bot merged commit 987eaee into OCA:19.0 Sep 8, 2026
7 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at 72e0550. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants