Skip to content

Commit

Permalink
[OU-FIX] hr_holidays: Convert correctly allocation_validation_type
Browse files Browse the repository at this point in the history
TT42390
  • Loading branch information
pedrobaeza committed Mar 8, 2024
1 parent 4f49eb5 commit c7b0bab
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docsource/modules150-160.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 | | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down
17 changes: 7 additions & 10 deletions openupgrade_scripts/scripts/hr_holidays/16.0.1.5/post-migration.py
Original file line number Diff line number Diff line change
@@ -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")
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c7b0bab

Please sign in to comment.