Skip to content

[18.0][FIX] queue_job: Remove deprecated @api.private decorator#815

Closed
bosd wants to merge 2 commits into
OCA:18.0from
bosd:bosd-patch-1
Closed

[18.0][FIX] queue_job: Remove deprecated @api.private decorator#815
bosd wants to merge 2 commits into
OCA:18.0from
bosd:bosd-patch-1

Conversation

@bosd
Copy link
Copy Markdown
Contributor

@bosd bosd commented Aug 15, 2025

No description provided.

@OCA-git-bot
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Member

@guewen guewen left a comment

Choose a reason for hiding this comment

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

It has been added here https://github.com/OCA/queue/pull/802/files#diff-52052ee7edd7df6a68c13f1c6f9667c1556c7c08b0a8e91de76dcd7b2d604439R238 as a replacement for the sentinel protection.

Removing the decorator would be a security hole as we would be able to create jobs with a crafted payload executing any method executed by any user, using RPC.

Also, I do not see any mention of @api.private being deprecated, actually, it has been added on master and backported in Odoo 18.0 and other supported versions, so I'm curious if you have any source for that?

@bosd
Copy link
Copy Markdown
Contributor Author

bosd commented Aug 15, 2025

Before this fix, install of this module fails:
After this fix I am getting a:
AttributeError: module 'odoo.api' has no attribute 'private'

RPC_ERROR

Odoo Server Error

Occured on localhost:18069 on model ir.module.module and id 9 on 2025-08-15 13:22:59 GMT

Traceback (most recent call last):
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 1957, in _transactioning
    return service_model.retrying(func, env=self.env)
  File "/opt/odoo/custom/src/odoo/odoo/service/model.py", line 137, in retrying
    result = func()
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 1924, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 2171, in dispatch
    result = self.request.registry['ir.http']._dispatch(endpoint)
  File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_http.py", line 329, in _dispatch
    result = endpoint(**request.params)
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 727, in route_wrapper
    result = endpoint(self, *args, **params_ok)
  File "/opt/odoo/auto/addons/web/controllers/dataset.py", line 40, in call_button
    action = call_kw(request.env[model], method, args, kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/api.py", line 517, in call_kw
    result = getattr(recs, name)(*args, **kwargs)
  File "<decorator-gen-73>", line 2, in button_immediate_install
  File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_module.py", line 75, in check_and_log
    return method(self, *args, **kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_module.py", line 480, in button_immediate_install
    return self._button_immediate_function(self.env.registry[self._name].button_install)
  File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_module.py", line 604, in _button_immediate_function
    registry = modules.registry.Registry.new(self._cr.dbname, update_module=True)
  File "<decorator-gen-13>", line 2, in new
  File "/opt/odoo/custom/src/odoo/odoo/tools/func.py", line 97, in locked
    return func(inst, *args, **kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/modules/registry.py", line 127, in new
    odoo.modules.load_modules(registry, force_demo, status, update_module)
  File "/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 480, in load_modules
    processed_modules += load_marked_modules(env, graph,
  File "/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 364, in load_marked_modules
    loaded, processed = load_module_graph(
  File "/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 185, in load_module_graph
    load_openerp_module(package.name)
  File "/opt/odoo/custom/src/odoo/odoo/modules/module.py", line 384, in load_openerp_module
    __import__(qualname)
  File "/opt/odoo/auto/addons/queue_job/__init__.py", line 3, in <module>
    from . import models
  File "/opt/odoo/auto/addons/queue_job/models/__init__.py", line 3, in <module>
    from . import queue_job
  File "/opt/odoo/auto/addons/queue_job/models/queue_job.py", line 31, in <module>
    class QueueJob(models.Model):
  File "/opt/odoo/auto/addons/queue_job/models/queue_job.py", line 238, in QueueJob
    @api.private
AttributeError: module 'odoo.api' has no attribute 'private'

The above server error caused the following client error:
RPC_ERROR: Odoo Server Error
    RPCError@http://localhost:18069/web/assets/0c704c8/web.assets_web.min.js:3121:338
    makeErrorFromResponse@http://localhost:18069/web/assets/0c704c8/web.assets_web.min.js:3124:163
    rpc._rpc/promise</<@http://localhost:18069/web/assets/0c704c8/web.assets_web.min.js:3129:34
    

@amh-mw
Copy link
Copy Markdown
Member

amh-mw commented Aug 15, 2025

Per #806

api.private decorator was introduced by odoo/odoo@c7efed2 on 2025/02/28, so a newer version of 18.0 should set things right.

@guewen
Copy link
Copy Markdown
Member

guewen commented Aug 15, 2025

Is your odoo core code up-to-date?

@bosd
Copy link
Copy Markdown
Contributor Author

bosd commented Aug 15, 2025

I am on 18.0+E
Gonna do a new pull to check this

Is your odoo core code up-to-date?

I am on 18.0+E
Gonna do a new pull to check this.

@bosd
Copy link
Copy Markdown
Contributor Author

bosd commented Aug 15, 2025

It ok now! Thanks.
Somehow I did'nt get the latest code. (Even after multiple attempts, but got it now.)

Sorry for opening this. Didn't find the old issues b/c they where already closed .

@bosd bosd closed this Aug 15, 2025
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.

4 participants