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

Hi folks,

I am trying to get logged in user id by using below method. It is working fine whenever I try to create new record. 

But not on old records. I see Administrator/OdooBot user in current user id field in old records.

Please help me out to fix this issue.


def get_current_user_id(self):
return self.env.user.id
current_user_id = fields.Many2one('res.users', default=get_current_user_id)
อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

Default function will work only for newly creating records. If you need to update the existing records you may have to use compute function or update those records as needed using a scrypt.

Thanks

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

I tried by compute method also. But it is showing administrator's user ID instead of logged in users ID.

.i.e res_users(1,) but I need res_users(425, )

Related Posts ตอบกลับ มุมมอง กิจกรรม
Odoo Selection field issue แก้ไขแล้ว
3
มี.ค. 24
6837
2
ธ.ค. 22
23891
1
ธ.ค. 20
18622
6
ม.ค. 24
13726
1
ส.ค. 19
3640