Skip to content
Snippets Groups Projects
post-migration.py 916 B
Newer Older
  • Learn to ignore specific revisions
  • # © 2022 Le Filament (<http://www.le-filament.com>)
    # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
    
    from openupgradelib import openupgrade  # pylint: disable=W7936
    
    
    def get_years():
        year_list = []
        for i in range(2019, 2030):
    
            year_list.append((i, str(i)))
    
    def get_months():
        month_list = []
        for i in range(1, 13):
            month_list.append((i, str(i)))
        return month_list
    
    
    
    def ur_month_timesheet_map_values(env):
        openupgrade.map_values(
            env.cr,
            openupgrade.get_legacy_name("month"),
            "month",
    
            get_months(),
    
            table="ur_month_timesheet",
        )
        openupgrade.map_values(
            env.cr,
            openupgrade.get_legacy_name("year"),
            "year",
            get_years(),
            table="ur_month_timesheet",
        )
    
    
    @openupgrade.migrate()
    def migrate(env, version):
        ur_month_timesheet_map_values(env)