Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] queue_job: prevent issues with native test TestOverrides:test_c… #727

Open
wants to merge 1 commit into
base: 18.0
Choose a base branch
from
Open
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 @@

@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

Check warning on line 237 in queue_job/models/queue_job.py

View check run for this annotation

Codecov / codecov/patch

queue_job/models/queue_job.py#L237

Added line #L237 was not covered by tests

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
Loading