初始提交

This commit is contained in:
2026-11-04 19:58:07 +08:00
commit 53b7d22429
829 changed files with 469986 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="ir_actions_server_view_form" model="ir.ui.view">
<field name="name">ir.actions.server.view.form.inherit.ai</field>
<field name="model">ir.actions.server</field>
<field name="inherit_id" ref="base.view_server_action_form"/>
<field name="priority">20</field>
<field name="arch" type="xml">
<data>
<xpath expr="//page[@name='usage']" position="inside">
<group name="use_in_ai">
<label for="use_in_ai"/>
<div>
<field
name="use_in_ai"
invisible="not ai_tool_is_candidate"
readonly="context.get('default_use_in_ai', False) and not context.get('allow_use_in_ai_edit', False)"/>
<field name="ai_tool_name" nolabel="1" class="oe_inline ms-2" placeholder="ai_tool_name" invisible="not use_in_ai"/>
</div>
<field name="ai_tool_description"
invisible="not use_in_ai or not ai_tool_is_candidate"
placeholder="Short explanation of what this does"/>
<field name="ai_tool_schema"
placeholder="JSON schema for the parameters of the action (leave empty if no arguments are needed)"
invisible="not use_in_ai or not ai_tool_is_candidate or not ai_tool_has_schema"
widget="ai_json_schema"/>
</group>
</xpath>
<xpath expr="//page[@name='usage']" position="attributes">
<attribute name="invisible" add="not ai_tool_is_candidate or context.get('is_modal')" separator="and"/>
</xpath>
<xpath expr="//page[@name='explanation']" position="before">
<page string="Prompt" name="ai_action_prompt" invisible="state != 'ai'">
<group>
<label for="ai_tool_ids"/>
<div class="d-flex flex-row align-items-baseline">
<i
class="oi text-warning me-2"
data-icon="warning"
invisible="not ai_tool_show_warning"
aria-hidden="true"
title="The AI will not be limited by the groups defined on tools"/>
<field name="ai_tool_ids"
nolabel="1"
widget="many2many_tags"
options="{'no_create': True, 'no_create_edit': True}"/>
</div>
<field name="ai_action_prompt"
string="Instructions"
widget="ai_prompt"
options="{'model_reference_field': 'model_name'}"
required="state == 'ai'"/>
</group>
</page>
</xpath>
<xpath expr="//page[@name='ir_actions_server_code_help']//ul" position="inside">
<li invisible="not use_in_ai">
To return a result to the AI agent, do <code>ai['result'] = ...</code>
</li>
</xpath>
<xpath expr="//button[@name='create_action']" position="attributes">
<attribute name="invisible" add="context.get('default_use_in_ai', False)" separator="or"/>
</xpath>
</data>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="mail_scheduled_message_view_form" model="ir.ui.view">
<field name="name">mail.scheduled.message.view.form.inherit</field>
<field name="model">mail.scheduled.message</field>
<field name="inherit_id" ref="mail.mail_scheduled_message_view_form"/>
<field name="arch" type="xml">
<xpath expr="//footer/field[@name='scheduled_date']" position="after">
<field name="body" widget="mail_composer_chatgpt"/>
</xpath>
</field>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record id="mail_template_view_form" model="ir.ui.view">
<field name="name">mail.template.view.form.inherit.ai</field>
<field name="model">mail.template</field>
<field name="inherit_id" ref="mail.email_template_form"/>
<field name="arch" type="xml">
<xpath expr="//page[@name='content']//div[hasclass('text-muted')]" position="replace">
<div invisible="not can_write" class="fst-italic text-muted">Tip: Write /field to insert values or /prompt to integrate AI-generated dynamic content!</div>
</xpath>
</field>
</record>
</data>
</odoo>

127
ai/views/templates.xml Normal file
View File

