From 964c36971b531f944bcb2de96adbd2ba9a5d83db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20-=20Le=20Filament?= <30716308+remi-filament@users.noreply.github.com> Date: Wed, 25 Feb 2026 09:22:35 +0100 Subject: [PATCH] [OU-ADD] l10n_fr_hr_holidays: Migration scripts --- docsource/modules160-170.rst | 2 +- .../17.0.1.0/post-migration.py | 55 +++++++++++++++++++ .../17.0.1.0/upgrade_analysis_work.txt | 11 ++++ 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 openupgrade_scripts/scripts/l10n_fr_hr_holidays/17.0.1.0/post-migration.py create mode 100644 openupgrade_scripts/scripts/l10n_fr_hr_holidays/17.0.1.0/upgrade_analysis_work.txt diff --git a/docsource/modules160-170.rst b/docsource/modules160-170.rst index 8845cd7867bd..018891259700 100644 --- a/docsource/modules160-170.rst +++ b/docsource/modules160-170.rst @@ -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 | | | +---------------------------------------------------+----------------------+-------------------------------------------------+ diff --git a/openupgrade_scripts/scripts/l10n_fr_hr_holidays/17.0.1.0/post-migration.py b/openupgrade_scripts/scripts/l10n_fr_hr_holidays/17.0.1.0/post-migration.py new file mode 100644 index 000000000000..70ef98e87edf --- /dev/null +++ b/openupgrade_scripts/scripts/l10n_fr_hr_holidays/17.0.1.0/post-migration.py @@ -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) diff --git a/openupgrade_scripts/scripts/l10n_fr_hr_holidays/17.0.1.0/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/l10n_fr_hr_holidays/17.0.1.0/upgrade_analysis_work.txt new file mode 100644 index 000000000000..a231c5dfdcf9 --- /dev/null +++ b/openupgrade_scripts/scripts/l10n_fr_hr_holidays/17.0.1.0/upgrade_analysis_work.txt @@ -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