Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
5567 Vizualizări

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)
Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
Autor

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 Răspunsuri Vizualizări Activitate
3
mar. 24
6695
2
dec. 22
23786
1
dec. 20
18386
6
ian. 24
13593
1
aug. 19
3555