Jeremy Gillbert
Jeremy Gillbert

Reputation: 133

Getting wrong User ID from self._uid

I'm trying to get the logged in user's id from self._uid. But when I logged in with a user and I got the user_id = 1 (which is the user_id of the administrator account)

That is my line. Am I doing something wrong?

user_id = self._uid

Upvotes: 1

Views: 619

Answers (1)

Bhavesh Odedra
Bhavesh Odedra

Reputation: 11143

Replace your code

from

user_id = self._uid

to

user_id = self.env.user

These will give us current logged user as a recordset. So if you need id, get it like self.env.user.id

Upvotes: 1

Related Questions