From 9e14c112eef3b4098c0756b8da17a7253ea0c4d3 Mon Sep 17 00:00:00 2001 From: Philippe Wauthy Date: Mon, 17 Jan 2022 07:35:46 +0000 Subject: [PATCH] [IMP] hr_contract: add employee manager role Currently, there are two security roles in Payroll: officer and administrator. Both roles allow the user to have a full overview on all salaries of the company. This commit adds an employee manager role allowing an employee manager to view his reports' contracts. task-2731933 closes odoo/odoo#83191 Related: odoo/enterprise#23669 Signed-off-by: Kevin Baptiste --- addons/hr_contract/models/hr_contract.py | 1 + .../hr_contract/security/ir.model.access.csv | 1 + addons/hr_contract/security/security.xml | 22 ++++++++- .../hr_contract/views/hr_contract_views.xml | 48 +++++++++++++++---- 4 files changed, 62 insertions(+), 10 deletions(-) diff --git a/addons/hr_contract/models/hr_contract.py b/addons/hr_contract/models/hr_contract.py index f107a3f3c03..72c1597fe8d 100644 --- a/addons/hr_contract/models/hr_contract.py +++ b/addons/hr_contract/models/hr_contract.py @@ -13,6 +13,7 @@ class Contract(models.Model): _name = 'hr.contract' _description = 'Contract' _inherit = ['mail.thread', 'mail.activity.mixin'] + _mail_post_access = 'read' name = fields.Char('Contract Reference', required=True) active = fields.Boolean(default=True) diff --git a/addons/hr_contract/security/ir.model.access.csv b/addons/hr_contract/security/ir.model.access.csv index e4856ec71f3..d06a65003cc 100644 --- a/addons/hr_contract/security/ir.model.access.csv +++ b/addons/hr_contract/security/ir.model.access.csv @@ -6,3 +6,4 @@ access_hr_contract_manager,hr.contract.manager,model_hr_contract,hr_contract.gro access_hr_contract_type_manager,hr.contract.type.manager,model_hr_contract_type,hr_contract.group_hr_contract_manager,1,1,1,1 access_hr_contract_history_manager,hr.contract.history.manager,model_hr_contract_history,hr_contract.group_hr_contract_manager,1,1,1,1 access_hr_payroll_structure_type_hr_contract_manager,hr.payroll.structure.type.contract.manager,model_hr_payroll_structure_type,hr_contract.group_hr_contract_manager,1,1,1,1 +access_hr_contract_hr_employee_manager,hr.contract.hr.employee.manager,model_hr_contract,hr_contract.group_hr_contract_employee_manager,1,0,0,0 diff --git a/addons/hr_contract/security/security.xml b/addons/hr_contract/security/security.xml index ee95ebc7107..96a6d1ee753 100644 --- a/addons/hr_contract/security/security.xml +++ b/addons/hr_contract/security/security.xml @@ -6,10 +6,16 @@ 10 + + Employee Manager + + + + Administrator - + @@ -23,6 +29,20 @@ ['|', ('employee_id.company_id', '=', False), ('employee_id.company_id', 'in', company_ids)] + + HR Contract: Employee Manager + + + ['|', ('employee_id.parent_id.user_id', '=', user.id), ('employee_id.user_id', '=', user.id)] + + + + HR Contract: Contract Manager + + + [(1, '=', 1)] + + HR Contract: Multi Company diff --git a/addons/hr_contract/views/hr_contract_views.xml b/addons/hr_contract/views/hr_contract_views.xml index 80cdf69cc86..ce1599de10b 100644 --- a/addons/hr_contract/views/hr_contract_views.xml +++ b/addons/hr_contract/views/hr_contract_views.xml @@ -135,7 +135,7 @@
- +
@@ -143,7 +143,7 @@

- +

@@ -157,11 +157,11 @@ - +