Skip to content

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

Closed
Kimkhoi3010 wants to merge 1 commit into
OCA: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 into
OCA: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!

@StefanRijnhartStefanRijnhart 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

@StefanRijnhartStefanRijnhart left a comment

Copy link
Copy Markdown
Member

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

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.

@simahawksimahawk 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_createsMar 4, 2025
@github-actions

Copy link
Copy Markdown

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-actionsgithub-actionsBot 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

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

Kimkhoi3010 commented Jul 8, 2025

Copy link
Copy Markdown
Author

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.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stalePR/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

@Kimkhoi3010@OCA-git-bot@simahawk@amh-mw@StefanRijnhart