Odoo Help


How to assign the logged in user as a default value? [Closed]

on 2/28/14, 1:53 PM 2,782 views

The Question has been closed

Sudhir Arya (ERP Harbor Consulting Services)
on 03/01/2014 02:32:33

Hello, I am trying to find a way to make the logged in user as a default value for a new record.
Is there a way to do that using the _defaults variable in the class file?

I am using the _defaults variable to set default values for other fields, but I dont know how to dynamically set my 'status_by' field to the logged in user id. Thank you for your help


Sudhir Arya (ERP Harbor Consulting Services)

--Sudhir Arya (ERP Harbor Consulting Services)--
| 6 8 8
Ahmedabad, India
--Sudhir Arya (ERP Harbor Consulting Services)--

• Co-Founder & Co-Owner at ERP Harbor Consulting Services

• ERP Consultant / ERP Customization / TechnoFunctional Expert

• Sound knowledge in Python, Odoo (Open ERP), XML, PostgreSQL

• Domain knowledge of Sale Management, Purchase Management, Warehouse Management, Manufacturing, Multi Company Configuration & Management, HR Management, Medical Management, Construction Management, Education Management, Point of Sale, Third Party Integrations

• Positive attitude and quick Learner

• Good analytical skill, quick bug and issue tracing and find the solution

• Good knowledge and experience in payment gateway integration with Odoo

• Ready to accept new challenges

• Active Memeber On Stackoverflow 




Sudhir Arya
ERP Harbor Consulting Services
Sudhir Arya (ERP Harbor Consulting Services)
On 2/28/14, 3:49 PM

Hi Eric,

You can assign current logged in user by following way also.

_defaults = {
    'status_by': lambda obj, cr, uid, context: uid,

Awesome! I didn't even think of that, but makes total sense. thank you

on 2/28/14, 6:45 PM
On 2/28/14, 2:25 PM

Okay so I found an answer at this url:


So basically I used this example, but modified a couple things so it worked with my app:

_defaults = {
    'status_by': lambda self,cr,uid, context: self.pool.get('res.users').browse(cr, uid, uid, context).id,

The lambda is an inline function that returns the id from the res_users table

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


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

0 follower(s)


Asked: 2/28/14, 1:53 PM
Seen: 2782 times
Last updated: 3/16/15, 8:10 AM