Skip to content

Commit

Permalink
calendar_public_holiday: add migration script data
Browse files Browse the repository at this point in the history
  • Loading branch information
xaviedoanhduy committed Jan 13, 2025
1 parent a76e44a commit bd79fb1
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
1 change: 1 addition & 0 deletions calendar_public_holiday/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

from . import models
from . import wizards
from .hooks import pre_init_hook
2 changes: 2 additions & 0 deletions calendar_public_holiday/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@
"views/calendar_public_holiday_view.xml",
"wizards/calendar_public_holiday_next_year_wizard.xml",
],
"external_dependencies": {"python": ["openupgradelib"]},
"pre_init_hook": "pre_init_hook",
}
55 changes: 55 additions & 0 deletions calendar_public_holiday/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright 2024 Camptocamp
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openupgradelib import openupgrade


def migrate_rename_xmlid_event_type_holiday(env):
if not openupgrade.is_module_installed(env.cr, "hr_holidays_public"):
return
xmlid_renames = [

Check warning on line 10 in calendar_public_holiday/hooks.py

View check run for this annotation

Codecov / codecov/patch

calendar_public_holiday/hooks.py#L10

Added line #L10 was not covered by tests
(
"hr_holidays_public.event_type_holiday",
"calendar_public_holiday.event_type_holiday",
),
]
openupgrade.rename_xmlids(env.cr, xmlid_renames)

Check warning on line 16 in calendar_public_holiday/hooks.py

View check run for this annotation

Codecov / codecov/patch

calendar_public_holiday/hooks.py#L16

Added line #L16 was not covered by tests


def migrate_rename_field_model_hr_holidays_public_line(env):
field_renames = [
(
"hr.holidays.public.line",
"hr_holidays_public_line",
"year_id",
"public_holiday_id",
),
]
openupgrade.rename_fields(env, field_renames, no_deep=True)


def migrate_rename_model_hr_holidays_public_line(env):
if not openupgrade.table_exists(env.cr, "hr_holidays_public_line"):
return
model_renames = [("hr.holidays.public.line", "calendar.public.holiday.line")]
openupgrade.rename_models(env.cr, model_renames)
tables_renames = [("hr_holidays_public_line", "calendar_public_holiday_line")]
openupgrade.rename_tables(env.cr, tables_renames)

Check warning on line 37 in calendar_public_holiday/hooks.py

View check run for this annotation

Codecov / codecov/patch

calendar_public_holiday/hooks.py#L34-L37

Added lines #L34 - L37 were not covered by tests


def migrate_rename_model_hr_holidays_public(env):
if not openupgrade.table_exists(env.cr, "hr_holidays_public"):
return
model_renames = [

Check warning on line 43 in calendar_public_holiday/hooks.py

View check run for this annotation

Codecov / codecov/patch

calendar_public_holiday/hooks.py#L43

Added line #L43 was not covered by tests
("hr.holidays.public", "calendar.public.holiday"),
]
openupgrade.rename_models(env.cr, model_renames)
tables_renames = [("hr_holidays_public", "calendar_public_holiday")]
openupgrade.rename_tables(env.cr, tables_renames)

Check warning on line 48 in calendar_public_holiday/hooks.py

View check run for this annotation

Codecov / codecov/patch

calendar_public_holiday/hooks.py#L46-L48

Added lines #L46 - L48 were not covered by tests


def pre_init_hook(env):
migrate_rename_xmlid_event_type_holiday(env)
migrate_rename_field_model_hr_holidays_public_line(env)
migrate_rename_model_hr_holidays_public_line(env)
migrate_rename_model_hr_holidays_public(env)
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# generated from manifests external_dependencies
openupgradelib

0 comments on commit bd79fb1

Please sign in to comment.