콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
4 답글
23518 화면

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
7495
1
9월 16
2568
1
6월 23
2144
1
5월 23
2081
1
10월 22
4245