diff --git a/addons/account/migrations/12.0.1.1/openupgrade_analysis_work.txt b/addons/account/migrations/12.0.1.1/openupgrade_analysis_work.txt index 8c2b897a5c16..27b1f6daf5f6 100644 --- a/addons/account/migrations/12.0.1.1/openupgrade_analysis_work.txt +++ b/addons/account/migrations/12.0.1.1/openupgrade_analysis_work.txt @@ -32,7 +32,8 @@ account / account.fiscal.year / company_id (many2one) : NEW re account / account.fiscal.year / date_from (date) : NEW required: required account / account.fiscal.year / date_to (date) : NEW required: required account / account.fiscal.year / name (char) : NEW required: required -# NOTHING TO DO (new model) +# Done: post-migration: populate with old account.fiscalyear model +# if we come from a 8.0 database. account / account.group / parent_left (integer) : DEL account / account.group / parent_path (char) : NEW diff --git a/addons/account/migrations/12.0.1.1/post-migration.py b/addons/account/migrations/12.0.1.1/post-migration.py index 29bea726e310..196891202335 100644 --- a/addons/account/migrations/12.0.1.1/post-migration.py +++ b/addons/account/migrations/12.0.1.1/post-migration.py @@ -220,6 +220,23 @@ def set_default_taxes(env): }) +def populate_fiscal_years(env): + if openupgrade.table_exists(env.cr, 'account_fiscalyear'): + # An old 8.0 table is still present with fiscal years + # We populate the new table with the old values + openupgrade.logged_query( + env.cr, """ + INSERT INTO account_fiscal_year ( + id, name, company_id, date_from, date_to, + create_date, create_uid, write_date, write_uid + ) + SELECT + id, name, company_id, date_start, date_stop, + create_date, create_uid, write_date, write_uid + FROM account_fiscalyear; + """) + + @openupgrade.migrate() def migrate(env, version): cr = env.cr @@ -235,6 +252,7 @@ def migrate(env, version): fill_account_move_reverse_entry_id(env) recompute_invoice_taxes_add_analytic_tags(env) set_default_taxes(env) + populate_fiscal_years(env) openupgrade.load_data( cr, 'account', 'migrations/12.0.1.1/noupdate_changes.xml') openupgrade.delete_record_translations(