Skip to Content
Menu
This question has been flagged
4 Replies
23301 Rodiniai

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

Portretas
Atmesti

Check the context, dataset,

Best Answer

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?

Portretas
Atmesti
Autorius

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)

Best Answer

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)
Portretas
Atmesti
Best Answer

For version 17 OWL we can go this way :

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

console.log(session.uid)

Portretas
Atmesti
Best Answer


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

user = session.user_id


Portretas
Atmesti

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

This works fine for me. Thank you MITUL SHAH

Related Posts Replies Rodiniai Veikla
1
kov. 17
7385
1
rugs. 16
2431
1
birž. 23
2021
1
geg. 23
1963
1
spal. 22
4133