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

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
7386
2
12월 22
24406
1
12월 20
19387
6
2월 24
14277
1
8월 19
4045