跳至內容
選單
此問題已被標幟
1 回覆
2836 瀏覽次數

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

相關帖文 回覆 瀏覽次數 活動
1
3月 15
4915
8
3月 22
40464
0
4月 19
3801
3
11月 18
3906
3
11月 17
15943