Odoo Help


Niyas Raphy

--Niyas Raphy--
| 6 6 9
Calicut, India
--Niyas Raphy--

Odoo Techno Functionalist

Feel free to contact :  niyasraphyk@gmail.com

Niyas Raphy
On 3/12/18, 11:24 PM


Just try like this, as you have to show the Id of the employee in the field, change the Many2one field to a char field and try.

Python :

'logged_user':fields.char('Current User',  default=lambda self: self.env.uid),


<field name="logged_user"/>

Then you will get like this :


I choose this answer as the solution because it was simple and it didn´t force me to create a compute function or something like that.

Jesús Marco
on 3/13/18, 12:09 PM

Ankit H Gandhi(AHG)

--Ankit H Gandhi(AHG)--

| 6 5 6
Baroda, India
--Ankit H Gandhi(AHG)--

Learning Python..

Ankit H Gandhi(AHG)
On 9/19/18, 8:41 AM


You can use below code.

context = self._context

current_uid = context.get('uid')

user = self.env['res.users'].browse(current_uid)

Hope this help you.

Best Thanks,

Ankit H Gandhi.

Eli Tehuitzil
On 3/12/18, 3:31 PM

Try self.env.uid

I tried it and get username, not ID (numerical).

On my Py file I have: 'logged_user':fields.many2one('res.users','Current User', default=lambda self: self.env.uid),

and on my view.xml: <field name="logged_user"/>

and as a result I visualize: Current User: Administrator

Jesús Marco
on 3/12/18, 3:53 PM

Another note: each time I edit my Py file, I restart the odoo service and upgrade the module I´m working on, and everytime I restart the odoo service/upgrade the module I know it accepts the changes because of the debug logs I write.

Jesús Marco
on 3/12/18, 3:55 PM

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 3/12/18, 2:19 PM
Seen: 2519 times
Last updated: 9/19/18, 8:41 AM