Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
4 ตอบกลับ
23307 มุมมอง

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
7387
1
ก.ย. 16
2433
1
มิ.ย. 23
2023
1
พ.ค. 23
1972
1
ต.ค. 22
4140