从javascript获取当前url odoo

时间:2017-08-28 08:25:34

标签: javascript session url controller odoo-8

我的代码出了什么问题,我希望从JavaScript中获取当前网址并保留所有网址:

controller.py:

class MyController(http.Controller): 
    @http.route(['/action_set_current_url/<string:url>'], type='json', auth="public")
    def set_current_url(self, url, **post):
     request.session['my_current_url'] = url
     return {"my_current_url":my_current_url}

我在JavaScript代码上调用此函数:

$(window).on('hashchange', function(e){
       var url=window.location.href 
       openerp.jsonRpc("/action_set_current_url/", 'call',url)
});

我希望在我的模型中使用:

current_url = http.request.session.get('my_current_url')

但我一无所获! 感谢

0 个答案:

没有答案