@@ -0,0 +1,127 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="ai_log_action">
<span>Action <b t-out="action.name"/> executed.</span>
<t t-if="tool_calls">
<div t-foreach="tool_calls" t-as="call">
<t t-if="call['error']">❌ </t>
<t t-else="">✅ </t>
<a href="#" class="o_ai_tool_summary text-black">
<b t-out="call['action'].name"/>
<div t-if="call['arguments']" class="o_ai_tool_arguments">
<span>with arguments</span>
<span t-foreach="call['arguments']" t-as="arg">
<t t-out="arg"/> = <i t-out="call['arguments'][arg] or 'False'"/>
</span>
</div>
</a>
<t t-if="call['error']">
<i class="oi text-danger" data-icon="arrow_forward" aria-hidden="true"/>
<span class="text-danger" t-out="call['error']"/>
</t>
<t t-elif="call['result'] and call['result'] != 'success'">
<i class="oi" data-icon="arrow_forward" aria-hidden="true"/>
<span t-out="call['result']"/>
</t>
</div>
</t>
<span t-else="">
No tool was executed.
</span>
</template>
<template id="ai_records_preview">
<p><t t-out="explanation" /></p>
<div class="o-rounded-bubble border mt-1 p-2">
<t t-call="ai.ai_record_preview"/>
</div>
</template>
<template id="ai_record_preview">
<t t-if="len(sections) > 1">
<ul class="mb-0">
<li t-foreach="sections" t-as="section">
<t t-set="items" t-value="section['items']"/>
<b><t t-out="section['label']"/>:</b>
<t t-if="template == 'create'">
<t t-call="ai.ai_record_create_fields_preview"/>
</t>
<t t-else="">
<t t-call="ai.ai_record_update_fields_preview"/>
</t>
</li>
</ul>
</t>
<t t-else="">
<t t-set="items" t-value="sections[0]['items']"/>
<t t-if="template == 'create'">
<t t-call="ai.ai_record_create_fields_preview"/>
</t>
<t t-else="">
<p class="mb-0"><b><t t-out="sections[0]['label']"/></b>:</p>
<t t-call="ai.ai_record_update_fields_preview"/>
</t>
</t>
</template>
<template id="ai_record_update_fields_preview">
<ul>
<li t-foreach="items" t-as="change">
<t t-if="change.get('old_val')">
<t t-out="change['old_val']"/> → <t t-out="change['new_val']"/> (<i><t t-out="change['field_name']"/></i>)
</t>
<t t-else="">
<t t-out="change['field_name']"/> → <t t-out="change['new_val']"/>
</t>
</li>
</ul>
</template>
<template id="ai_record_create_fields_preview">
<t t-if="len(sections) == 1 and len(items) == 1">
<p>
<t t-set="item" t-value="items[0]"/>
<t t-call="ai.ai_record_create_fields_preview_value"/>
</p>
</t>
<t t-else="">
<t t-if="len(items) == 1">
<t t-set="item" t-value="items[0]"/>
<t t-call="ai.ai_record_create_fields_preview_value"/>
</t>
<t t-else="">
<ul>
<li t-foreach="items" t-as="item">
<t t-call="ai.ai_record_create_fields_preview_value"/>
</li>
</ul>
</t>
</t>
</template>
<template id="ai_record_create_fields_preview_value">
<t t-if="len(items) > 1 or len(sections) == 1">
<span class="pe-1"><b><t t-out="item['label']"/></b>:</span>
</t>
<t t-set="item_val" t-value="item['value']"/>
<t t-if="isinstance(item_val, list)">
<ul>
<t t-foreach="item['value']" t-as="command">
<li>
<span><t t-out="command['label']"/>:</span>
<t t-if="isinstance(command['value'], list)">
<t t-set="items" t-value="command['value']"/>
<t t-call="ai.ai_record_create_fields_preview"/>
</t>
<t t-else="">
<t t-out="command['value']"/>
</t>
</li>
</t>
</ul>
</t>
<t t-else="">
<t t-out="item_val"/>
</t>
</template>
</odoo>