diff --git a/README.md b/README.md index 497ebc99ea..e852dd8a96 100644 --- a/README.md +++ b/README.md @@ -24,14 +24,14 @@ addon | version | maintainers | summary [base_export_async](base_export_async/) | 14.0.1.0.1 | | Asynchronous export with job queue [base_import_async](base_import_async/) | 14.0.1.0.2 | | Import CSV files in the background [export_async_schedule](export_async_schedule/) | 14.0.1.0.1 | [](https://github.com/guewen) | Generate and send exports by emails on a schedule -[queue_job](queue_job/) | 14.0.3.9.3 | [](https://github.com/guewen) | Job Queue +[queue_job](queue_job/) | 14.0.3.10.0 | [](https://github.com/guewen) | Job Queue [queue_job_batch](queue_job_batch/) | 14.0.1.0.2 | | Job Queue Batch [queue_job_context](queue_job_context/) | 14.0.1.0.1 | [](https://github.com/AshishHirapara) | Queue Job, prepare context before enqueue keys [queue_job_cron](queue_job_cron/) | 14.0.2.0.0 | | Scheduled Actions as Queue Jobs [queue_job_cron_jobrunner](queue_job_cron_jobrunner/) | 14.0.1.0.3 | [](https://github.com/ivantodorovich) | Run jobs without a dedicated JobRunner [queue_job_subscribe](queue_job_subscribe/) | 14.0.1.0.1 | | Control which users are subscribed to queue job notifications [test_base_import_async](test_base_import_async/) | 14.0.1.0.1 | | Test suite for base_import_async. Normally you don't need to install this. -[test_queue_job](test_queue_job/) | 14.0.3.4.1 | | Queue Job Tests +[test_queue_job](test_queue_job/) | 14.0.3.5.0 | | Queue Job Tests [test_queue_job_batch](test_queue_job_batch/) | 14.0.1.0.0 | | Test Job Queue Batch [//]: # (end addons) diff --git a/queue_job/README.rst b/queue_job/README.rst index d07f34b59c..b6f92f97b0 100644 --- a/queue_job/README.rst +++ b/queue_job/README.rst @@ -7,7 +7,7 @@ Job Queue !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:92d72e5fbf867c96e9c7ae0ab9bb7f70a2f793e83ed9bf8389d6e35fe970828a + !! source digest: sha256:e7a4f68d9c4b4d117e1e9a6f0096eaf1fd4bf1914b38d934779c93c49958a31a !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png diff --git a/queue_job/__manifest__.py b/queue_job/__manifest__.py index 7c8c95586f..c8c69184b1 100644 --- a/queue_job/__manifest__.py +++ b/queue_job/__manifest__.py @@ -2,7 +2,7 @@ { "name": "Job Queue", - "version": "14.0.3.9.3", + "version": "14.0.3.10.0", "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 89c408906a..a6487b7d9e 100644 --- a/queue_job/static/description/index.html +++ b/queue_job/static/description/index.html @@ -367,7 +367,7 @@
This addon adds an integrated Job Queue to Odoo.
diff --git a/queue_job/tests/common.py b/queue_job/tests/common.py index 5ca2f079e7..76c03218ba 100644 --- a/queue_job/tests/common.py +++ b/queue_job/tests/common.py @@ -256,6 +256,7 @@ def _add_job(self, *args, **kwargs): if not job.identity_key or all( j.identity_key != job.identity_key for j in self.enqueued_jobs ): + self._prepare_context(job) self.enqueued_jobs.append(job) patcher = mock.patch.object(job, "store") @@ -274,6 +275,13 @@ def _add_job(self, *args, **kwargs): ) return job + def _prepare_context(self, job): + # pylint: disable=context-overridden + job_model = job.job_model.with_context({}) + field_records = job_model._fields["records"] + # Filter the context to simulate store/load of the job + job.recordset = field_records.convert_to_write(job.recordset, job_model) + def __enter__(self): return self diff --git a/test_queue_job/__manifest__.py b/test_queue_job/__manifest__.py index 354e85304a..85a7861365 100644 --- a/test_queue_job/__manifest__.py +++ b/test_queue_job/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Queue Job Tests", - "version": "14.0.3.4.1", + "version": "14.0.3.5.0", "author": "Camptocamp,Odoo Community Association (OCA)", "license": "LGPL-3", "category": "Generic Modules", diff --git a/test_queue_job/tests/test_delay_mocks.py b/test_queue_job/tests/test_delay_mocks.py index 740b77d30b..bf02693c3a 100644 --- a/test_queue_job/tests/test_delay_mocks.py +++ b/test_queue_job/tests/test_delay_mocks.py @@ -268,6 +268,27 @@ def test_trap_jobs_perform(self): self.assertEqual(logs[2].message, "test_trap_jobs_perform graph 3") self.assertEqual(logs[3].message, "test_trap_jobs_perform graph 1") + def test_trap_jobs_prepare_context(self): + """Verify that context is filtered consistently. + + Method '_job_prepare_context_before_enqueue_keys' is redefined on 'test.queue.job'. + Key 'lang' is whitelisted, while key 'config_key' is filtered out. + """ + # pylint: disable=context-overridden + with trap_jobs() as trap: + model1 = self.env["test.queue.job"].with_context({"config_key": 42}) + model2 = self.env["test.queue.job"].with_context( + {"config_key": 42, "lang": "it_IT"} + ) + model1.with_delay().testing_method("0", "K", return_context=1) + model2.with_delay().testing_method("0", "K", return_context=1) + + [job1, job2] = trap.enqueued_jobs + trap.perform_enqueued_jobs() + + self.assertEqual(job1.result, {"job_uuid": mock.ANY}) + self.assertEqual(job2.result, {"job_uuid": mock.ANY, "lang": "it_IT"}) + def test_mock_with_delay(self): with mock_with_delay() as (delayable_cls, delayable): self.env["test.queue.job"].button_that_uses_with_delay()