diff --git a/README.md b/README.md
index 0c224f3b99..3f1ad58350 100644
--- a/README.md
+++ b/README.md
@@ -24,13 +24,13 @@ addon | version | maintainers | summary
--- | --- | --- | ---
[base_export_async](base_export_async/) | 16.0.1.2.0 | | Asynchronous export with job queue
[base_import_async](base_import_async/) | 16.0.1.2.1 | | Import CSV files in the background
-[queue_job](queue_job/) | 16.0.3.0.1 |
| Job Queue
+[queue_job](queue_job/) | 16.0.3.0.2 |
| Job Queue
[queue_job_batch](queue_job_batch/) | 16.0.1.0.1 | | Job Queue Batch
[queue_job_cron](queue_job_cron/) | 16.0.2.1.0 | | Scheduled Actions as Queue Jobs
[queue_job_cron_jobrunner](queue_job_cron_jobrunner/) | 16.0.1.1.0 |
| Run jobs without a dedicated JobRunner
[queue_job_subscribe](queue_job_subscribe/) | 16.0.1.1.0 | | Control which users are subscribed to queue job notifications
[queue_job_web_notify](queue_job_web_notify/) | 16.0.1.0.0 | | This module allows to display a notification to the related user of a failed job. It uses the web_notify notification feature.
-[test_queue_job](test_queue_job/) | 16.0.2.5.0 |
| Queue Job Tests
+[test_queue_job](test_queue_job/) | 16.0.2.5.1 |
| Queue Job Tests
[test_queue_job_batch](test_queue_job_batch/) | 16.0.1.0.0 | | Test Job Queue Batch
diff --git a/queue_job/README.rst b/queue_job/README.rst
index a37109a861..d26a7bd27b 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:078ff84f658e3a8953ba800728b7b57d5effbaa0083ff7ab9c1b8134b77bb885
+ !! source digest: sha256:7387273e60279f8c69c8b3052a07d6fed49d33f14949cbfd7a41f41852ccbb4d
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png
diff --git a/queue_job/__manifest__.py b/queue_job/__manifest__.py
index a5d362681a..60cff1e25c 100644
--- a/queue_job/__manifest__.py
+++ b/queue_job/__manifest__.py
@@ -2,7 +2,7 @@
{
"name": "Job Queue",
- "version": "16.0.3.0.1",
+ "version": "16.0.3.0.2",
"author": "Camptocamp,ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/queue",
"license": "LGPL-3",
diff --git a/queue_job/job.py b/queue_job/job.py
index b2d64c6d34..9610511927 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"
@@ -533,8 +554,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
@@ -705,6 +726,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)
diff --git a/queue_job/static/description/index.html b/queue_job/static/description/index.html
index 4d9d62b9c8..89ea6306a4 100644
--- a/queue_job/static/description/index.html
+++ b/queue_job/static/description/index.html
@@ -372,7 +372,7 @@
This addon adds an integrated Job Queue to Odoo.
diff --git a/test_queue_job/__manifest__.py b/test_queue_job/__manifest__.py index 42c5851dbe..1a19acff55 100644 --- a/test_queue_job/__manifest__.py +++ b/test_queue_job/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Queue Job Tests", - "version": "16.0.2.5.0", + "version": "16.0.2.5.1", "author": "Camptocamp,Odoo Community Association (OCA)", "license": "LGPL-3", "category": "Generic Modules", diff --git a/test_queue_job/data/queue_job_function_data.xml b/test_queue_job/data/queue_job_function_data.xml index 8338045141..c01903b0f3 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 @@