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

I need to get current user in function fetch_from_channel in chat_manager.js in addon mail

I tried  to use self.session.uid. But its not working in this file.

And i need to get this without using python function

形象
丢弃

Check the context, dataset,

最佳答案

var session = require('web.session');

user = session.uid


Important: js is asyncronous. Make sure, all the data about the session is uploaded to the time when you are trying to retrieve the data. E.g. console.log(session). What is kept there, when you try to get the active user?

形象
丢弃
编写者

Thanks, it works fine now

thanks, best.
for addition : in ver 17 it can work this way :

import { session } from "@web/session";

console.log(session.uid)

最佳答案

In Odoo 12 you can get the current user ID like this

var session = require('web.session');

...
var user = session.uid
console.log('user >>>> ', user)
形象
丢弃
最佳答案

For version 17 OWL we can go this way :

import { session } from "@web/session";

console.log(session.uid)

形象
丢弃
最佳答案


var session = require('web.session');

user = session.user_id


形象
丢弃

I got result while putting session.user_id in my code.

This works fine for me. Thank you MITUL SHAH

相关帖文 回复 查看 活动
1
3月 17
7327
1
9月 16
2399
1
6月 23
1932
1
5月 23
1877
1
10月 22
4021