Skip to Content
मेन्यू
This question has been flagged
1 Reply
2785 Views

hi

i need parent_id of a user from hr.employee to sale.order based on the user_id in hr.employee

so when we create quotation in sale.order parent_id should come as default corresponding to the user from the hr.employee

Avatar
Discard
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


Avatar
Discard

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')

Related Posts Replies Views Activity
1
मार्च 15
4850
8
मार्च 22
40384
0
अप्रैल 19
3753
3
नव॰ 18
3857
3
नव॰ 17
15916