Friday 13 October 2017

How to Get Currently Logged In User in Odoo



In this tutorial, i will teach you the simplest way to get the currently logged in user in Odoo. These tutorial is based on version 8, 9 and 10.

Let's get to it...

To get the currently logged user in Odoo, i will create a small method that gets the logged in user and default the method on a field.


Now that you have the method, all you need is to default the method on a field. The field you are returning the method on, can either be Char or a Many2one field, it's your choice


If the field is Char, then you need to return record.name, as shown in the code, because the model it searches returns an id value, so you need the name to be able to get the exact value from the model.

If your field is Many2one, then you dont need to return record.name, all you need is just to return record alone, and the Many2one field will do the magic.

Now, let's put the pieces together...

No comments:

Post a Comment