Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
4 Ответы
23177 Представления

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

Related Posts Ответы Просмотры Активность
1
мар. 17
7331
1
сент. 16
2399
1
июн. 23
1935
1
мая 23
1880
1
окт. 22
4025