Skip to content

Commit dac6c6a

Browse files
committed
Merge PR #630 into 15.0
Signed-off-by simahawk
2 parents 8bb6f2c + 5d0a00a commit dac6c6a

8 files changed

Lines changed: 44 additions & 5 deletions

File tree

.oca/oca-port/blacklist/queue_job.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
"466": "Reverts https://github.com/OCA/queue/pull/387",
77
"511": "Icon already updated for v15",
88
"443": "Squashed w/ 453, commit rewritten",
9-
"453": "Squashed w/ 443, commit rewritten"
9+
"453": "Squashed w/ 443, commit rewritten",
10+
"403": "Lint fixes, relevant code already ported",
11+
"537": "Already ported",
12+
"571": "Already ported"
1013
}
1114
}

queue_job/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
{
44
"name": "Job Queue",
5-
"version": "15.0.2.3.5",
5+
"version": "15.0.2.3.6",
66
"author": "Camptocamp,ACSONE SA/NV,Odoo Community Association (OCA)",
77
"website": "https://github.com/OCA/queue",
88
"license": "LGPL-3",

queue_job/controllers/main.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,16 @@ def create_test_job(
175175
size=1,
176176
failure_rate=0,
177177
):
178+
"""Create test jobs
179+
180+
Examples of urls:
181+
182+
* http://127.0.0.1:8069/queue_job/create_test_job: single job
183+
* http://127.0.0.1:8069/queue_job/create_test_job?size=10: a graph of 10 jobs
184+
* http://127.0.0.1:8069/queue_job/create_test_job?size=10&failure_rate=0.5:
185+
a graph of 10 jobs, half will fail
186+
187+
"""
178188
if not http.request.env.user.has_group("base.group_erp_manager"):
179189
raise Forbidden(_("Access Denied"))
180190

queue_job/job.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,19 @@ def identity_example(job_):
8989
Usually you will probably always want to include at least the name of the
9090
model and method.
9191
"""
92+
hasher = identity_exact_hasher(job_)
93+
return hasher.hexdigest()
94+
95+
96+
def identity_exact_hasher(job_):
97+
"""Prepare hasher object for identity_exact."""
9298
hasher = hashlib.sha1()
9399
hasher.update(job_.model_name.encode("utf-8"))
94100
hasher.update(job_.method_name.encode("utf-8"))
95101
hasher.update(str(sorted(job_.recordset.ids)).encode("utf-8"))
96102
hasher.update(str(job_.args).encode("utf-8"))
97103
hasher.update(str(sorted(job_.kwargs.items())).encode("utf-8"))
98-
99-
return hasher.hexdigest()
104+
return hasher
100105

101106

102107
@total_ordering
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)
2+
3+
from odoo.tools.sql import table_exists
4+
5+
6+
def migrate(cr, version):
7+
if table_exists(cr, "queue_job"):
8+
# Drop index 'queue_job_identity_key_state_partial_index',
9+
# it will be recreated during the update
10+
cr.execute("DROP INDEX IF EXISTS queue_job_identity_key_state_partial_index;")

queue_job/models/queue_job.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def init(self):
139139
self._cr.execute(
140140
"CREATE INDEX queue_job_identity_key_state_partial_index "
141141
"ON queue_job (identity_key) WHERE state in ('pending', "
142-
"'enqueued') AND identity_key IS NOT NULL;"
142+
"'enqueued', 'wait_dependencies') AND identity_key IS NOT NULL;"
143143
)
144144

145145
@api.depends("records")

queue_job/readme/USAGE.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,12 @@ tests), and it makes tests smaller.
318318
The best way to run such assertions on the enqueued jobs is to use
319319
``odoo.addons.queue_job.tests.common.trap_jobs()``.
320320

321+
Inside this context manager, instead of being added in the database's queue,
322+
jobs are pushed in an in-memory list. The context manager then provides useful
323+
helpers to verify that jobs have been enqueued with the expected arguments. It
324+
even can run the jobs of its list synchronously! Details in
325+
``odoo.addons.queue_job.tests.common.JobsTester``.
326+
321327
A very small example (more details in ``tests/common.py``):
322328

323329
.. code-block:: python

queue_job/views/queue_job_views.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,11 @@
244244
string="Failed"
245245
domain="[('state', '=', 'failed')]"
246246
/>
247+
<filter
248+
name="cancelled"
249+
string="Cancelled"
250+
domain="[('state', '=', 'cancelled')]"
251+
/>
247252
<group expand="0" string="Group By">
248253
<filter
249254
name="group_by_channel"

0 commit comments

Comments
 (0)