Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
5711 Представления

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 Ответы Просмотры Активность
3
мар. 24
6998
2
дек. 22
24064
1
дек. 20
18830
6
янв. 24
13905
1
авг. 19
3774