Skip to content
Closed
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
6 changes: 6 additions & 0 deletions queue_job/models/queue_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import logging
import random
import threading
from datetime import datetime, timedelta

from odoo import _, api, exceptions, fields, models
Expand Down Expand Up @@ -231,12 +232,17 @@ def _compute_graph_jobs_count(self):

@api.model_create_multi
def create(self, vals_list):
test_mode = getattr(threading.current_thread(), "testing", False)
if test_mode and not vals_list:
return self

if self.env.context.get("_job_edit_sentinel") is not self.EDIT_SENTINEL:
# Prevent to create a queue.job record "raw" from RPC.
# ``with_delay()`` must be used.
raise exceptions.AccessError(
_("Queue jobs must be created by calling 'with_delay()'.")
)

return super(
QueueJob,
self.with_context(mail_create_nolog=True, mail_create_nosubscribe=True),
Expand Down