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
5 changes: 4 additions & 1 deletion .oca/oca-port/blacklist/queue_job.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"466": "Reverts https://github.com/OCA/queue/pull/387",
"511": "Icon already updated for v15",
"443": "Squashed w/ 453, commit rewritten",
"453": "Squashed w/ 443, commit rewritten"
"453": "Squashed w/ 443, commit rewritten",
"403": "Lint fixes, relevant code already ported",
"537": "Already ported",
"571": "Already ported"
}
}
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": "15.0.2.3.5",
"version": "15.0.2.3.6",
"author": "Camptocamp,ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/queue",
"license": "LGPL-3",
Expand Down
10 changes: 10 additions & 0 deletions queue_job/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@ def create_test_job(
size=1,
failure_rate=0,
):
"""Create test jobs

Examples of urls:

* http://127.0.0.1:8069/queue_job/create_test_job: single job
* http://127.0.0.1:8069/queue_job/create_test_job?size=10: a graph of 10 jobs
* http://127.0.0.1:8069/queue_job/create_test_job?size=10&failure_rate=0.5:
a graph of 10 jobs, half will fail

"""
if not http.request.env.user.has_group("base.group_erp_manager"):
raise Forbidden(_("Access Denied"))

Expand Down
9 changes: 7 additions & 2 deletions queue_job/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,19 @@ def identity_example(job_):
Usually you will probably always want to include at least the name of the
model and method.
"""
hasher = identity_exact_hasher(job_)
return hasher.hexdigest()


def identity_exact_hasher(job_):
"""Prepare hasher object for identity_exact."""
hasher = hashlib.sha1()
hasher.update(job_.model_name.encode("utf-8"))
hasher.update(job_.method_name.encode("utf-8"))
hasher.update(str(sorted(job_.recordset.ids)).encode("utf-8"))
hasher.update(str(job_.args).encode("utf-8"))
hasher.update(str(sorted(job_.kwargs.items())).encode("utf-8"))

return hasher.hexdigest()
return hasher


@total_ordering
Expand Down
10 changes: 10 additions & 0 deletions queue_job/migrations/15.0.2.3.6/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)

from odoo.tools.sql import table_exists


def migrate(cr, version):
if table_exists(cr, "queue_job"):
# Drop index 'queue_job_identity_key_state_partial_index',
# it will be recreated during the update
cr.execute("DROP INDEX IF EXISTS queue_job_identity_key_state_partial_index;")
2 changes: 1 addition & 1 deletion queue_job/models/queue_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def init(self):
self._cr.execute(
"CREATE INDEX queue_job_identity_key_state_partial_index "
"ON queue_job (identity_key) WHERE state in ('pending', "
"'enqueued') AND identity_key IS NOT NULL;"
"'enqueued', 'wait_dependencies') AND identity_key IS NOT NULL;"
)

@api.depends("records")
Expand Down
6 changes: 6 additions & 0 deletions queue_job/readme/USAGE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,12 @@ tests), and it makes tests smaller.
The best way to run such assertions on the enqueued jobs is to use
``odoo.addons.queue_job.tests.common.trap_jobs()``.

Inside this context manager, instead of being added in the database's queue,
jobs are pushed in an in-memory list. The context manager then provides useful
helpers to verify that jobs have been enqueued with the expected arguments. It
even can run the jobs of its list synchronously! Details in
``odoo.addons.queue_job.tests.common.JobsTester``.

A very small example (more details in ``tests/common.py``):

.. code-block:: python
Expand Down
5 changes: 5 additions & 0 deletions queue_job/views/queue_job_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@
string="Failed"
domain="[('state', '=', 'failed')]"
/>
<filter
name="cancelled"
string="Cancelled"
domain="[('state', '=', 'cancelled')]"
/>
<group expand="0" string="Group By">
<filter
name="group_by_channel"
Expand Down