Skip to content

[FIX] ai_tool: allow tool use by users without Administration rights - #123

Closed
dreispt wants to merge 1 commit into
OCA:19.0from
dreispt:19.0-fix-ai_tool
Closed

dreispt wants to merge 1 commit into
OCA:19.0from
dreispt:19.0-fix-ai_tool

Conversation

@dreispt

@dreispt dreispt commented Oct 7, 2026

Copy link
Copy Markdown
Member

Since Odoo 19.0, ir.model is no longer readable by internal users (base.group_user gets perm_read=0).

_get_tool_definition and _execute_tool read model_id.model to dispatch the tool, so a call made under a non-admin environment — e.g. the MCP endpoint in ai_oca_mcp, which switches to the key owner's user via with_user — raised an AccessError and returned HTTP 403.

The fix reads the related model through sudo() only for the ir.model name lookup; the returned env stays bound to the calling user, so tool methods still run with the caller's permissions.

This unblocks the ai_oca_mcp 19.0 migration (non-admin key tests).

Since Odoo 19.0, ir.model is no longer readable by internal users
(base.group_user gets perm_read=0). _get_tool_definition and
_execute_tool read model_id.model to dispatch the tool, so a call made
under a non-admin environment raised an AccessError.

Read the related model through sudo() only for the ir.model lookup; the
returned env stays bound to the calling user, so tool methods still run
with the caller's permissions.

Assisted-by: Devin:SWE-2 High
@dreispt

dreispt commented Oct 7, 2026

Copy link
Copy Markdown
Member Author

Closing in favor of #119, which carries the same ir.model sudo fix plus the _ai_get_date output-schema correction.

@dreispt dreispt closed this Oct 7, 2026
@dreispt
dreispt deleted the 19.0-fix-ai_tool branch October 7, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants