Before this commit, in the search view, it is not possible to filter the employees to only have those ones who is a subordinate of the current user. That is, if Pierre is the current employee/user and he is the manager of Paul and Paul is the manager of Jacques. Pierre could want to see his subordinates in his view of so Paul and Jacques instead of just Paul. This commit adds a new boolean field called `is_subordinate` in `hr.employee` and `hr.employee.public` models. This field will be True if the employee is a subordinate of the current user. task-3061362 closes odoo/odoo#108060 Related: odoo/enterprise#34181 Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
21 lines
904 B
Python
21 lines
904 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import fields, models
|
|
|
|
|
|
class Employee(models.Model):
|
|
_inherit = ["hr.employee"]
|
|
|
|
subordinate_ids = fields.One2many('hr.employee', string='Subordinates', compute='_compute_subordinates', help="Direct and indirect subordinates",
|
|
compute_sudo=True)
|
|
is_subordinate = fields.Boolean(compute="_compute_is_subordinate", search="_search_is_subordinate")
|
|
|
|
|
|
class HrEmployeePublic(models.Model):
|
|
_inherit = ["hr.employee.public"]
|
|
|
|
subordinate_ids = fields.One2many('hr.employee.public', string='Subordinates', compute='_compute_subordinates', help="Direct and indirect subordinates",
|
|
compute_sudo=True)
|
|
is_subordinate = fields.Boolean(compute="_compute_is_subordinate", search="_search_is_subordinate")
|