diff --git a/yuthon_ai_agent/models/ai_manual.py b/yuthon_ai_agent/models/ai_manual.py new file mode 100644 index 000000000..3505081ac --- /dev/null +++ b/yuthon_ai_agent/models/ai_manual.py @@ -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) diff --git a/yuthon_ai_agent/views/ai_manual_views.xml b/yuthon_ai_agent/views/ai_manual_views.xml new file mode 100644 index 000000000..7b04e39dc --- /dev/null +++ b/yuthon_ai_agent/views/ai_manual_views.xml @@ -0,0 +1,109 @@ + + + + + + + + ai.manual.tree + ai.manual + + + + + + + + + + + + + + + ai.manual.form + ai.manual + +
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ + + + + + ai.manual.search + ai.manual + + + + + + + + + + + + + + + + + 操作手册 + ai.manual + tree,form + {'search_default_filter_active': 1, 'search_default_group_module': 1} + + + + + +