跳至内容
菜单
此问题已终结
1 回复
8032 查看

Hi all,

I'm making a new app that creates menus "on the fly".

I need to know how to refresh the page in order to update menus. (Not manually, no F5, etc)

I tried with:

cr.commit()
openerp.service.restart_server()
 return {
            'type': 'ir.actions.client',
            'tag': 'home',
            'params': {'wait': True},
}

But that does not reload the page completly.

All suggestions are welcome.

Regards

形象
丢弃
最佳答案

You can use js and buses like this:
1. Send a message from Python when something changes

self.env['bus.bus'].sudo()._sendone(
'broadcast',
'crm_stage_changed',
{}
)


2. Subscribe to the bus event in JavaScript and reload the page when the message arrives:

/** @odoo-module **/

import { registry } from "@web/core/registry";

export const crmStageRefreshService = {
dependencies: ["bus_service"],

start(env, { bus_service }) {
bus_service.subscribe("crm_stage_changed", () => {
window.location.reload();
});
},
};

registry.category("services").add("crmStageRefresh", crmStageRefreshService);




形象
丢弃
相关帖文 回复 查看 活动
1
11月 16
15014
0
3月 15
4484
1
2月 23
2573
1
8月 17
5985
0
7月 16
4845