Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
2842 Vues

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
Ignorer
Meilleure réponse

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
Ignorer

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

Publications associées Réponses Vues Activité
1
mars 15
4917
8
mars 22
40478
0
avr. 19
3804
3
nov. 18
3910
3
nov. 17
15949