Skip to Content
Menú
This question has been flagged
1 Respondre
8057 Vistes

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

Avatar
Descartar
Best Answer

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);




Avatar
Descartar
Related Posts Respostes Vistes Activitat
1
de nov. 16
15035
0
de març 15
4506
1
de febr. 23
2581
1
d’ag. 17
6035
0
de jul. 16
4873