Hello Odooers, Odoogig and Odoo Lovers,
In this Odoo Tips Technical Tutorial, I would like to explain about how to Pass Default Employee value into Employee Field in odoo in detail with code example.
- In odoo , every user is linked with each employee . if you want to know how to link user with employee you can check here
- If you are creating any model with employee field and want to show current logged user employee value will come as default then this odoo technical tip would be helpful to you.
odoo tips,odoo tips 2018, Odoo technical tips, odoo tips for beginner, odoo beginner tutorial, odoo12.0
- Let’s create employee field and get the logged user employee detail by default to the field in odoo:
1.Create employee field with many2one
employee_id = fields.Many2one("hr.employee", string="Employee", default=_get_employee)
2. pass logged user employee detail by default to employee field by get_employee method
return self.env['hr.employee'].search([('user_id', '=', self.env.uid)],limit=1) or False
GET IN TOUCH.!
We’d Love to Hear from You! We are happy to answer any questions, you have regarding My Training.
Mail : firstname.lastname@example.org
Skype : mayur_maheshwari1
What’s app : +919924542042