Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ Available addons
----------------
addon | version | maintainers | summary
--- | --- | --- | ---
[queue_job](queue_job/) | 18.0.1.2.1 | [![guewen](https://github.com/guewen.png?size=30px)](https://github.com/guewen) | Job Queue
[queue_job](queue_job/) | 18.0.1.2.2 | [![guewen](https://github.com/guewen.png?size=30px)](https://github.com/guewen) | Job Queue
[queue_job_batch](queue_job_batch/) | 18.0.1.0.0 | | Job Queue Batch
[queue_job_cron](queue_job_cron/) | 18.0.1.1.0 | | Scheduled Actions as Queue Jobs
[queue_job_cron_jobrunner](queue_job_cron_jobrunner/) | 18.0.1.0.0 | [![ivantodorovich](https://github.com/ivantodorovich.png?size=30px)](https://github.com/ivantodorovich) | Run jobs without a dedicated JobRunner
[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.1.0.0 | | Queue Job Tests
[test_queue_job](test_queue_job/) | 18.0.1.0.1 | | Queue Job Tests
[test_queue_job_batch](test_queue_job_batch/) | 18.0.1.0.0 | | Test Job Queue Batch

[//]: # (end addons)
Expand Down
2 changes: 1 addition & 1 deletion queue_job/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Job Queue
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:2b47ea2c9a7ab9a2b5ec87defad309384cfbc8d5640544a0233c4c7510c5bd4e
!! source digest: sha256:457b3cda8ba43e54d1aa390b5e3be8291b6f58bb375d2fde4bc07b97634432df
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png
Expand Down
2 changes: 1 addition & 1 deletion queue_job/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{
"name": "Job Queue",
"version": "18.0.1.2.1",
"version": "18.0.1.2.2",
"author": "Camptocamp,ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/queue",
"license": "LGPL-3",
Expand Down
48 changes: 24 additions & 24 deletions queue_job/static/description/index.html

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions queue_job/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,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")
Expand All @@ -273,6 +274,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

Expand Down
2 changes: 1 addition & 1 deletion test_queue_job/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "Queue Job Tests",
"version": "18.0.1.0.0",
"version": "18.0.1.0.1",
"author": "Camptocamp,Odoo Community Association (OCA)",
"license": "LGPL-3",
"category": "Generic Modules",
Expand Down
22 changes: 22 additions & 0 deletions test_queue_job/tests/test_delay_mocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,28 @@ 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):
"""Context is transferred to the job according to an allow-list.

Default allow-list is:
("tz", "lang", "allowed_company_ids", "force_company", "active_test")
It can be customized in ``Base._job_prepare_context_before_enqueue_keys``.
"""
# 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()
Expand Down