Skip to content

[16.0][FIX] queue_job: rebind args/kwargs lazily to the job's current cursor - #967

Merged
OCA-git-bot merged 2 commits into
OCA:16.0from
nuobit:16.0-fix-queue_job-rebind-args-lazily
Aug 21, 2026
Merged

[16.0][FIX] queue_job: rebind args/kwargs lazily to the job's current cursor#967
OCA-git-bot merged 2 commits into
OCA:16.0from
nuobit:16.0-fix-queue_job-rebind-args-lazily

Conversation

@eantones

Copy link
Copy Markdown
Contributor

Supersedes #926.

Job.in_temporary_env() rebinds self.recordset to the inner cursor via the @env.setter, but leaves self.args and self.kwargs on the outer worker cursor where _prevent_commit is patched. A cr.commit() reached through any recordset argument then raises RuntimeError: Commit is forbidden in queue jobs even with allow_commit=True. Typical case: a connector exporter taking a binding and a related record, committing inside binder.bind_export(...).

Introduced by #910.

Fix: args and kwargs are stored in _args/_kwargs and exposed as properties that rebind any recordset inside (recursing into lists, tuples and dicts) to self.env.cr on access — only the cursor changes, uid/su/context are kept. in_temporary_env() goes back to a plain env swap.

Regression test in test_queue_job passes the same recordset as positional arg, list element and dict value, checks cursor identity in all three, then commits. Run through RunJobController._runjob.

The same issue exists on 18.0 and 19.0; ports will follow once this is merged.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @sbidoul, @guewen,
some modules you are maintaining are being modified, check this out!

@eantones

Copy link
Copy Markdown
Contributor Author

Hi @guewen, no worries about the delay. Here it is as its own PR, same code as the branch you preferred, unchanged. Thanks again for the suggestion.

@guewen

guewen commented Aug 20, 2026

Copy link
Copy Markdown
Member

Thanks!

@guewen

guewen commented Aug 21, 2026

Copy link
Copy Markdown
Member

/ocabot merge patch

@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 16.0-ocabot-merge-pr-967-by-guewen-bump-patch, awaiting test results.

@OCA-git-bot
OCA-git-bot merged commit baa73b6 into OCA:16.0 Aug 21, 2026
11 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at 4ea642c. 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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants