diff --git a/hr_holidays_leave_type_visibility/README.rst b/hr_holidays_leave_type_visibility/README.rst new file mode 100644 index 00000000..7ed7af77 --- /dev/null +++ b/hr_holidays_leave_type_visibility/README.rst @@ -0,0 +1,100 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +============================================ +HR Holidays Overview - Leave Type Visibility +============================================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:b44124275ed2bf5071bc6df43a99b4dc2f6d9d9611e7d44cbf369dd782485f07 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fhr--holidays-lightgray.png?logo=github + :target: https://github.com/OCA/hr-holidays/tree/19.0/hr_holidays_leave_type_visibility + :alt: OCA/hr-holidays +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/hr-holidays-19-0/hr-holidays-19-0-hr_holidays_leave_type_visibility + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/hr-holidays&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +In standard Odoo, the *Time Off Type* of an absence shown in the Time +Off Overview calendar (``hr.leave.report.calendar``) is restricted to +the *Time Off / Officer: Manage all requests* group. Regular employees +can see **that** a colleague is absent, but not **why**. + +This addon makes the time off type readable by every internal user, both +in the calendar event label and in the event detail popup, without +granting any approval or write rights on time off requests. + +The private time off description remains restricted to Time Off Officers +and to the employee's approver. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Go to *Time Off > Overview* as a regular employee. Each absence is now +labelled with the employee name followed by the time off type, and the +event detail popup shows the *Time Off Type* field. + +To also get a filter/group by time off type in that calendar, install +``hr_holidays_leave_report_calendar_type`` alongside this addon. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* ForgeFlow + +Contributors +------------ + +- Jasmin Solanki + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/hr-holidays `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/hr_holidays_leave_type_visibility/__init__.py b/hr_holidays_leave_type_visibility/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/hr_holidays_leave_type_visibility/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/hr_holidays_leave_type_visibility/__manifest__.py b/hr_holidays_leave_type_visibility/__manifest__.py new file mode 100644 index 00000000..eaeab38d --- /dev/null +++ b/hr_holidays_leave_type_visibility/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2026 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "HR Holidays Overview - Leave Type Visibility", + "summary": "Show the time off type in the Time Off Overview to every internal user", + "version": "19.0.1.0.0", + "development_status": "Beta", + "category": "Human Resources/Time Off", + "website": "https://github.com/OCA/hr-holidays", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": ["hr_holidays"], +} diff --git a/hr_holidays_leave_type_visibility/models/__init__.py b/hr_holidays_leave_type_visibility/models/__init__.py new file mode 100644 index 00000000..7695e614 --- /dev/null +++ b/hr_holidays_leave_type_visibility/models/__init__.py @@ -0,0 +1 @@ +from . import hr_leave_report_calendar diff --git a/hr_holidays_leave_type_visibility/models/hr_leave_report_calendar.py b/hr_holidays_leave_type_visibility/models/hr_leave_report_calendar.py new file mode 100644 index 00000000..68030b08 --- /dev/null +++ b/hr_holidays_leave_type_visibility/models/hr_leave_report_calendar.py @@ -0,0 +1,21 @@ +# Copyright 2026 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class HrLeaveReportCalendar(models.Model): + _inherit = "hr.leave.report.calendar" + + # Standard restricts this field to Time Off Officers, which prevents regular + # users from knowing why a colleague is absent. The private description + # remains restricted. + holiday_status_id = fields.Many2one(groups="base.group_user") + + @api.depends("employee_id.name", "holiday_status_id", "leave_id") + def _compute_name(self): + for leave in self: + name = leave.employee_id.name or "" + if leave.holiday_status_id: + name += f" {leave.holiday_status_id.name}" + leave.name = f"{name}: {leave.sudo().leave_id.duration_display}" diff --git a/hr_holidays_leave_type_visibility/pyproject.toml b/hr_holidays_leave_type_visibility/pyproject.toml new file mode 100644 index 00000000..4231d0cc --- /dev/null +++ b/hr_holidays_leave_type_visibility/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/hr_holidays_leave_type_visibility/readme/CONTRIBUTORS.md b/hr_holidays_leave_type_visibility/readme/CONTRIBUTORS.md new file mode 100644 index 00000000..88b3ed52 --- /dev/null +++ b/hr_holidays_leave_type_visibility/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Jasmin Solanki \<\> diff --git a/hr_holidays_leave_type_visibility/readme/DESCRIPTION.md b/hr_holidays_leave_type_visibility/readme/DESCRIPTION.md new file mode 100644 index 00000000..842b1006 --- /dev/null +++ b/hr_holidays_leave_type_visibility/readme/DESCRIPTION.md @@ -0,0 +1,11 @@ +In standard Odoo, the *Time Off Type* of an absence shown in the Time Off +Overview calendar (`hr.leave.report.calendar`) is restricted to the +*Time Off / Officer: Manage all requests* group. Regular employees can see +**that** a colleague is absent, but not **why**. + +This addon makes the time off type readable by every internal user, both in +the calendar event label and in the event detail popup, without granting any +approval or write rights on time off requests. + +The private time off description remains restricted to Time Off Officers and +to the employee's approver. diff --git a/hr_holidays_leave_type_visibility/readme/USAGE.md b/hr_holidays_leave_type_visibility/readme/USAGE.md new file mode 100644 index 00000000..8714fe1e --- /dev/null +++ b/hr_holidays_leave_type_visibility/readme/USAGE.md @@ -0,0 +1,3 @@ +Go to *Time Off > Overview* as a regular employee. Each absence is now +labelled with the employee name followed by the time off type, and the event +detail popup shows the *Time Off Type* field. diff --git a/hr_holidays_leave_type_visibility/static/description/icon.png b/hr_holidays_leave_type_visibility/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/hr_holidays_leave_type_visibility/static/description/icon.png differ diff --git a/hr_holidays_leave_type_visibility/static/description/index.html b/hr_holidays_leave_type_visibility/static/description/index.html new file mode 100644 index 00000000..719f41a5 --- /dev/null +++ b/hr_holidays_leave_type_visibility/static/description/index.html @@ -0,0 +1,446 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

HR Holidays Overview - Leave Type Visibility

+ +

Beta License: AGPL-3 OCA/hr-holidays Translate me on Weblate Try me on Runboat

+

In standard Odoo, the Time Off Type of an absence shown in the Time +Off Overview calendar (hr.leave.report.calendar) is restricted to +the Time Off / Officer: Manage all requests group. Regular employees +can see that a colleague is absent, but not why.

+

This addon makes the time off type readable by every internal user, both +in the calendar event label and in the event detail popup, without +granting any approval or write rights on time off requests.

+

The private time off description remains restricted to Time Off Officers +and to the employee’s approver.

+

Table of contents

+ +
+

Usage

+

Go to Time Off > Overview as a regular employee. Each absence is now +labelled with the employee name followed by the time off type, and the +event detail popup shows the Time Off Type field.

+

To also get a filter/group by time off type in that calendar, install +hr_holidays_leave_report_calendar_type alongside this addon.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/hr-holidays project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+
+ + diff --git a/hr_holidays_leave_type_visibility/tests/__init__.py b/hr_holidays_leave_type_visibility/tests/__init__.py new file mode 100644 index 00000000..0db86b46 --- /dev/null +++ b/hr_holidays_leave_type_visibility/tests/__init__.py @@ -0,0 +1 @@ +from . import test_leave_type_visibility diff --git a/hr_holidays_leave_type_visibility/tests/test_leave_type_visibility.py b/hr_holidays_leave_type_visibility/tests/test_leave_type_visibility.py new file mode 100644 index 00000000..2af74174 --- /dev/null +++ b/hr_holidays_leave_type_visibility/tests/test_leave_type_visibility.py @@ -0,0 +1,79 @@ +# Copyright 2026 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from datetime import date + +from odoo.tests.common import TransactionCase, new_test_user + + +class TestLeaveTypeVisibility(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.company = cls.env.company + cls.leave_type = cls.env["hr.leave.type"].create( + { + "name": "Test Sick Leave", + "company_id": cls.company.id, + "requires_allocation": False, + "leave_validation_type": "no_validation", + "request_unit": "day", + } + ) + cls.absent_user = new_test_user( + cls.env, login="absent_user", groups="base.group_user" + ) + cls.absent_employee = cls.env["hr.employee"].create( + { + "name": "Absent Employee", + "user_id": cls.absent_user.id, + "company_id": cls.company.id, + } + ) + cls.regular_user = new_test_user( + cls.env, login="regular_user", groups="base.group_user" + ) + cls.env["hr.employee"].create( + { + "name": "Regular Employee", + "user_id": cls.regular_user.id, + "company_id": cls.company.id, + } + ) + cls.officer_user = new_test_user( + cls.env, + login="officer_user", + groups="base.group_user,hr_holidays.group_hr_holidays_user", + ) + cls.leave = ( + cls.env["hr.leave"] + .with_context(mail_create_nolog=True, mail_notrack=True) + .create( + { + "name": "Private reason", + "employee_id": cls.absent_employee.id, + "holiday_status_id": cls.leave_type.id, + "request_date_from": date(2026, 3, 2), + "request_date_to": date(2026, 3, 2), + } + ) + ) + cls.env.flush_all() + + def _report_leave(self, user): + return ( + self.env["hr.leave.report.calendar"] + .with_user(user) + .search([("employee_id", "=", self.absent_employee.id)]) + ) + + def test_regular_user_reads_leave_type(self): + report_leave = self._report_leave(self.regular_user) + self.assertEqual(len(report_leave), 1) + self.assertEqual(report_leave.holiday_status_id, self.leave_type) + self.assertIn(self.leave_type.name, report_leave.name) + + def test_private_description_still_restricted(self): + report_leave = self._report_leave(self.regular_user) + self.assertNotIn("description", report_leave.fields_get()) + self.assertIn("description", self._report_leave(self.officer_user).fields_get())