diff --git a/queue_job/models/queue_job.py b/queue_job/models/queue_job.py index c4f1faaef5..b16acf60f1 100644 --- a/queue_job/models/queue_job.py +++ b/queue_job/models/queue_job.py @@ -3,6 +3,7 @@ import logging import random +import threading from datetime import datetime, timedelta from odoo import _, api, exceptions, fields, models @@ -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),