From 4f49eb5ecd4c6402a4031cd73d0ed7e028e7ecd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Taymans?= Date: Tue, 13 Jun 2023 21:20:16 +0200 Subject: [PATCH 1/2] [OU-ADD] hr_holidays Compute new values for allocation_validation_type on hr.leave.type as it is now a stored computed field with only two choices: "no" and "officer". Load noupdate_changes. --- .../hr_holidays/16.0.1.5/post-migration.py | 28 ++++++++++++ .../16.0.1.5/upgrade_analysis_work.txt | 44 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 openupgrade_scripts/scripts/hr_holidays/16.0.1.5/post-migration.py create mode 100644 openupgrade_scripts/scripts/hr_holidays/16.0.1.5/upgrade_analysis_work.txt diff --git a/openupgrade_scripts/scripts/hr_holidays/16.0.1.5/post-migration.py b/openupgrade_scripts/scripts/hr_holidays/16.0.1.5/post-migration.py new file mode 100644 index 000000000000..18e6b76f40b8 --- /dev/null +++ b/openupgrade_scripts/scripts/hr_holidays/16.0.1.5/post-migration.py @@ -0,0 +1,28 @@ +# Copyright 2023 Coop IT Easy (https://coopiteasy.be) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openupgradelib import openupgrade + + +def set_allocation_validation_type(env): + """Operate like the _compute_allocation_validation_type() function. + + It set "no" by default except if employee_request is set to "no" + where it set "officer". + """ + openupgrade.logged_query( + env.cr, "UPDATE hr_leave_type SET allocation_validation_type = 'no'" + ) + openupgrade.logged_query( + env.cr, + """UPDATE hr_leave_type + SET allocation_validation_type = 'officer' + WHERE employee_requests = 'no' + """, + ) + + +@openupgrade.migrate() +def migrate(env, version): + set_allocation_validation_type(env) + openupgrade.load_data(env.cr, "hr_holidays", "16.0.1.5/noupdate_changes.xml") diff --git a/openupgrade_scripts/scripts/hr_holidays/16.0.1.5/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/hr_holidays/16.0.1.5/upgrade_analysis_work.txt new file mode 100644 index 000000000000..1c0b66f10163 --- /dev/null +++ b/openupgrade_scripts/scripts/hr_holidays/16.0.1.5/upgrade_analysis_work.txt @@ -0,0 +1,44 @@ +---Models in module 'hr_holidays'--- +new model hr.holidays.cancel.leave [transient] +# NOTHING TO DO: transient model + +new model hr.leave.stress.day +# NOTHING TO DO: new feature + +---Fields in module 'hr_holidays'--- +hr_holidays / hr.leave / active (boolean) : NEW +# NOTHING TO DO: default value is True. + +hr_holidays / hr.leave / request_unit_custom (boolean) : DEL +# NOTHING TO DO: not needed anymore. See : https://github.com/odoo/odoo/commit/81c8a0564d54c981e65a6ed3b2c70dd792d59a46 + +hr_holidays / hr.leave.accrual.level / postpone_max_days (integer) : NEW +hr_holidays / hr.leave.stress.day / color (integer) : NEW hasdefault: default +hr_holidays / hr.leave.stress.day / company_id (many2one) : NEW relation: res.company, required, hasdefault: default +hr_holidays / hr.leave.stress.day / department_ids (many2many) : NEW relation: hr.department +hr_holidays / hr.leave.stress.day / end_date (date) : NEW required +hr_holidays / hr.leave.stress.day / name (char) : NEW required +hr_holidays / hr.leave.stress.day / resource_calendar_id (many2one): NEW relation: resource.calendar +hr_holidays / hr.leave.stress.day / start_date (date) : NEW required +# NOTHING TO DO: new feature + +hr_holidays / hr.leave.type / allocation_validation_type (selection): selection_keys is now '['no', 'officer']' ('['no', 'officer', 'set']') +# DONE: post-migration: compute new value for allocation_validation_type + +---XML records in module 'hr_holidays'--- +NEW ir.actions.act_window: hr_holidays.hr_leave_stress_day_action +DEL ir.actions.act_window.view: hr_holidays.hr_leave_action_my_view_form +DEL ir.actions.act_window.view: hr_holidays.hr_leave_action_my_view_tree +NEW ir.model.access: hr_holidays.access_hr_holidays_cancel_leave +NEW ir.model.access: hr_holidays.access_hr_leave_stress_day_manager +NEW ir.model.access: hr_holidays.access_hr_leave_stress_day_user +NEW ir.model.constraint: hr_holidays.constraint_hr_leave_stress_day_date_from_after_day_to +NEW ir.rule: hr_holidays.hr_leave_stress_day_rule_multi_company (noupdate) +NEW ir.ui.menu: hr_holidays.hr_holidays_stress_day_menu_configuration +NEW ir.ui.view: hr_holidays.hr_holidays_cancel_leave_form +NEW ir.ui.view: hr_holidays.hr_leave_report_view_form +NEW ir.ui.view: hr_holidays.hr_leave_stress_day_view_form +NEW ir.ui.view: hr_holidays.hr_leave_stress_day_view_list +NEW ir.ui.view: hr_holidays.hr_leave_stress_day_view_search +NEW ir.ui.view: hr_holidays.hr_leave_view_kanban_approve_department +# NOTHING TO DO: managed by the ORM From c7b0bab543e68f5d81986cc0a701e7911506e738 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Fri, 8 Mar 2024 13:41:03 +0100 Subject: [PATCH 2/2] [OU-FIX] hr_holidays: Convert correctly allocation_validation_type TT42390 --- docsource/modules150-160.rst | 2 +- .../hr_holidays/16.0.1.5/post-migration.py | 17 +++++++---------- .../16.0.1.5/upgrade_analysis_work.txt | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/docsource/modules150-160.rst b/docsource/modules150-160.rst index be3e74354428..65b02bfaa0bd 100644 --- a/docsource/modules150-160.rst +++ b/docsource/modules150-160.rst @@ -176,7 +176,7 @@ Module coverage 15.0 -> 16.0 +-------------------------------------------------+----------------------+-------------------------------------------------+ | hr_gamification | Nothing to do |No DB layout changes. | +-------------------------------------------------+----------------------+-------------------------------------------------+ -| hr_holidays | | | +| hr_holidays | Done | | +-------------------------------------------------+----------------------+-------------------------------------------------+ | hr_holidays_attendance | | | +-------------------------------------------------+----------------------+-------------------------------------------------+ diff --git a/openupgrade_scripts/scripts/hr_holidays/16.0.1.5/post-migration.py b/openupgrade_scripts/scripts/hr_holidays/16.0.1.5/post-migration.py index 18e6b76f40b8..70aef7b5c96b 100644 --- a/openupgrade_scripts/scripts/hr_holidays/16.0.1.5/post-migration.py +++ b/openupgrade_scripts/scripts/hr_holidays/16.0.1.5/post-migration.py @@ -1,28 +1,25 @@ # Copyright 2023 Coop IT Easy (https://coopiteasy.be) +# Copyright 2024 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from openupgradelib import openupgrade -def set_allocation_validation_type(env): - """Operate like the _compute_allocation_validation_type() function. - - It set "no" by default except if employee_request is set to "no" - where it set "officer". +def _set_allocation_validation_type(env): + """Convert the previous `set` value to `officer` as it's mostly the same. The only + difference is that previously if set is selected, the responsible could be empty, + and thus the own user was selected as approver - which was incorrect -. """ - openupgrade.logged_query( - env.cr, "UPDATE hr_leave_type SET allocation_validation_type = 'no'" - ) openupgrade.logged_query( env.cr, """UPDATE hr_leave_type SET allocation_validation_type = 'officer' - WHERE employee_requests = 'no' + WHERE allocation_validation_type = 'set' """, ) @openupgrade.migrate() def migrate(env, version): - set_allocation_validation_type(env) + _set_allocation_validation_type(env) openupgrade.load_data(env.cr, "hr_holidays", "16.0.1.5/noupdate_changes.xml") diff --git a/openupgrade_scripts/scripts/hr_holidays/16.0.1.5/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/hr_holidays/16.0.1.5/upgrade_analysis_work.txt index 1c0b66f10163..2bf32ed40eba 100644 --- a/openupgrade_scripts/scripts/hr_holidays/16.0.1.5/upgrade_analysis_work.txt +++ b/openupgrade_scripts/scripts/hr_holidays/16.0.1.5/upgrade_analysis_work.txt @@ -23,7 +23,7 @@ hr_holidays / hr.leave.stress.day / start_date (date) : NEW re # NOTHING TO DO: new feature hr_holidays / hr.leave.type / allocation_validation_type (selection): selection_keys is now '['no', 'officer']' ('['no', 'officer', 'set']') -# DONE: post-migration: compute new value for allocation_validation_type +# DONE: post-migration: convert previous `set` values to `officer`. They acted the same except the responsible_id is not set. In that case, the user was selected as approver, which was incorrect. ---XML records in module 'hr_holidays'--- NEW ir.actions.act_window: hr_holidays.hr_leave_stress_day_action