Skip to content
Closed
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
13 changes: 10 additions & 3 deletions queue_job/models/queue_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ def _compute_graph_jobs_count(self):
record.graph_jobs_count = count_per_graph_uuid.get(record.graph_uuid) or 0

@api.model_create_multi
@api.private
def create(self, vals_list):
return super(
QueueJob,
Expand Down Expand Up @@ -433,7 +432,11 @@ def _get_stuck_jobs_domain(self, queue_dl, started_dl):
domain.append(
[
"&",
("date_enqueued", "<=", fields.Datetime.to_string(queue_dl)),
(
"date_enqueued",
"<=",
fields.Datetime.to_string(queue_dl),
),
("state", "=", "enqueued"),
]
)
Expand All @@ -442,7 +445,11 @@ def _get_stuck_jobs_domain(self, queue_dl, started_dl):
domain.append(
[
"&",
("date_started", "<=", fields.Datetime.to_string(started_dl)),
(
"date_started",
"<=",
fields.Datetime.to_string(started_dl),
),
("state", "=", "started"),
]
)
Expand Down
22 changes: 14 additions & 8 deletions queue_job/tests/test_queue_job_protected_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,25 @@

class TestJobCreatePrivate(common.HttpCase):
def test_create_error(self):
self.authenticate("admin", "admin")
with self.assertRaises(common.JsonRpcException) as cm, mute_logger("odoo.http"):
self.authenticate("demo", "demo")
with (
self.assertRaises(common.JsonRpcException) as cm,
mute_logger("odoo.http"),
):
self.make_jsonrpc_request(
"/web/dataset/call_kw",
params={
"model": "queue.job",
"method": "create",
"args": [],
"kwargs": {
"method_name": "write",
"model_name": "res.partner",
"uuid": "test",
},
"args": [
{
"method_name": "write",
"model_name": "res.partner",
"uuid": "test",
"state": "pending",
},
],
"kwargs": {},
},
headers={
"Cookie": f"session_id={self.session.sid};",
Expand Down