



Get current logged In user id in Odoo/openERP model

Get current logged in user id in field:





current_user = fields.Many2one('res.users','Current User', default=lambda self: self.env.user.id)

current_user = fields.Many2one('res.users','Current User', default=lambda self: self.env.uid)

def get_user_id(self): return self.env.uid current_user = fields.Many2one('res.users','Current User', default=_get_user_id)

Get current user or logged in user id in odoo web controller

request.uid

or

request.session.uid

or

http.request.env.context.get('uid')

In this article you will learn how to getor current user login id. The question is why we need this id. The answer is that on the basis of current user we want to perform some action or show records/data on list or tree view , on odoo field or on odoo controller . In this tutorial I will show you different ways to get current user or logged in user id or active id.We can also get current user id or logged in user id using "We can also get current user id by defining default value of a field . Default value will be a function that returns the current user's id which can be accessed with. By using default function we can set any value to a field.Inside a custom or inherited web controller we can get the current user id by following codes.