From 4f08e337194a20939a19a9d5b3bf790514d3a5ad Mon Sep 17 00:00:00 2001 From: Eric Antones Date: Thu, 2 Jul 2026 23:26:09 +0200 Subject: [PATCH 1/3] [FIX] queue_job: rebind args/kwargs lazily to the job's current cursor (cherry picked from commit 47b8c48015a62db65c0b6205f669558587c8baa5) [ported to 18.0: isinstance union syntax for ruff UP038] --- queue_job/job.py | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/queue_job/job.py b/queue_job/job.py index 032bdb933..c22dcf3b2 100644 --- a/queue_job/job.py +++ b/queue_job/job.py @@ -13,9 +13,30 @@ from random import randint import odoo +from odoo.models import BaseModel from .exception import FailedJobError, NoSuchJobError, RetryableJobError + +def _rebind_to_cr(value, cr): + """Rebind any BaseModel inside ``value`` to the cursor ``cr``. + + Recurses into lists, tuples and dicts. Preserves uid/su/context of each + inner env - only the cursor is swapped. Recordsets already bound to + ``cr`` and non-recordset values pass through untouched. Containers are + rebuilt, so in-place changes to the result are lost. + """ + if isinstance(value, BaseModel): + if value.env.cr is cr: + return value + return value.with_env(value.env(cr=cr)) + if isinstance(value, list | tuple): + return type(value)(_rebind_to_cr(v, cr) for v in value) + if isinstance(value, dict): + return {k: _rebind_to_cr(v, cr) for k, v in value.items()} + return value + + WAIT_DEPENDENCIES = "wait_dependencies" PENDING = "pending" ENQUEUED = "enqueued" @@ -512,8 +533,8 @@ def perform(self): def in_temporary_env(self): with self.env.registry.cursor() as new_cr: env = self.env - self._env = env(cr=new_cr) try: + self._env = env(cr=new_cr) yield finally: self._env = env @@ -687,6 +708,24 @@ def env(self): def _env(self, env): self.recordset = self.recordset.with_env(env) + @property + def args(self): + """Positional arguments, rebound to the job's current cursor.""" + return _rebind_to_cr(self._args, self.env.cr) + + @args.setter + def args(self, value): + self._args = value + + @property + def kwargs(self): + """Keyword arguments, rebound to the job's current cursor.""" + return _rebind_to_cr(self._kwargs, self.env.cr) + + @kwargs.setter + def kwargs(self, value): + self._kwargs = value + @property def func(self): recordset = self.recordset.with_context(job_uuid=self.uuid) From b1d7137587ef796ebb7aa78c62aa64acc88f6e2d Mon Sep 17 00:00:00 2001 From: ??? Date: Wed, 29 Apr 2026 12:59:11 +0200 Subject: [PATCH 2/3] [IMP] test_queue_job: add regression test for args/kwargs rebind in in_temporary_env (cherry picked from commit 8b16a588a63a56c28c5dae564360fc7f8a85ce04) --- test_queue_job/data/queue_job_function_data.xml | 8 ++++++++ test_queue_job/models/test_models.py | 13 +++++++++++++ test_queue_job/tests/test_job.py | 12 ++++++++++++ 3 files changed, 33 insertions(+) diff --git a/test_queue_job/data/queue_job_function_data.xml b/test_queue_job/data/queue_job_function_data.xml index 833804514..c01903b0f 100644 --- a/test_queue_job/data/queue_job_function_data.xml +++ b/test_queue_job/data/queue_job_function_data.xml @@ -20,6 +20,14 @@ job_with_retry_pattern__no_zero + + + job_commit_with_arg_records + + Date: Mon, 24 Aug 2026 11:34:05 +0000 Subject: [PATCH 3/3] [BOT] post-merge updates --- README.md | 4 ++-- queue_job/README.rst | 2 +- queue_job/__manifest__.py | 2 +- queue_job/static/description/index.html | 2 +- test_queue_job/__manifest__.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3d44e9cde..1a951b806 100644 --- a/README.md +++ b/README.md @@ -23,13 +23,13 @@ Available addons addon | version | maintainers | summary --- | --- | --- | --- [base_import_async](base_import_async/) | 18.0.1.0.0 | | Import CSV files in the background -[queue_job](queue_job/) | 18.0.3.1.3 | guewen sbidoul | Job Queue +[queue_job](queue_job/) | 18.0.3.1.4 | guewen sbidoul | Job Queue [queue_job_batch](queue_job_batch/) | 18.0.1.1.1 | | Job Queue Batch [queue_job_cron](queue_job_cron/) | 18.0.1.1.1 | | Scheduled Actions as Queue Jobs [queue_job_cron_jobrunner](queue_job_cron_jobrunner/) | 18.0.1.0.1 | ivantodorovich | Run jobs without a dedicated JobRunner [queue_job_profiler](queue_job_profiler/) | 18.0.1.0.1 | simahawk | Job Queue Profiler [queue_job_subscribe](queue_job_subscribe/) | 18.0.1.0.0 | | Control which users are subscribed to queue job notifications -[test_queue_job](test_queue_job/) | 18.0.2.0.5 | sbidoul | Queue Job Tests +[test_queue_job](test_queue_job/) | 18.0.2.0.6 | sbidoul | Queue Job Tests [test_queue_job_batch](test_queue_job_batch/) | 18.0.1.0.0 | | Test Job Queue Batch [//]: # (end addons) diff --git a/queue_job/README.rst b/queue_job/README.rst index b27a1675a..ce5ca27d3 100644 --- a/queue_job/README.rst +++ b/queue_job/README.rst @@ -11,7 +11,7 @@ Job Queue !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:85d54819989d21ee1d0349ecbcc7eeafe118baa9521524b1ce50fc3fdb890050 + !! source digest: sha256:c94de320505ef709649262a57968f03fa951a6ee88f25dc7fb097ecdde197c04 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png diff --git a/queue_job/__manifest__.py b/queue_job/__manifest__.py index fea6a3447..2f1ea0828 100644 --- a/queue_job/__manifest__.py +++ b/queue_job/__manifest__.py @@ -2,7 +2,7 @@ { "name": "Job Queue", - "version": "18.0.3.1.3", + "version": "18.0.3.1.4", "author": "Camptocamp,ACSONE SA/NV,Odoo Community Association (OCA)", "website": "https://github.com/OCA/queue", "license": "LGPL-3", diff --git a/queue_job/static/description/index.html b/queue_job/static/description/index.html index c5920c7ac..f2a9a4a5a 100644 --- a/queue_job/static/description/index.html +++ b/queue_job/static/description/index.html @@ -372,7 +372,7 @@

Job Queue

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:85d54819989d21ee1d0349ecbcc7eeafe118baa9521524b1ce50fc3fdb890050 +!! source digest: sha256:c94de320505ef709649262a57968f03fa951a6ee88f25dc7fb097ecdde197c04 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Mature License: LGPL-3 OCA/queue Translate me on Weblate Try me on Runboat

This addon adds an integrated Job Queue to Odoo.

diff --git a/test_queue_job/__manifest__.py b/test_queue_job/__manifest__.py index 0064305f7..8c81fcfbf 100644 --- a/test_queue_job/__manifest__.py +++ b/test_queue_job/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Queue Job Tests", - "version": "18.0.2.0.5", + "version": "18.0.2.0.6", "author": "Camptocamp,Odoo Community Association (OCA)", "license": "LGPL-3", "category": "Generic Modules",