Skip to content

[19.0][ADD] hr_holidays_leave_type_visibility - #269

Open
JasminSForgeFlow wants to merge 1 commit into
OCA:19.0from
ForgeFlow:19.0-add-hr_holidays_leave_type_visibility
Open

[19.0][ADD] hr_holidays_leave_type_visibility#269
JasminSForgeFlow wants to merge 1 commit into
OCA:19.0from
ForgeFlow:19.0-add-hr_holidays_leave_type_visibility

Conversation

@JasminSForgeFlow

Copy link
Copy Markdown
Contributor

Purpose

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 therefore
see that a colleague is absent, but not why.

Several customers need employees to know the kind of absence (sick leave,
holiday, training, ...) in order to plan their own work, without granting anyone
approval or write rights on time off requests.

@ForgeFlow

@OCA-git-bot OCA-git-bot added series:19.0 mod:hr_holidays_leave_type_visibility Module hr_holidays_leave_type_visibility labels Aug 7, 2026

@AaronHForgeFlow AaronHForgeFlow left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In runboat I got this error when trying to create a leave for the demo user:

Image

Is that due to this module or another? can you check?

@JasminSForgeFlow

Copy link
Copy Markdown
Contributor Author

Tests fixed here #270

@JasminSForgeFlow
JasminSForgeFlow force-pushed the 19.0-add-hr_holidays_leave_type_visibility branch from b2a94f9 to e0aa26a Compare August 10, 2026 05:25
@JasminSForgeFlow

Copy link
Copy Markdown
Contributor Author

In runboat I got this error when trying to create a leave for the demo user:

Image Is that due to this module or another? can you check?

This error is not caused by this module — it reproduces on the same runboat with hr_holidays_leave_type_visibility uninstalled.

Root cause (upstream hr_holidays): in Odoo 19 hr.employee delegates to hr.version via _inherits, and the link field version_id is declared with groups="hr.group_hr_user" (addons/hr/models/hr_employee.py). So any read of a delegated field on hr.employee by a plain internal user raises the "Implicitly accessed through 'Employee'" AccessError.

In the leave-creation flow that happens in two places, both reading employee_id.department_id (defined on hr.version, addons/hr/models/hr_version.py) without sudo():

  • HrLeave._compute_department_idaddons/hr_holidays/models/hr_leave.py:537
  • HrLeave._compute_has_mandatory_dayaddons/hr_holidays/models/hr_leave.py:549

Note that the neighbouring lines in the same file do sudo for exactly this reason, with explanatory comments:

  • hr_leave.py:543# Sudo to get access to version fields on employee (job_id)
  • hr_leave.py:623# sudo as is_flexible is on version model and employee does not have access to it.

So it looks like an inconsistency in core rather than intended behaviour.

Verified on runboat:

  • demo user without hr.group_hr_user → AccessError on version_id, with or without this module installed
  • demo user granted hr.group_hr_user → leave creates fine

This module only touches hr.leave.report.calendar (widening holiday_status_id to base.group_user and overriding _compute_name); it never reads employee version fields. The fix belongs in odoo/odoo, not here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:hr_holidays_leave_type_visibility Module hr_holidays_leave_type_visibility series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants