Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
4 Odpowiedzi
23203 Widoki

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

Awatar
Odrzuć

Check the context, dataset,

Najlepsza odpowiedź

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?

Awatar
Odrzuć
Autor

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)

Najlepsza odpowiedź

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)
Awatar
Odrzuć
Najlepsza odpowiedź

For version 17 OWL we can go this way :

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

console.log(session.uid)

Awatar
Odrzuć
Najlepsza odpowiedź


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

user = session.user_id


Awatar
Odrzuć

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

This works fine for me. Thank you MITUL SHAH

Powiązane posty Odpowiedzi Widoki Czynność
1
mar 17
7354
1
wrz 16
2406
1
cze 23
1944
1
maj 23
1897
1
paź 22
4058