跳至内容
菜单
此问题已终结
1 回复
5691 查看

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, )

相关帖文 回复 查看 活动
3
3月 24
6954
2
12月 22
24010
1
12月 20
18751
6
1月 24
13848
1
8月 19
3745