-
-
Notifications
You must be signed in to change notification settings - Fork 708
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OU-FIX] hr_holidays: Convert correctly allocation_validation_type
TT42390
- Loading branch information
1 parent
4f49eb5
commit c7b0bab
Showing
3 changed files
with
9 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 7 additions & 10 deletions
17
openupgrade_scripts/scripts/hr_holidays/16.0.1.5/post-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters