This commit is contained in:
2026-11-25 11:58:57 +08:00
parent 5fc4382687
commit 88b4fe3d59
3210 changed files with 11146 additions and 601197 deletions

View File

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="ai_default_agent" model="ai.agent">
<field name="name">Odoo AI</field>
<field name="subtitle">I'm your Odoo sidekick for most day-to-day tasks.</field>
<field name="sequence">1</field>
<field name="is_system_agent" eval="True"/>
<field name="skill_ids" eval="[(6, 0, [
ref('ai_skill_information_retrieval_query'),
ref('ai_skill_natural_language_query'),
ref('ai_skill_update_records'),
ref('ai_skill_create_records'),
])]"/>
<field name="system_prompt">You are the main Odoo AI Assistant. Help users complete business work inside Odoo accurately, efficiently, and with good judgment.
## Working Style
- Be practical, concise, and action-oriented. Prefer making progress when the user's intent is clear.
- Ask a short clarifying question only when missing information would materially change the result, block the action, or create business risk.
- Use a professional, supportive tone. Put the useful answer or outcome first, followed by important caveats or next steps.
## Collaboration
- Adapt to the user's intent.
- For information requests, answer from the available evidence.
- For action requests, proceed through the available tools or loaded workflows once the target, intended action, and required values are clear.
- For drafting, rewriting, summarizing, or data-quality improvement, preserve the user's intent and factual basis while improving clarity, tone, structure, and usefulness.
- If you cannot complete the request with the currently available tools or context, explain the limitation briefly and offer the closest useful next step.</field>
</record>
<record id="ai_composer_chatter" model="ai.composer">
<field name="name">Chatter AI button</field>
<field name="interface_key">chatter_ai_button</field>
<field name="ai_agent_id" ref="ai_default_agent"/>
<field name="is_system_default" eval="True"/>
<field name="default_prompt">The user opened the AI assistant from the chatter of the current record.</field>
</record>
<record id="ai_composer_systray" model="ai.composer">
<field name="name">Systray AI button</field>
<field name="interface_key">systray_ai_button</field>
<field name="ai_agent_id" ref="ai_default_agent"/>
<field name="is_system_default" eval="True"/>
<field name="default_prompt">The user opened the AI assistant from the top bar, without focusing any record.</field>
</record>
</odoo>

View File

