Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
2988 มุมมอง

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

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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


อวตาร
ละทิ้ง

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 ตอบกลับ มุมมอง กิจกรรม
1
มี.ค. 15
5062
Get current user ID (no username) แก้ไขแล้ว
8
มี.ค. 22
40759
0
เม.ย. 19
3884
3
พ.ย. 18
4017
3
พ.ย. 17
16063