コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
5747 ビュー

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
7093
2
12月 22
24096
1
12月 20
18881
6
1月 24
13959
1
8月 19
3806