@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- ============ Search Database ============ -->
<record id="ai_skill_information_retrieval_query" model="ai.skill">
<field name="name">Search Database</field>
<field name="sequence">10</field>
<field name="is_native_skill" eval="True"/>
<field name="description">Read data from any Odoo record: search, filter, aggregate and read field values.</field>
<field name="instructions">## Search Database
You can retrieve information from any Odoo record.
### Workflow
1. If you do not know the technical model name, call `get_models`.
2. Always call `get_fields` on a model before querying it: field names are technical identifiers, not labels.
3. Use `search` to read records, and `read_group` whenever the question is about totals, counts or averages — never read hundreds of records to compute a sum yourself.
4. When filtering on a date, compute the boundary with `compute_date`. The server runs in UTC while the user thinks in their own timezone; "today" means the user's today.
### Rules
- Never invent records, ids or field values. If a search returns nothing, say so and propose a broader search.
- Never guess a field name. If `get_fields` does not list it, it does not exist.
- Prefer a narrow domain over a broad one, and cap the number of fields you read to what the answer needs.
- When the question mentions a person, a company or a document by name, resolve it with a search first instead of asking the user for an id.
- Summarise the result in business terms. Do not paste raw ORM output.</field>
<field name="tool_ids" eval="[(6, 0, [
ref('ir_actions_server_get_models'),
ref('ir_actions_server_get_fields'),
ref('ir_actions_server_search'),
ref('ir_actions_server_read_group'),
ref('ir_actions_server_compute_date'),
ref('ir_actions_server_preview_records'),
])]"/>
</record>
<!-- ============ Shape View ============ -->
<record id="ai_skill_natural_language_query" model="ai.skill">
<field name="name">Shape View</field>
<field name="sequence">20</field>
<field name="is_native_skill" eval="True"/>
<field name="description">Navigate the user in the UI and shape the view: open a menu, filter, group, chart, pivot.</field>
<field name="instructions">## Shape View
You can navigate the user in the interface and interact with the current view.
Use it whenever the user asks to "see", "view", "show", "open", "filter", "group by", "chart", "compare" — even when no view type is mentioned.
### Workflow
1. Call `get_menus` to find the menu the user means. Pick the most specific match, not the first one.
2. If you are unsure which fields to group by, call `get_menu_details` (it lists the fields) or `compute_report_measures` for numeric measures.
3. Open the view with `open_menu_list`, `open_menu_kanban`, `open_menu_pivot` or `open_menu_graph`. Pass a domain when the user asked for a subset.
4. If the user is already looking at a screen and asks for a tweak, use `adjust_search` instead of opening a new view.
### Rules
- Always pass a real `menu_id` obtained from `get_menus`; never invent one.
- Group-bys must be plain field names, or `field:interval` for dates (day, week, month, quarter, year).
- Do not open a view and also describe the data at length: open the view, then add one short sentence about what it shows.
- If no menu matches, say which menus you found instead and ask which one the user meant.</field>
<field name="tool_ids" eval="[(6, 0, [
ref('ir_actions_server_get_models'),
ref('ir_actions_server_get_menus'),
ref('ir_actions_server_get_menu_details'),
ref('ir_actions_server_get_fields'),
ref('ir_actions_server_compute_date'),
ref('ir_actions_server_adjust_search'),
ref('ir_actions_server_open_menu_list'),
ref('ir_actions_server_open_menu_kanban'),
ref('ir_actions_server_open_menu_pivot'),
ref('ir_actions_server_open_menu_graph'),
ref('ir_actions_server_compute_report_measures'),
ref('ir_actions_server_run_view_action'),
])]"/>
</record>
<!-- ============ Update Records ============ -->
<record id="ai_skill_update_records" model="ai.skill">
<field name="name">Update Records</field>
<field name="sequence">30</field>
<field name="is_native_skill" eval="True"/>
<field name="description">Modify field values on existing records.</field>
<field name="instructions">## Update Records
You can update existing records.
### Rules
- Before updating, call `get_fields` on the model to confirm the exact technical field names and which ones are readonly.
- Build a precise domain that targets exactly the records the user meant. Updating "all records" is refused unless the user explicitly asked for it and the domain reflects it.
- Read the records first and show the user what will change when the request is ambiguous.
- Never write to computed or readonly fields, and never set a relational field with a raw id without checking the relation.
- The runtime shows a confirmation card before executing. Do not ask for confirmation in chat.
- After the update, state what changed in business terms, with the number of records touched.</field>
<field name="tool_ids" eval="[(6, 0, [
ref('ir_actions_server_get_models'),
ref('ir_actions_server_get_fields'),
ref('ir_actions_server_search'),
ref('ir_actions_server_compute_date'),
ref('ir_actions_server_update_records'),
])]"/>
</record>
<!-- ============ Create Records ============ -->
<record id="ai_skill_create_records" model="ai.skill">
<field name="name">Create Records</field>
<field name="sequence">40</field>
<field name="is_native_skill" eval="True"/>
<field name="description">Create new records from the conversation.</field>
<field name="instructions">## Create Records
You can create records.
### Rules
- Use `get_fields` to get the technical model name and the technical field names. Required fields must always be provided.
- Gather every mandatory value before creating. If a required value is missing and cannot be inferred from the conversation or a search, ask the user — do not invent a placeholder.
- Many2one values must be existing record ids. Resolve a name with `search` first.
- Provide a short `explanation` describing what will be created; it is shown on the confirmation card.
- Never create duplicates: search for an existing record matching the intent before creating a new one.
- After creation, tell the user what was created using display names, not ids.</field>
<field name="tool_ids" eval="[(6, 0, [
ref('ir_actions_server_get_models'),
ref('ir_actions_server_get_fields'),
ref('ir_actions_server_search'),
ref('ir_actions_server_compute_date'),
ref('ir_actions_server_create_records'),
])]"/>
</record>
</odoo>

View File

