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

Hi, 

How can i search or get the field "id" from table "res.users" of the one that is currently logged in.

i tried this one.    my_id=self.pool.get('res.users').search(cr,uid,['id','=','id']), but it returns all records id ( i want the id only of the account im using currently)

because i want to use this "my_id" as a indicator where i will write my data in future.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi Lakay, you can use "uid" parameter in functions to get the current user logged in or you can get it by the context

อวตาร
ละทิ้ง
ผู้เขียน

if by the context, how will i do it?

Lakay, change your code to: my_id=self.pool.get('res.users').search(cr,uid,['id','=',uid]), That should do it.

Actually, as Maniganda said, you can use uid directly without having to do a search. Sorry, my previous answer is a unnecessary.

ผู้เขียน

thanks now i get it.