I've created a user menu item next to logout button, and that new button contains a JS to call Python code function to redirect to another page. I'm trying to return an act_url to redirect, but its not working :/
I can't redirect directly from JS script because I NEED to call request.session to get the id_token, can't do it from JS.
My JS file:
odoo.define('login_redirect.ComplementMenu', function(require) {
"use strict";
var UserMenu = require('web.UserMenu');
var rpc = require('web.rpc');
var ComplementMenu = UserMenu.include({
/**
* @private
*/
_onMenuTeste: function () {
//alert("test");
rpc.query({
model: 'logout.test',
method: 'raise_key',
args: [],
});
},
});
return ComplementMenu; });
My python code:
class LogoutConfig(models.Model):
_name = 'logout.test'
@api.model
def raise_key(self):
#raise Warning("TESTE")
url_logout = request.httprequest.url_root + 'web/session/logout'
url_test = "***LINK***?id_token_hint={0}" \
"&post_logout_redirect_uri={1}" .format(str(request.session["id_token"]), url_logout)
return { 'type': 'ir.actions.act_url', 'url': url_test, 'target': 'self' }
The raise warning is working, but that return isn't working :/ I was using that same python function by calling form a server action and it was working, but not from JS script, anyone knows why?
Thanks!