AI Tool - Read
ai_tool_read · OCA/ai
-
Security25/25No findings
-
Activity25/25Human commit this month
-
Required by5/250 modules depend on it
-
Maturity5/25In 1 Odoo series since 16.0
Heuristic over the facts below, not an audit · How it's computed
Migration considerations
- Migrating to 18.0: `user_has_groups()` was removed: use `self.env.user.has_group()`. migration-user-has-groups · source
Migration review checklist, not a compatibility verdict. "Migrating to X.0" applies once you upgrade to that version; "Since X.0" means this version already ignores or rejects that code. Methodology
Description
Adds ai_tool tools to let an AI agent read any model and field it
is allowed to access, while keeping personal or otherwise sensitive fields out
of the results.
A flag AI Read Forbidden (ai_no_read) is added to fields. The tools never
return nor describe a forbidden field, nor any field exposing its value:
related fields, including those delegated through _inherits, and computed
fields depending on it. Flagging res.partner.email thus also hides
email_formatted, email_normalized and res.users.email.
Three tools are provided:
- list_models: lists the models the current user is allowed to read.
- get_fields: describes a model's readable fields (label, type, help,
selection options and relation target), and lists the forbidden ones under
hidden. - search_read: searches and reads records of a model. It returns the
stored fields unless a field list is given, relational fields as record
IDs, and dates in UTC. Results are paged with
limitandoffset, andhas_moretells whether more records match. A field whose computation is refused for the user is left out and listed ininaccessible_fields, and a record the search finds but the user cannot read (asir.attachmentallows) is left out without notice, as record rules would.
The tools run with the calling user's own access rights (no sudo), so Odoo
ACLs, record rules and field groups still apply. Connect the agent as a user
with no more rights than it needs: an administrator sees every field restricted
by groups.
Besides forbidden fields, the results leave out binary fields, fields pointing to a model the user cannot read (reading them would fail), and display names computed on the fly, including the one Odoo adds to many2one values: they are built from other records' fields, which may be forbidden there.
The flag keeps values out of the results, not out of searches: see Known issues.
Dependencies
Code analysis
Extracted from the source by best-effort static analysis (no code is executed); details may be incomplete.
Views touched 4
| XML ID | Name | Model | Type | Status |
|---|---|---|---|---|
ir_model_fields_view_form |
ir.model.fields | form | Inherits base.view_model_fields_form | |
ir_model_fields_view_search |
ir.model.fields | search | Inherits base.view_model_fields_search | |
ir_model_fields_view_tree |
ir.model.fields | tree | Inherits base.view_model_fields_tree | |
ir_model_view_form |
ir.model | form | Inherits base.view_model_form |
HTTP endpoints 0
No HTTP endpoints found for this module.
Models touched 2
No new fields.
Public methods (0)No public methods.
-
ai_no_readBooleandefault=Falsehelp="If enabled, the generic AI read tools leave this field out of the records they return and of the fields described by get_fields. It does not stop an agent from filtering or sorting on the field (see the module's Known issues). Use it to keep personal or otherwise sensitive values out of the results given to AI agents."index=Truestring='AI Read Forbidden'
-
write(self, vals)
Loading…