Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docsource/modules160-170.rst
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ Module coverage 16.0 -> 17.0
+---------------------------------------------------+----------------------+-------------------------------------------------+
| l10n_fr_fec | |No DB layout changes. |
+---------------------------------------------------+----------------------+-------------------------------------------------+
| |new| l10n_fr_hr_holidays | | |
| |new| l10n_fr_hr_holidays | Done | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
| |new| l10n_fr_hr_work_entry_holidays | | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright 2026 Le Filament
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openupgradelib import openupgrade


def _assign_default_leave_type(env):
"""
We try to compute most probable leave type for FR companies
in the following order :
1. default leave type from hr_holidays still active
2. leave type with most common default configuration
3. leave type accessible to that company, configured in days
or half days and of type = "leave"
for case 2 or 3, ordering by sequence and taking the first found
"""
fr_company_ids = (
env["res.company"].search([]).filtered(lambda c: c.country_id.code == "FR")
)
default_leave_type = env.ref("hr_holidays.holiday_status_cl", False)
for company in fr_company_ids:
if (
default_leave_type
and default_leave_type.active
and default_leave_type.company_id.id in [False, company.id]
):
leave_type = default_leave_type
else:
leave_type = env["hr.leave.type"].search(
[
("company_id", "in", [False, company.id]),
("requires_allocation", "=", "yes"),
("employee_requests", "=", "no"),
("request_unit", "in", ["day", "half_day"]),
("leave_validation_type", "!=", "no_validation"),
("time_type", "=", "leave"),
],
order="sequence asc",
limit=1,
)
if not leave_type:
leave_type = env["hr.leave.type"].search(
[
("company_id", "in", [False, company.id]),
("request_unit", "in", ["day", "half_day"]),
("time_type", "=", "leave"),
],
order="sequence asc",
limit=1,
)
company.l10n_fr_reference_leave_type = leave_type


@openupgrade.migrate(no_version=True)
def migrate(env, version):
_assign_default_leave_type(env)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---Models in module 'l10n_fr_hr_holidays'---
---Fields in module 'l10n_fr_hr_holidays'---
l10n_fr_hr_holidays / hr.leave / l10n_fr_date_to_changed (boolean): NEW
# NOTHING TO DO: new functionality will be used on new leaves

l10n_fr_hr_holidays / res.company / l10n_fr_reference_leave_type (many2one): NEW relation: hr.leave.type
# DONE: post-migration: initialize this field with most probable holiday type
---XML records in module 'l10n_fr_hr_holidays'---
NEW ir.ui.menu: l10n_fr_hr_holidays.hr_holidays_menu_configuration
NEW ir.ui.view: l10n_fr_hr_holidays.res_config_settings_view_form
# NOTHING TO DO: handled by ORM