菜单跳转
This commit is contained in:
@@ -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': [
|
||||
|
||||
@@ -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, [])}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user