ai模块测试
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import logging
|
||||
|
||||
from odoo import models, fields, api
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class AiManual(models.Model):
|
||||
_name = 'ai.manual'
|
||||
_description = '操作手册'
|
||||
_order = 'module_name, sequence, id'
|
||||
|
||||
name = fields.Char('手册名称', required=True)
|
||||
module_name = fields.Char('所属模块', required=True,
|
||||
help='如:销售管理、采购管理、库存管理、人事管理等')
|
||||
sequence = fields.Integer('排序', default=10)
|
||||
content = fields.Text('手册内容', required=True,
|
||||
help='AI 将直接读取此内容来指导用户操作')
|
||||
attachment_ids = fields.Many2many(
|
||||
'ir.attachment', 'ai_manual_attachment_rel',
|
||||
'manual_id', 'attachment_id',
|
||||
string='参考附件',
|
||||
help='可上传 PDF/Word 等原始手册文件作为参考(AI 不会直接读取附件,请将关键内容填入上方文本框)')
|
||||
active = fields.Boolean('启用', default=True)
|
||||
note = fields.Text('备注')
|
||||
|
||||
@api.model
|
||||
def get_all_manual_content(self):
|
||||
"""获取所有启用的手册内容,按模块分组返回"""
|
||||
manuals = self.sudo().search([('active', '=', True)])
|
||||
if not manuals:
|
||||
return ''
|
||||
result = []
|
||||
current_module = ''
|
||||
for manual in manuals:
|
||||
if manual.module_name != current_module:
|
||||
current_module = manual.module_name
|
||||
result.append(f'\n【{current_module}】')
|
||||
result.append(f'● {manual.name}:\n{manual.content}')
|
||||
return '\n'.join(result)
|
||||
@@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
|
||||
<!-- ============================================ -->
|
||||
<!-- 操作手册 - 列表视图 -->
|
||||
<!-- ============================================ -->
|
||||
<record id="view_ai_manual_tree" model="ir.ui.view">
|
||||
<field name="name">ai.manual.tree</field>
|
||||
<field name="model">ai.manual</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="操作手册">
|
||||
<field name="sequence" widget="handle"/>
|
||||
<field name="module_name"/>
|
||||
<field name="name"/>
|
||||
<field name="active" widget="boolean_toggle"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- ============================================ -->
|
||||
<!-- 操作手册 - 表单视图 -->
|
||||
<!-- ============================================ -->
|
||||
<record id="view_ai_manual_form" model="ir.ui.view">
|
||||
<field name="name">ai.manual.form</field>
|
||||
<field name="model">ai.manual</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="操作手册">
|
||||
<sheet>
|
||||
<widget name="web_ribbon" title="已停用"
|
||||
bg_color="text-bg-danger" invisible="active"/>
|
||||
|
||||
<div class="oe_title">
|
||||
<label for="name"/>
|
||||
<h1>
|
||||
<field name="name" placeholder="如:创建销售订单流程"/>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<group>
|
||||
<group>
|
||||
<field name="module_name"
|
||||
placeholder="如:销售管理、采购管理、库存管理"/>
|
||||
<field name="sequence"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="active"/>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
<notebook>
|
||||
<page string="手册内容" name="content">
|
||||
<div class="alert alert-info" role="alert">
|
||||
请将操作手册的关键内容以文字形式填写在下方,AI 将直接读取此内容来指导用户。
|
||||
内容建议包含:操作步骤、注意事项、常见问题等。
|
||||
</div>
|
||||
<field name="content" placeholder="请输入手册内容..."/>
|
||||
</page>
|
||||
<page string="参考附件" name="attachments">
|
||||
<div class="alert alert-warning" role="alert">
|
||||
附件仅作为参考存档,AI 不会直接读取附件内容。如需 AI 使用,请将关键内容复制到「手册内容」页签。
|
||||
</div>
|
||||
<field name="attachment_ids" widget="many2many_binary"/>
|
||||
</page>
|
||||
<page string="备注" name="note">
|
||||
<field name="note" placeholder="其他备注信息..."/>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- ============================================ -->
|
||||
<!-- 操作手册 - 搜索视图 -->
|
||||
<!-- ============================================ -->
|
||||
<record id="view_ai_manual_search" model="ir.ui.view">
|
||||
<field name="name">ai.manual.search</field>
|
||||
<field name="model">ai.manual</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="搜索手册">
|
||||
<field name="name"/>
|
||||
<field name="module_name"/>
|
||||
<filter name="filter_active" string="已启用"
|
||||
domain="[('active','=',True)]"/>
|
||||
<filter name="filter_inactive" string="已停用"
|
||||
domain="[('active','=',False)]"/>
|
||||
<separator/>
|
||||
<group expand="0" string="分组">
|
||||
<filter name="group_module" string="所属模块"
|
||||
context="{'group_by': 'module_name'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Action -->
|
||||
<record id="action_ai_manual" model="ir.actions.act_window">
|
||||
<field name="name">操作手册</field>
|
||||
<field name="res_model">ai.manual</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="context">{'search_default_filter_active': 1, 'search_default_group_module': 1}</field>
|
||||
</record>
|
||||
|
||||
<!-- 菜单 → 系统配置 -->
|
||||
<menuitem id="menu_ai_manual" name="操作手册"
|
||||
parent="menu_system_config" action="action_ai_manual" sequence="3"
|
||||
groups="yuthon_ai_agent.group_ai_agent_admin"/>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user