mirror of
https://github.com/bringout/oca-ocb-hr.git
synced 2026-04-26 00:12:00 +02:00
Initial commit: Hr packages
This commit is contained in:
commit
62531cd146
2820 changed files with 1432848 additions and 0 deletions
|
|
@ -0,0 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import hr_org_chart_mixin
|
||||
from . import hr_employee
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,18 @@
|
|||
# -*- 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)
|
||||
|
||||
|
||||
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)
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class HrEmployeeBase(models.AbstractModel):
|
||||
_inherit = "hr.employee.base"
|
||||
|
||||
child_all_count = fields.Integer(
|
||||
'Indirect Subordinates Count',
|
||||
compute='_compute_subordinates', recursive=True, store=False,
|
||||
compute_sudo=True)
|
||||
|
||||
def _get_subordinates(self, parents=None):
|
||||
"""
|
||||
Helper function to compute subordinates_ids.
|
||||
Get all subordinates (direct and indirect) of an employee.
|
||||
An employee can be a manager of his own manager (recursive hierarchy; e.g. the CEO is manager of everyone but is also
|
||||
member of the RD department, managed by the CTO itself managed by the CEO).
|
||||
In that case, the manager in not counted as a subordinate if it's in the 'parents' set.
|
||||
"""
|
||||
if not parents:
|
||||
parents = self.env[self._name]
|
||||
|
||||
indirect_subordinates = self.env[self._name]
|
||||
parents |= self
|
||||
direct_subordinates = self.child_ids - parents
|
||||
child_subordinates = direct_subordinates._get_subordinates(parents=parents) if direct_subordinates else self.browse()
|
||||
indirect_subordinates |= child_subordinates
|
||||
return indirect_subordinates | direct_subordinates
|
||||
|
||||
|
||||
@api.depends('child_ids', 'child_ids.child_all_count')
|
||||
def _compute_subordinates(self):
|
||||
for employee in self:
|
||||
employee.subordinate_ids = employee._get_subordinates()
|
||||
employee.child_all_count = len(employee.subordinate_ids)
|
||||
Loading…
Add table
Add a link
Reference in a new issue