Skip to content

[18.0][FIX] queue_job: prevent conflict w/ TestOverrides:test_creates#727

Closed
Kimkhoi3010 wants to merge 1 commit intoOCA:18.0from
Kimkhoi3010:18.0_pr709
Closed

[18.0][FIX] queue_job: prevent conflict w/ TestOverrides:test_creates#727
Kimkhoi3010 wants to merge 1 commit intoOCA:18.0from
Kimkhoi3010:18.0_pr709

Conversation

@Kimkhoi3010
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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).

@simahawk
Copy link
Copy Markdown
Contributor

simahawk commented Mar 4, 2025

Proposal: use https://github.com/odoo/odoo/blob/18.0/odoo/api.py#L446 and get rid of the sentinel.
As an alternative we could use rpc_helper but that would add another dependency.

@simahawk simahawk changed the title [18.0][FIX] queue_job: prevent issues with native test TestOverrides:test_c… [18.0][FIX] queue_job: prevent conflict w/ TestOverrides:test_creates Mar 4, 2025
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jul 6, 2025

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Jul 6, 2025
@amh-mw
Copy link
Copy Markdown
Member

amh-mw commented Jul 7, 2025

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).

@StefanRijnhart As another fool that has been tilting at the core Odoo test windmill for several years now, I agree that some failures are inevitable, but still find a lot of value in running the majority of the tests and only excluding (i.e. --test-tags=-/base.test_creates) or patching out the absolutely irreconcilable ones. Especially when migrating Odoo versions, I have found tests invaluable for detecting drift between the core Odoo implementation and custom modules built on top of that implementation.

@Kimkhoi3010
Copy link
Copy Markdown
Author

Kimkhoi3010 commented Jul 8, 2025

This PR is closed in favor of #802, which supersedes and includes the necessary fixes and improvements.
Thanks to @amh-mw for taking it over and refining the solution.

@Kimkhoi3010 Kimkhoi3010 closed this Jul 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale PR/Issue without recent activity, it'll be soon closed automatically.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants