Uh oh!
There was an error while loading. Please reload this page.
[FIX] queue_job: prevent conflict w/ TestOverrides:test_creates - #802
Conversation
This prevents TestOverrides.test_creates from failing in the Odoo `base` module due to sentinel protections taking effect even for local create invocations.
OCA-git-bot
commented
Jul 7, 2025
Hi @guewen, |
amh-mw
commented
Jul 7, 2025
@simahawk I liked your idea and went ahead and implemented it. Tests are green and I will start running this change in my local development environment this week. |
amh-mw
commented
Jul 7, 2025
@Kimkhoi3010 Would you be willing to review this pull request, since it mirrors your own? |
guewen
commented
Jul 10, 2025
/ocabot merge patch |
OCA-git-bot
commented
Jul 10, 2025
On my way to merge this fine PR! |
Uh oh!
There was an error while loading. Please reload this page.
OCA-git-bot
commented
Jul 10, 2025
Congratulations, your PR was merged at 5b7cedd. Thanks a lot for contributing to OCA. ❤️ |
simahawk
commented
Jul 11, 2025
That's cool! Question: what about the |
amh-mw
commented
Jul 11, 2025
I did consider it during implementation, but |
simahawk
commented
Jul 14, 2025
🤣 that makes sense 😄 My understanding is that writes always happen by calling @guewen any opinion? |
guewen
commented
Jul 14, 2025
I wondered about that too when reviewing but then realized some fields can be modified through the API (from the UI), some mustn't, so I don't think we can do that without the sentinel? |
bosd
commented
Aug 15, 2025
After this fix I am getting a: |
guewen
commented
Apr 24, 2026
Hi @amh-mw, I just looked at |
That seems unfortunately right. My knee jerk reaction is to override |
guewen
commented
Apr 24, 2026
I had the exact same reasoning |
amh-mw
commented
Apr 24, 2026
After digging a bit more, it looks like the Per https://github.com/odoo/odoo/blob/18.0/addons/web/controllers/dataset.py#L32-L36 @http.route(['/web/dataset/call_kw', '/web/dataset/call_kw/<path:path>'], type='json', auth="user", readonly=_call_kw_readonly)defcall_kw(self, model, method, args, kwargs, path=None):
Model=request.env[model]
get_public_method(Model, method)
returncall_kw(request.env[model], method, args, kwargs)Per https://github.com/odoo/odoo/blob/18.0/odoo/service/model.py#L29-L46 defget_public_method(model, name):
""" Get the public unbound method from a model. When the method does not exist or is inaccessible, raise appropriate errors. Accessible methods are public (in sense that python defined it: not prefixed with "_") and are not decorated with `@api.private`. """assertisinstance(model, BaseModel), f"{model!r} is not a BaseModel for {name}"cls=type(model)
method=getattr(cls, name, None)
ifnotcallable(method):
raiseAttributeError(f"The method '{model._name}.{name}' does not exist") # noqa: TRY004formro_clsincls.mro():
cla_method=getattr(mro_cls, name, None)
ifnotcla_method:
continueifname.startswith('_') orgetattr(cla_method, '_api_private', False) ornamein_UNSAFE_ATTRIBUTES:
raiseAccessError(f"Private methods (such as '{model._name}.{name}') cannot be called remotely.")
returnmethod |
Argh, no -- I'm reading it wrong, because |
Uh oh!
There was an error while loading. Please reload this page.
guewen
commented
Apr 29, 2026
@amh-mw wait, actually no user should have permissions to create jobs. Queue job managers have permissions to create and delete that should be removed IMO. In older versions, the admin user could bypass the permissions so the sentinel was needed, but now that access rights are enforced even for the admin user, it seems the cleanest and simplest solution (and they should never have had these permissions anyway). Does it sound right to you? If yes, I can open a PR for this. |
amh-mw
commented
Apr 29, 2026
Confirmed, as admin and superuser, Job Queue list view has no create button. Let's lock it down! |
Jobs are always created through sudo() in the Job class, and always deleted by the cron, never by users. See discussion on OCA#802 (comment)
Jobs are always created through sudo() in the Job class, and always deleted by the cron, never by users. See discussion on OCA#802 (comment)
Jobs are always created through sudo() in the Job class, and always deleted by the cron, never by users. See discussion on OCA#802 (comment)
Jobs are always created through sudo() in the Job class, and always deleted by the cron, never by users. See discussion on OCA#802 (comment)
This prevents TestOverrides.test_creates from failing in the Odoo
basemodule due to the sentinel protections taking effect even for local create invocations.Fixes#727