Help

欢迎!

该社区面向专业人士和我们产品和服务的爱好者。
分享和讨论最好的内容和新的营销理念,建立您的专业形象,一起成为更好的营销人员。


0

fetch parent_id

Avatar
odoo
Avatar
Discard
1 Answer
0
Avatar
odoo
Best Answer

Hi  Abijith,

employee = self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)
if employee:
self.manager_id = employee.parent_id.id if employee.parent_id else False


1 Comment
Avatar
Discard
Avatar
odoo
-

either using a compute function based on above code or using 'related' you can get parent_id based on login user.

employee_id = fields.Many2one('hr.employee', string="Employee",
default=lambda self: self.env.user.employee_id)

manager_id = fields.Many2one('hr.employee', related='employee_id.parent_id')