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

[18.0][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

Conversation

Kimkhoi3010
Copy link

Issue:

The native test TestOverrides:test_creates() fails when queue_job is installed due to a security check that prevents the creation of queue.job records via RPC (see queue_job.py#L234). This results in an exception:

ERROR: TestOverrides.test_creates
Traceback (most recent call last):
  File "/home/odoo/src/odoo/odoo/addons/base/tests/test_overrides.py", line 19, in test_creates
    model_env.create([]), model_env.browse(),
    ^^^^^^^^^^^^^^^^^^^^
  File "<decorator-gen-160>", line 2, in create
  File "/home/odoo/src/odoo/odoo/api.py", line 480, in _model_create_multi
    return create(self, arg)
           ^^^^^^^^^^^^^^^^^
  File "/home/odoo/src/user/queue_job_cron_jobrunner/models/queue_job.py", line 147, in create
    records = super().create(vals_list)
              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<decorator-gen-155>", line 2, in create
  File "/home/odoo/src/odoo/odoo/api.py", line 480, in _model_create_multi
    return create(self, arg)
           ^^^^^^^^^^^^^^^^^
  File "/home/odoo/src/user/queue_job/models/queue_job.py", line 237, in create
    raise exceptions.AccessError(
odoo.exceptions.AccessError: Queue jobs must be created by calling 'with_delay()'.

Solution:

  • This PR modifies the create method in the queue_job model for that specific case, and only that one (test mode + empty vals_list).

@OCA-git-bot
Copy link
Contributor

Hi @guewen,
some modules you are maintaining are being modified, check this out!

@StefanRijnhart StefanRijnhart changed the title [FIX] queue_job: prevent issues with native test TestOverrides:test_c… [18.0][FIX] queue_job: prevent issues with native test TestOverrides:test_c… Feb 28, 2025
Copy link
Member

@StefanRijnhart StefanRijnhart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's inevitable that not all post-install tests from core Odoo run successfully on a database with additional modules involved. If this causes issues in your setup, I would recommend to only run the tests of your custom modules (or, custom + OCA modules).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants