From 7e5b320ef811b31f5b9df8512ca12126ad33e3d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Wed, 1 Jul 2026 20:21:44 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8F=9C=E5=8D=95=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_ai_agent/__manifest__.py | 2 +- yuthon_ai_agent/models/ai_agent.py | 2 +- yuthon_ai_agent/static/src/css/ai_floating.css | 10 ++++++---- yuthon_ai_agent/static/src/js/ai_floating.js | 18 +++++++++++++++--- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/yuthon_ai_agent/__manifest__.py b/yuthon_ai_agent/__manifest__.py index 10fd3d296..b350cdf18 100644 --- a/yuthon_ai_agent/__manifest__.py +++ b/yuthon_ai_agent/__manifest__.py @@ -13,7 +13,7 @@ - AI 规则配置系统 """, 'author': 'pengyuthon', - 'version': '17.0.2.2.1', + 'version': '17.0.2.2.2', 'license': 'LGPL-3', 'depends': ['base', 'web', 'hr', 'documents', 'sh_backmate_theme_adv_enterprise'], 'data': [ diff --git a/yuthon_ai_agent/models/ai_agent.py b/yuthon_ai_agent/models/ai_agent.py index b66fbc396..e4fba6506 100644 --- a/yuthon_ai_agent/models/ai_agent.py +++ b/yuthon_ai_agent/models/ai_agent.py @@ -614,7 +614,7 @@ class AiConversation(models.Model): action_ref = menu.action raw_action = action_ref.sudo().read()[0] keep_keys = { - 'name', 'type', 'target', 'res_model', 'res_id', 'view_mode', 'views', + 'id', 'name', 'type', 'target', 'res_model', 'res_id', 'view_mode', 'views', 'domain', 'context', 'search_view_id', 'limit', 'binding_type', } action = {k: raw_action[k] for k in keep_keys if k in raw_action and raw_action[k] not in (None, False, [])} diff --git a/yuthon_ai_agent/static/src/css/ai_floating.css b/yuthon_ai_agent/static/src/css/ai_floating.css index 8f2c96b92..f7a2fd0c9 100644 --- a/yuthon_ai_agent/static/src/css/ai_floating.css +++ b/yuthon_ai_agent/static/src/css/ai_floating.css @@ -191,14 +191,16 @@ } /* AI 导航按钮(菜单跳转) */ .o_ai_action_wrap { - margin-top: 10px; + margin-top: 8px; + display: flex; + justify-content: flex-start; } .o_ai_action_btn { display: inline-flex; align-items: center; justify-content: center; - gap: 8px; - padding: 9px 18px; + gap: 6px; + padding: 6px 14px; background: #7c3aed; color: #fff; border: none; @@ -215,7 +217,7 @@ box-shadow: 0 4px 12px rgba(124,58,237,0.35); } .o_ai_action_btn i { - font-size: 13px; + font-size: 12px; } .o_ai_loading { display: flex; diff --git a/yuthon_ai_agent/static/src/js/ai_floating.js b/yuthon_ai_agent/static/src/js/ai_floating.js index fa8d79490..450f07114 100644 --- a/yuthon_ai_agent/static/src/js/ai_floating.js +++ b/yuthon_ai_agent/static/src/js/ai_floating.js @@ -565,27 +565,39 @@ function toggleExpand() { */ function doOdooAction(action) { if (!action) return; + let usedService = false; try { // 尝试通过 OWL app 的 action service 执行(无刷新导航) const appEl = document.querySelector('.o_web_client'); if (appEl && appEl.__owl__ && appEl.__owl__.component) { const env = appEl.__owl__.component.env; if (env && env.services && env.services.action) { - env.services.action.doAction(action); + env.services.action.doAction(action, { clearBreadcrumbs: true }); + usedService = true; return; } } } catch (e) { console.warn('[AI] 无法访问 action service,降级为 URL 跳转:', e); } - // 降级方案:hash-based URL 导航 - if (action && action.type === 'ir.actions.act_window') { + if (usedService) return; + + // 降级方案:构造正确的 Odoo URL hash + if (action.type === 'ir.actions.act_window') { const parts = []; + // 优先用真实 action id 生成最短路径,没有 id 时塞整个 action JSON + if (action.id) { + parts.push('action=' + action.id); + } else { + parts.push('action=' + encodeURIComponent(JSON.stringify(action))); + } if (action.res_model) parts.push('model=' + encodeURIComponent(action.res_model)); if (action.res_id) parts.push('id=' + action.res_id); const viewType = action.res_id ? 'form' : ((action.view_mode || 'list').split(',')[0]); parts.push('view_type=' + viewType); window.location.hash = parts.join('&'); + } else if (action.type === 'ir.actions.client') { + window.location.hash = '#action=' + encodeURIComponent(JSON.stringify(action)); } }