AI Tool: Get Models
code
get_models
Looking up available models
List every database model the current user is allowed to read. Call this first when you do not know the technical name of a model.
{
"type": "object",
"properties": {},
"required": []
}
ai["result"] = record._ai_tool_get_models()
AI Tool: Get Fields
code
get_fields
Inspecting the fields of the model
Return the technical fields of a model: name, type, label, relations, selection values. Always call this before searching, grouping or writing on a model you have not inspected yet.
{
"type": "object",
"properties": {
"model_name": {"type": "string", "description": "Technical model name, e.g. res.partner"},
"include_description": {"type": "boolean", "description": "Include the help text of each field"}
},
"required": ["model_name"]
}
ai["result"] = record._ai_tool_get_fields(model_name, include_description)
AI Tool: Search
code
search
Searching records
Search and read records of a model. Provide an Odoo domain as JSON (e.g. [["name","ilike","Acme"]]) and the exact field names to read.
{
"type": "object",
"properties": {
"model_name": {"type": "string"},
"domain": {"type": "string", "description": "Odoo domain as a JSON string. Use [] for all records."},
"fields": {"type": "array", "items": {"type": "string"}, "description": "Field names to read"},
"offset": {"type": "integer"},
"limit": {"type": "integer", "description": "Max 200, default 40"},
"order": {"type": "string", "description": "e.g. create_date desc"}
},
"required": ["model_name", "fields"]
}
ai["result"] = record._ai_tool_search(model_name, domain, fields, offset, limit, order)
AI Tool: Read Group
code
read_group
Aggregating records
Group records and compute aggregates. Use it for counts, sums and averages instead of reading every record.
{
"type": "object",
"properties": {
"model_name": {"type": "string"},
"domain": {"type": "string", "description": "Odoo domain as JSON"},
"groupby": {"type": "array", "items": {"type": "string"}, "description": "e.g. [\"partner_id\", \"create_date:month\"]"},
"aggregates": {"type": "array", "items": {"type": "string"}, "description": "e.g. [\"__count\", \"amount_total:sum\"]"}
},
"required": ["model_name", "domain", "groupby"]
}
ai["result"] = record._ai_tool_read_group(model_name, domain, groupby, aggregates)
AI Tool: Compute Date
code
compute_date
Computing the date
Turn a relative expression ("next Monday", "start of last quarter") into an absolute date or datetime in the user's timezone. Use it whenever a domain filters on a date, because "today" on the server is UTC.
{
"type": "object",
"properties": {
"model_name": {"type": "string", "description": "Model owning the date field"},
"field_name": {"type": "string", "description": "Date or datetime field name"},
"operations": {
"type": "array",
"description": "Ordered operations. navigate moves by a period, find_next/find_previous jump to a weekday (0=Monday).",
"items": {
"type": "object",
"properties": {
"type": {"type": "string", "enum": ["navigate", "find_next", "find_previous"]},
"period": {"type": "string", "enum": ["minute", "hour", "day", "week", "month", "quarter", "year"]},
"offset": {"type": "integer", "description": "-100 to 100"},
"boundary": {"type": "string", "enum": ["start", "end"]},
"weekday": {"type": "integer", "description": "0=Monday … 6=Sunday"}
}
}
},
"pin": {
"type": "object",
"description": "Final anchoring: day (1-31 or {weekday, occurrence}) and time (HH:MM)",
"properties": {
"day": {},
"time": {"type": "string"}
}
}
},
"required": ["model_name", "field_name"]
}
ai["result"] = record._ai_tool_compute_date(model_name, field_name, operations, pin)
AI Tool: Adjust Search
code
adjust_search
Refining the current view
Modify the view the user is currently looking at: add or remove filters, change group by, switch view type.
{
"type": "object",
"properties": {
"model_name": {"type": "string"},
"remove_facets": {"type": "array", "items": {"type": "integer"}, "description": "Search item group ids to deactivate"},
"toggle_filters": {"type": "array", "items": {"type": "string"}, "description": "Filter names or xml ids to toggle"},
"toggle_groupbys": {"type": "array", "items": {"type": "string"}, "description": "Group by field names to toggle"},
"apply_searches": {
"type": "array",
"description": "Simulates typing into the search bar, e.g. [{\"search_field\": \"name\", \"value\": \"SO001\"}]",
"items": {
"type": "object",
"properties": {
"search_field": {"type": "string"},
"value": {"type": "string"}
},
"required": ["search_field", "value"]
}
},
"measures": {"type": "array", "items": {"type": "string"}},
"mode": {"type": "string", "enum": ["reset", "add", "remove"], "description": "Pivot/graph display mode"},
"order": {"type": "string", "enum": ["ASC", "DESC"]},
"stacked": {"type": "boolean", "description": "Graph only: stack the bars"},
"cumulated": {"type": "boolean", "description": "Graph only, line mode: cumulative values"},
"custom_domain": {"type": "string", "description": "Extra domain as JSON"},
"switch_view_type": {"type": "string", "enum": ["list", "kanban", "pivot", "graph"]}
},
"required": ["model_name"]
}
ai["result"] = record._ai_tool_adjust_search(model_name, remove_facets, toggle_filters, toggle_groupbys, apply_searches, measures, mode, order, stacked, cumulated, custom_domain, switch_view_type)
AI Tool: Compute Report Measures
code
compute_report_measures
Listing the available measures
List the numeric fields that can be used as measures in a pivot or graph view.
{
"type": "object",
"properties": {
"action_id": {"type": "integer"},
"model": {"type": "string"}
},
"required": ["model"]
}
ai["result"] = record._ai_tool_compute_report_measures(action_id, model)
AI Tool: Run View Action
code
run_view_action
Opening the view
Open a menu using its default action and view type.
{
"type": "object",
"properties": {
"menu_id": {"type": "integer"},
"action_type": {"type": "string", "enum": ["list", "kanban", "form", "pivot", "graph"]}
},
"required": ["menu_id", "action_type"]
}
ai["result"] = record._ai_tool_run_view_action(menu_id, action_type)
AI Tool: Prepare Record Previews
code
prepare_record_previews
Preparing the preview
Prepare clickable previews of records so the user can open them from the chat.
{
"type": "object",
"properties": {
"model_name": {"type": "string"},
"record_ids": {"type": "array", "items": {"type": "integer"}},
"preview_label": {"type": "string"}
},
"required": ["model_name", "record_ids"]
}
ai["result"] = record._ai_tool_prepare_record_previews(model_name, record_ids, preview_label)
AI Tool: Read Binary Content
code
read_binary_content
Reading the attached file
Read the text content of a binary field (PDF, image, attachment) linked to a record.
{
"type": "object",
"properties": {
"model_name": {"type": "string"},
"record_ids": {"type": "array", "items": {"type": "integer"}},
"field_name": {"type": "string"}
},
"required": ["model_name", "record_ids"]
}
ai["result"] = record._ai_tool_read_binary_content(model_name, record_ids, field_name)
AI Tool: Create Records
code
create_records
Creating the record
Create one or more records. The user is asked to confirm before anything is written.
{
"type": "object",
"properties": {
"explanation": {"type": "string", "description": "One sentence shown to the user explaining what will be created"},
"preview_menu_id": {"type": "integer"},
"model_name": {"type": "string"},
"values": {"type": "object", "description": "Field values, using exact technical field names"}
},
"required": ["explanation", "model_name", "values"]
}
ai["result"] = record._ai_tool_create_records(ai, explanation, preview_menu_id, model_name, values)
AI Tool: Update Records
code
update_records
Updating the records
Update fields on existing records. Always pass a precise domain; updating every record is refused. The user confirms first.
{
"type": "object",
"properties": {
"explanation": {"type": "string"},
"preview_menus": {"type": "array", "items": {"type": "integer"}},
"updates": {
"type": "array",
"items": {
"type": "object",
"properties": {
"model_name": {"type": "string"},
"domain": {"type": "string"},
"changes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"field": {"type": "string"},
"value": {}
},
"required": ["field", "value"]
}
}
},
"required": ["model_name", "domain", "changes"]
}
}
},
"required": ["explanation", "updates"]
}
ai["result"] = record._ai_tool_update_records(ai, explanation, preview_menus, updates)
AI Tool: Ask User Question
code
ask_user_question
Asking you a question
Ask the user a question and wait. Use it only when the answer cannot be resolved by searching the database.
{
"type": "object",
"properties": {
"question": {"type": "string"},
"choices": {"type": "array", "items": {"type": "string"}},
"multi_select": {"type": "boolean"},
"allow_free_text": {"type": "boolean"}
},
"required": ["question"]
}
ai["result"] = record._ai_tool_ask_user_question(ai, question, choices, multi_select, allow_free_text)
AI Tool: Load Skills
code
load_skills
Loading the relevant skill
Load one or more skills by id. Their instructions are returned and their tools become available. Call it at most once per request.
{
"type": "object",
"properties": {
"skill_ids": {"type": "array", "items": {"type": "integer"}}
},
"required": ["skill_ids"]
}
ai["result"] = record._ai_tool_load_skills(ai, skill_ids)