@@ -0,0 +1,487 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!--
Every tool is a `code` server action exposing an ai.tool method.
The JSON schema drives argument validation and is what the model sees.
-->
<!-- ================= read: models & schema ================= -->
<record id="ir_actions_server_get_models" model="ir.actions.server">
<field name="name">AI Tool: Get Models</field>
<field name="model_id" ref="model_ai_tool"/>
<field name="state">code</field>
<field name="use_in_ai" eval="True"/>
<field name="ai_tool_name">get_models</field>
<field name="ai_tool_thinking_text">Looking up available models</field>
<field name="ai_tool_description">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.</field>
<field name="ai_tool_schema">{
"type": "object",
"properties": {},
"required": []
}</field>
<field name="code">ai["result"] = record._ai_tool_get_models()</field>
</record>
<record id="ir_actions_server_get_fields" model="ir.actions.server">
<field name="name">AI Tool: Get Fields</field>
<field name="model_id" ref="model_ai_tool"/>
<field name="state">code</field>
<field name="use_in_ai" eval="True"/>
<field name="ai_tool_name">get_fields</field>
<field name="ai_tool_thinking_text">Inspecting the fields of the model</field>
<field name="ai_tool_description">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.</field>
<field name="ai_tool_schema">{
"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"]
}</field>
<field name="code">ai["result"] = record._ai_tool_get_fields(model_name, include_description)</field>
</record>
<!-- ================= menus ================= -->
<record id="ir_actions_server_get_menus" model="ir.actions.server">
<field name="name">AI Tool: Get Menus</field>
<field name="model_id" ref="model_ai_tool"/>
<field name="state">code</field>
<field name="use_in_ai" eval="True"/>
<field name="ai_tool_name">get_menus</field>
<field name="ai_tool_thinking_text">Reading the menu tree</field>
<field name="ai_tool_description">List the menus the current user can open, with their action, model and available view types. Use it to navigate the user to the right screen.</field>
<field name="ai_tool_schema">{
"type": "object",
"properties": {},
"required": []
}</field>
<field name="code">ai["result"] = record._ai_tool_get_menus()</field>
</record>
<record id="ir_actions_server_get_menu_details" model="ir.actions.server">
<field name="name">AI Tool: Get Menu Details</field>
<field name="model_id" ref="model_ai_tool"/>
<field name="state">code</field>
<field name="use_in_ai" eval="True"/>
<field name="ai_tool_name">get_menu_details</field>
<field name="ai_tool_thinking_text">Inspecting the selected menus</field>
<field name="ai_tool_description">Return the action, model and fields behind one or more menus.</field>
<field name="ai_tool_schema">{
"type": "object",
"properties": {
"menu_ids": {"type": "array", "items": {"type": "integer"}, "description": "Menu ids returned by get_menus"},
"include_model_fields": {"type": "boolean", "description": "Also list the fields of the target model"}
},
"required": ["menu_ids"]
}</field>
<field name="code">ai["result"] = record._ai_tool_get_menu_details(menu_ids, include_model_fields)</field>
</record>
<!-- ================= data ================= -->
<record id="ir_actions_server_search" model="ir.actions.server">
<field name="name">AI Tool: Search</field>
<field name="model_id" ref="model_ai_tool"/>
<field name="state">code</field>
<field name="use_in_ai" eval="True"/>
<field name="ai_tool_name">search</field>
<field name="ai_tool_thinking_text">Searching records</field>
<field name="ai_tool_description">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.</field>
<field name="ai_tool_schema">{
"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"]
}</field>
<field name="code">ai["result"] = record._ai_tool_search(model_name, domain, fields, offset, limit, order)</field>
</record>
<record id="ir_actions_server_read_group" model="ir.actions.server">
<field name="name">AI Tool: Read Group</field>
<field name="model_id" ref="model_ai_tool"/>
<field name="state">code</field>
<field name="use_in_ai" eval="True"/>
<field name="ai_tool_name">read_group</field>
<field name="ai_tool_thinking_text">Aggregating records</field>
<field name="ai_tool_description">Group records and compute aggregates. Use it for counts, sums and averages instead of reading every record.</field>
<field name="ai_tool_schema">{
"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"]
}</field>
<field name="code">ai["result"] = record._ai_tool_read_group(model_name, domain, groupby, aggregates)</field>
</record>
<record id="ir_actions_server_compute_date" model="ir.actions.server">
<field name="name">AI Tool: Compute Date</field>
<field name="model_id" ref="model_ai_tool"/>
<field name="state">code</field>
<field name="use_in_ai" eval="True"/>
<field name="ai_tool_name">compute_date</field>
<field name="ai_tool_thinking_text">Computing the date</field>
<field name="ai_tool_description">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.</field>
<field name="ai_tool_schema">{
"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"]
}</field>
<field name="code">ai["result"] = record._ai_tool_compute_date(model_name, field_name, operations, pin)</field>
</record>
<!-- ================= navigation ================= -->
<record id="ir_actions_server_open_menu_list" model="ir.actions.server">
<field name="name">AI Tool: Open Menu List</field>
<field name="model_id" ref="model_ai_tool"/>
<field name="state">code</field>
<field name="use_in_ai" eval="True"/>
<field name="ai_tool_name">open_menu_list</field>
<field name="ai_tool_thinking_text">Opening the list view</field>
<field name="ai_tool_description">Open the list view of a menu in the user's browser, optionally filtered by a domain.</field>
<field name="ai_tool_schema">{
"type": "object",
"properties": {
"menu_id": {"type": "integer"},
"model_name": {"type": "string"},
"custom_domain": {"type": "string", "description": "Extra domain as JSON"},
"selected_filters": {"type": "array", "items": {"type": "string"}, "description": "Search filter xml ids to activate"},
"selected_groupbys": {"type": "array", "items": {"type": "string"}, "description": "Group by fields"},
"search": {"type": "string", "description": "Free text search term"}
},
"required": ["menu_id", "model_name"]
}</field>
<field name="code">ai["result"] = record._ai_tool_open_menu_list(menu_id, model_name, selected_filters, selected_groupbys, search, custom_domain)</field>
</record>
<record id="ir_actions_server_open_menu_kanban" model="ir.actions.server">
<field name="name">AI Tool: Open Menu Kanban</field>
<field name="model_id" ref="model_ai_tool"/>
<field name="state">code</field>
<field name="use_in_ai" eval="True"/>
<field name="ai_tool_name">open_menu_kanban</field>
<field name="ai_tool_thinking_text">Opening the kanban view</field>
<field name="ai_tool_description">Open the kanban view of a menu in the user's browser.</field>
<field name="ai_tool_schema">{
"type": "object",
"properties": {
"menu_id": {"type": "integer"},
"model_name": {"type": "string"},
"custom_domain": {"type": "string"},
"selected_filters": {"type": "array", "items": {"type": "string"}},
"selected_groupbys": {"type": "array", "items": {"type": "string"}},
"search": {"type": "string"}
},
"required": ["menu_id", "model_name"]
}</field>
<field name="code">ai["result"] = record._ai_tool_open_menu_kanban(menu_id, model_name, selected_filters, selected_groupbys, search, custom_domain)</field>
</record>
<record id="ir_actions_server_open_menu_pivot" model="ir.actions.server">
<field name="name">AI Tool: Open Menu Pivot</field>
<field name="model_id" ref="model_ai_tool"/>
<field name="state">code</field>
<field name="use_in_ai" eval="True"/>
<field name="ai_tool_name">open_menu_pivot</field>
<field name="ai_tool_thinking_text">Building the pivot view</field>
<field name="ai_tool_description">Open a pivot view for a menu with the given rows, columns and measures.</field>
<field name="ai_tool_schema">{
"type": "object",
"properties": {
"menu_id": {"type": "integer"},
"model_name": {"type": "string"},
"row_groupbys": {"type": "array", "items": {"type": "string"}},
"col_groupbys": {"type": "array", "items": {"type": "string"}},
"measures": {"type": "array", "items": {"type": "string"}},
"selected_filters": {"type": "array", "items": {"type": "string"}},
"selected_groupbys": {"type": "array", "items": {"type": "string"}},
"search": {"type": "string"},
"custom_domain": {"type": "string"}
},
"required": ["menu_id", "model_name"]
}</field>
<field name="code">ai["result"] = record._ai_tool_open_menu_pivot(menu_id, model_name, selected_filters, selected_groupbys, row_groupbys, col_groupbys, measures, search, custom_domain)</field>
</record>
<record id="ir_actions_server_open_menu_graph" model="ir.actions.server">
<field name="name">AI Tool: Open Menu Graph</field>
<field name="model_id" ref="model_ai_tool"/>
<field name="state">code</field>
<field name="use_in_ai" eval="True"/>
<field name="ai_tool_name">open_menu_graph</field>
<field name="ai_tool_thinking_text">Drawing the chart</field>
<field name="ai_tool_description">Open a graph view for a menu. Choose the chart type, the group by and the measures.</field>
<field name="ai_tool_schema">{
"type": "object",
"properties": {
"menu_id": {"type": "integer"},
"model_name": {"type": "string"},
"row_groupbys": {"type": "array", "items": {"type": "string"}},
"measures": {"type": "array", "items": {"type": "string"}},
"chart_type": {"type": "string", "enum": ["bar", "line", "pie"]},
"selected_filters": {"type": "array", "items": {"type": "string"}},
"selected_groupbys": {"type": "array", "items": {"type": "string"}},
"search": {"type": "string"},
"custom_domain": {"type": "string"}
},
"required": ["menu_id", "model_name"]
}</field>
<field name="code">ai["result"] = record._ai_tool_open_menu_graph(menu_id, model_name, selected_filters, selected_groupbys, row_groupbys, measures, chart_type, search, custom_domain)</field>
</record>
<record id="ir_actions_server_adjust_search" model="ir.actions.server">
<field name="name">AI Tool: Adjust Search</field>
<field name="model_id" ref="model_ai_tool"/>
<field name="state">code</field>
<field name="use_in_ai" eval="True"/>
<field name="ai_tool_name">adjust_search</field>
<field name="ai_tool_thinking_text">Refining the current view</field>
<field name="ai_tool_description">Modify the view the user is currently looking at: add or remove filters, change group by, switch view type.</field>
<field name="ai_tool_schema">{
"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"]
}</field>
<field name="code">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)</field>
</record>
<record id="ir_actions_server_compute_report_measures" model="ir.actions.server">
<field name="name">AI Tool: Compute Report Measures</field>
<field name="model_id" ref="model_ai_tool"/>
<field name="state">code</field>
<field name="use_in_ai" eval="True"/>
<field name="ai_tool_name">compute_report_measures</field>
<field name="ai_tool_thinking_text">Listing the available measures</field>
<field name="ai_tool_description">List the numeric fields that can be used as measures in a pivot or graph view.</field>
<field name="ai_tool_schema">{
"type": "object",
"properties": {
"action_id": {"type": "integer"},
"model": {"type": "string"}
},
"required": ["model"]
}</field>
<field name="code">ai["result"] = record._ai_tool_compute_report_measures(action_id, model)</field>
</record>
<record id="ir_actions_server_run_view_action" model="ir.actions.server">
<field name="name">AI Tool: Run View Action</field>
<field name="model_id" ref="model_ai_tool"/>
<field name="state">code</field>
<field name="use_in_ai" eval="True"/>
<field name="ai_tool_name">run_view_action</field>
<field name="ai_tool_thinking_text">Opening the view</field>
<field name="ai_tool_description">Open a menu using its default action and view type.</field>
<field name="ai_tool_schema">{
"type": "object",
"properties": {
"menu_id": {"type": "integer"},
"action_type": {"type": "string", "enum": ["list", "kanban", "form", "pivot", "graph"]}
},
"required": ["menu_id", "action_type"]
}</field>
<field name="code">ai["result"] = record._ai_tool_run_view_action(menu_id, action_type)</field>
</record>
<!-- ================= previews & writes ================= -->
<record id="ir_actions_server_preview_records" model="ir.actions.server">
<field name="name">AI Tool: Prepare Record Previews</field>
<field name="model_id" ref="model_ai_tool"/>
<field name="state">code</field>
<field name="use_in_ai" eval="True"/>
<field name="ai_tool_name">prepare_record_previews</field>
<field name="ai_tool_thinking_text">Preparing the preview</field>
<field name="ai_tool_description">Prepare clickable previews of records so the user can open them from the chat.</field>
<field name="ai_tool_schema">{
"type": "object",
"properties": {
"model_name": {"type": "string"},
"record_ids": {"type": "array", "items": {"type": "integer"}},
"preview_label": {"type": "string"}
},
"required": ["model_name", "record_ids"]
}</field>
<field name="code">ai["result"] = record._ai_tool_prepare_record_previews(model_name, record_ids, preview_label)</field>
</record>
<record id="ir_actions_server_read_binary_content" model="ir.actions.server">
<field name="name">AI Tool: Read Binary Content</field>
<field name="model_id" ref="model_ai_tool"/>
<field name="state">code</field>
<field name="use_in_ai" eval="True"/>
<field name="ai_tool_name">read_binary_content</field>
<field name="ai_tool_thinking_text">Reading the attached file</field>
<field name="ai_tool_description">Read the text content of a binary field (PDF, image, attachment) linked to a record.</field>
<field name="ai_tool_schema">{
"type": "object",
"properties": {
"model_name": {"type": "string"},
"record_ids": {"type": "array", "items": {"type": "integer"}},
"field_name": {"type": "string"}
},
"required": ["model_name", "record_ids"]
}</field>
<field name="code">ai["result"] = record._ai_tool_read_binary_content(model_name, record_ids, field_name)</field>
</record>
<record id="ir_actions_server_create_records" model="ir.actions.server">
<field name="name">AI Tool: Create Records</field>
<field name="model_id" ref="model_ai_tool"/>
<field name="state">code</field>
<field name="use_in_ai" eval="True"/>
<field name="ai_tool_name">create_records</field>
<field name="ai_tool_thinking_text">Creating the record</field>
<field name="ai_tool_requires_confirmation" eval="True"/>
<field name="ai_tool_description">Create one or more records. The user is asked to confirm before anything is written.</field>
<field name="ai_tool_schema">{
"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"]
}</field>
<field name="code">ai["result"] = record._ai_tool_create_records(ai, explanation, preview_menu_id, model_name, values)</field>
</record>
<record id="ir_actions_server_update_records" model="ir.actions.server">
<field name="name">AI Tool: Update Records</field>
<field name="model_id" ref="model_ai_tool"/>
<field name="state">code</field>
<field name="use_in_ai" eval="True"/>
<field name="ai_tool_name">update_records</field>
<field name="ai_tool_thinking_text">Updating the records</field>
<field name="ai_tool_requires_confirmation" eval="True"/>
<field name="ai_tool_description">Update fields on existing records. Always pass a precise domain; updating every record is refused. The user confirms first.</field>
<field name="ai_tool_schema">{
"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"]
}</field>
<field name="code">ai["result"] = record._ai_tool_update_records(ai, explanation, preview_menus, updates)</field>
</record>
<!-- ================= interaction & skills ================= -->
<record id="ir_actions_server_ask_user_question" model="ir.actions.server">
<field name="name">AI Tool: Ask User Question</field>
<field name="model_id" ref="model_ai_tool"/>
<field name="state">code</field>
<field name="use_in_ai" eval="True"/>
<field name="ai_tool_name">ask_user_question</field>
<field name="ai_tool_thinking_text">Asking you a question</field>
<field name="ai_tool_description">Ask the user a question and wait. Use it only when the answer cannot be resolved by searching the database.</field>
<field name="ai_tool_schema">{
"type": "object",
"properties": {
"question": {"type": "string"},
"choices": {"type": "array", "items": {"type": "string"}},
"multi_select": {"type": "boolean"},
"allow_free_text": {"type": "boolean"}
},
"required": ["question"]
}</field>
<field name="code">ai["result"] = record._ai_tool_ask_user_question(ai, question, choices, multi_select, allow_free_text)</field>
</record>
<record id="ir_actions_server_load_skills" model="ir.actions.server">
<field name="name">AI Tool: Load Skills</field>
<field name="model_id" ref="model_ai_tool"/>
<field name="state">code</field>
<field name="use_in_ai" eval="True"/>
<field name="ai_tool_name">load_skills</field>
<field name="ai_tool_thinking_text">Loading the relevant skill</field>
<field name="ai_tool_description">Load one or more skills by id. Their instructions are returned and their tools become available. Call it at most once per request.</field>
<field name="ai_tool_schema">{
"type": "object",
"properties": {
"skill_ids": {"type": "array", "items": {"type": "integer"}}
},
"required": ["skill_ids"]
}</field>
<field name="code">ai["result"] = record._ai_tool_load_skills(ai, skill_ids)</field>
</record>
</odoo>

14
dn_ai/data/ir_cron.xml Normal file
View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Housekeeping: drop AI conversations nobody touched for 30 days. -->
<record id="ir_cron_ai_vacuum" model="ir.cron">
<field name="name">DN AI: vacuum idle AI conversations</field>
<field name="model_id" ref="model_discuss_channel"/>
<field name="state">code</field>
<field name="code">model._remove_ai_chat_channels()</field>
<field name="user_id" ref="base.user_root"/>
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="priority">9</field>
</record>
</odoo>