Skip to content

Commit a9f6ef6

Browse files
committed
[ADD] hr_timesheet_manager_approver: Allow approvers to manage subordinate timesheets
Extend the `timesheet_line_rule_approver` record rule so that users with group_hr_timesheet_approver can read, write, create and delete timesheets of employees whose parent_id.user_id matches them. Add unit tests to verify CRUD access on subordinate timesheets while restricting access to non-subordinates. @moduon MT-14395
1 parent d8dbbe3 commit a9f6ef6

11 files changed

Lines changed: 778 additions & 0 deletions

File tree

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
==========================
2+
Timesheet Manager Approver
3+
==========================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:a835f0b5c73ced76ef46f252021aa25d284d12f1de59606a45930c03c15f95d3
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Ftimesheet-lightgray.png?logo=github
20+
:target: https://github.com/OCA/timesheet/tree/18.0/hr_timesheet_manager_approver
21+
:alt: OCA/timesheet
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/timesheet-18-0/timesheet-18-0-hr_timesheet_manager_approver
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/timesheet&target_branch=18.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module extends the standard timesheet approver rules so that a user
32+
with the group *User: all timesheets* can also manage the timesheets of
33+
their subordinate employees (i.e. employees whose *Manager* field points
34+
to the approver).
35+
36+
It updates the ``timesheet_line_rule_approver`` record rule to include
37+
the clause
38+
``('employee_id.parent_id.user_id', 'in', (False, user.id))``.
39+
40+
**Table of contents**
41+
42+
.. contents::
43+
:local:
44+
45+
Usage
46+
=====
47+
48+
To use this module:
49+
50+
1. Go to **Employees** and open the employee you want to set as a
51+
manager.
52+
2. In the *Work Information* tab, under *Employee*, set the **Timesheet
53+
Responsible** or ensure the **Manager** field points to the approver
54+
user.
55+
3. Assign the *Timesheets / User: all timesheets* group to the manager
56+
user (*Settings → Users & Companies → Users* → *Timesheets* section).
57+
4. Log in as the manager user.
58+
5. Go to **Timesheets**.
59+
6. You will now see, edit and delete timesheets for employees who report
60+
to you, even on projects with *Invited employees* privacy. Also you
61+
can create but only in the projects where the user has access.
62+
63+
**Important:** Without this module, a timesheet approver can only manage
64+
timesheets on projects where they are a follower. With this module, the
65+
approver also gains access to their subordinates' timesheets regardless
66+
of project visibility.
67+
68+
Bug Tracker
69+
===========
70+
71+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/timesheet/issues>`_.
72+
In case of trouble, please check there if your issue has already been reported.
73+
If you spotted it first, help us to smash it by providing a detailed and welcomed
74+
`feedback <https://github.com/OCA/timesheet/issues/new?body=module:%20hr_timesheet_manager_approver%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
75+
76+
Do not contact contributors directly about support or help with technical issues.
77+
78+
Credits
79+
=======
80+
81+
Authors
82+
-------
83+
84+
* Moduon
85+
86+
Contributors
87+
------------
88+
89+
- Emilio Pascual (`Moduon <https://www.moduon.team/>`__)
90+
91+
Maintainers
92+
-----------
93+
94+
This module is maintained by the OCA.
95+
96+
.. image:: https://odoo-community.org/logo.png
97+
:alt: Odoo Community Association
98+
:target: https://odoo-community.org
99+
100+
OCA, or the Odoo Community Association, is a nonprofit organization whose
101+
mission is to support the collaborative development of Odoo features and
102+
promote its widespread use.
103+
104+
.. |maintainer-EmilioPascual| image:: https://github.com/EmilioPascual.png?size=40px
105+
:target: https://github.com/EmilioPascual
106+
:alt: EmilioPascual
107+
.. |maintainer-rafaelbn| image:: https://github.com/rafaelbn.png?size=40px
108+
:target: https://github.com/rafaelbn
109+
:alt: rafaelbn
110+
111+
Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
112+
113+
|maintainer-EmilioPascual| |maintainer-rafaelbn|
114+
115+
This module is part of the `OCA/timesheet <https://github.com/OCA/timesheet/tree/18.0/hr_timesheet_manager_approver>`_ project on GitHub.
116+
117+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Copyright 2025 Moduon Team SL
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright 2025 Moduon Team SL
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
{
5+
"name": "Timesheet Manager Approver",
6+
"version": "18.0.1.0.0",
7+
"category": "Human Resources",
8+
"summary": "Allow timesheet approvers to manage subordinate timesheets",
9+
"license": "AGPL-3",
10+
"author": "Moduon, Odoo Community Association (OCA)",
11+
"website": "https://github.com/OCA/timesheet",
12+
"depends": ["hr_timesheet"],
13+
"maintainers": ["EmilioPascual", "rafaelbn"],
14+
"data": [
15+
"security/hr_timesheet_manager_approver_security.xml",
16+
],
17+
"installable": True,
18+
"auto_install": False,
19+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Emilio Pascual ([Moduon](https://www.moduon.team/))
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
This module extends the standard timesheet approver rules so that a user with the
2+
group *User: all timesheets* can also manage the timesheets of their subordinate
3+
employees (i.e. employees whose *Manager* field points to the approver).
4+
5+
It updates the ``timesheet_line_rule_approver`` record rule to include the clause
6+
``('employee_id.parent_id.user_id', 'in', (False, user.id))``.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
To use this module:
2+
3+
1. Go to **Employees** and open the employee you want to set as a manager.
4+
2. In the *Work Information* tab, under *Employee*, set the **Timesheet Responsible** or ensure the **Manager** field points to the approver user.
5+
3. Assign the *Timesheets / User: all timesheets* group to the manager user (*Settings → Users & Companies → Users**Timesheets* section).
6+
4. Log in as the manager user.
7+
5. Go to **Timesheets**.
8+
6. You will now see, edit and delete timesheets for employees who report to you, even on projects with *Invited employees* privacy. Also you can create but only in the projects where the user has access.
9+
10+
**Important:** Without this module, a timesheet approver can only manage timesheets on projects where they are a follower. With this module, the approver also gains access to their subordinates' timesheets regardless of project visibility.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!--
3+
Copyright 2025 Moduon Team SL
4+
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
5+
-->
6+
<odoo noupdate="1">
7+
<record id="hr_timesheet.timesheet_line_rule_approver" model="ir.rule">
8+
<field name="domain_force">[
9+
('project_id', '!=', False),
10+
'|', '|', '|',
11+
('project_id.privacy_visibility', '!=', 'followers'),
12+
('project_id.message_partner_ids', 'in', [user.partner_id.id]),
13+
('task_id.message_partner_ids', 'in', [user.partner_id.id]),
14+
('employee_id.parent_id.user_id', '=', user.id)
15+
]</field>
16+
</record>
17+
</odoo>

0 commit comments

Comments
 (0)