Skip to content

Commit 11a91ed

Browse files
committed
[OU-IMP]hr: Add computation of some fields
1 parent 7b0ce92 commit 11a91ed

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright 2024- Le Filament (https://le-filament.com)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from openupgradelib import openupgrade
5+
6+
7+
@openupgrade.migrate()
8+
def migrate(env, version):
9+
leaves = env["hr.leave"].search([])
10+
leaves._compute_leave_type_increases_duration()
11+
leaves._compute_duration()

openupgrade_scripts/scripts/hr_holidays/17.0.1.6/pre-migration.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,36 @@
2020
],
2121
}
2222

23+
_field_add = [
24+
(
25+
"leave_type_increases_duration",
26+
"hr.leave",
27+
"hr_leave",
28+
"bool",
29+
None,
30+
"hr_holidays",
31+
False,
32+
),
33+
(
34+
"number_of_days",
35+
"hr.leave",
36+
"hr_leave",
37+
"float",
38+
None,
39+
"hr_holidays",
40+
0.0,
41+
),
42+
(
43+
"number_of_hours",
44+
"hr.leave",
45+
"hr_leave",
46+
"float",
47+
None,
48+
"hr_holidays",
49+
0.0,
50+
),
51+
]
52+
2353

2454
def _pre_create_accrual_plan_active(cr):
2555
"""
@@ -156,6 +186,7 @@ def migrate(env, version):
156186
openupgrade.rename_models(env.cr, _model_renames)
157187
openupgrade.rename_tables(env.cr, _table_renames)
158188
openupgrade.rename_columns(env.cr, _column_renames)
189+
openupgrade.add_fields(env, _field_add)
159190
_pre_create_accrual_plan_active(env.cr)
160191
_hr_leave_company_id(env.cr)
161192
_map_leave_accrual_level_action(env.cr)

openupgrade_scripts/scripts/hr_holidays/17.0.1.6/upgrade_analysis_work.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ hr_holidays / hr.leave / message_has_sms_error (boolean): previ
2828
hr_holidays / hr.leave / mode_company_id (many2one) : not a function anymore
2929
# NOTHING TO DO: states removed only
3030

31+
hr_holidays / hr.leave / leave_type_increases_duration (boolean) : NEW isfunction: function, stored
3132
hr_holidays / hr.leave / number_of_days (float) : now a function
3233
hr_holidays / hr.leave / number_of_hours (float) : NEW isfunction: function, stored
33-
# NOTHING TO DO: computed fields
34+
# Pre-migration script and end-migration script to recompute
3435

3536
hr_holidays / hr.leave / rating_ids (one2many) : NEW relation: rating.rating
3637
hr_holidays / hr.leave / resource_calendar_id (many2one): NEW relation: resource.calendar, hasdefault: compute

0 commit comments

Comments
 (0)