-
-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] account_fiscal_year_closing: Migration to 16.0
- Loading branch information
Showing
11 changed files
with
154 additions
and
72 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
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
58 changes: 58 additions & 0 deletions
58
account_fiscal_year_closing/migrations/16.0.1.0.0/pre-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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Copyright 2023 Akretion France (http://www.akretion.com/) | ||
# @author: Alexis de Lattre <alexis.delattre@akretion.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from openupgradelib import openupgrade | ||
|
||
|
||
def update_account_type(env, model, new_type, old_type): | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
UPDATE %(model)s | ||
SET account_type = '%(new_type)s' | ||
WHERE id in ( | ||
SELECT id | ||
WHERE account_type_id = %(old_type)s | ||
) | ||
""" | ||
% { | ||
"model": model, | ||
"new_type": new_type, | ||
"old_type": old_type, | ||
}, | ||
) | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
|
||
all_account_type = [ | ||
("asset_receivable", env("account.data_account_type_receivable").id), | ||
("asset_cash", env("account.data_account_type_liquidity").id), | ||
("asset_current", env("account.data_account_type_current_assets").id), | ||
("asset_non_current", env("account.data_account_type_non_current_assets").id), | ||
("asset_fixed", env("account.data_account_type_fixed_assets").id), | ||
("expense", env("account.data_account_type_expenses").id), | ||
("expense_depreciation", env("account.data_account_type_depreciation").id), | ||
("expense_direct_cost", env("account.data_account_type_direct_costs").id), | ||
("off_balance", env("account.data_account_off_sheet").id), | ||
("liability_payable", env("account.data_account_type_payable").id), | ||
("liability_credit_card", env("account.data_account_type_credit_card").id), | ||
("asset_prepayments", env("account.data_account_type_prepayments").id), | ||
("liability_current", env("account.data_account_type_current_liabilities").id), | ||
( | ||
"liability_non_current", | ||
env("account.data_account_type_non_current_liabilities").id, | ||
), | ||
("equity", env("account.data_account_type_equity").id), | ||
("equity_unaffected", env("account.data_unaffected_earnings").id), | ||
("income", env("account.data_account_type_revenue").id), | ||
("income_other", env("account.data_account_type_other_income").id), | ||
] | ||
|
||
for new_type, old_type in all_account_type: | ||
update_account_type( | ||
env, "account_fiscalyear_closing_type_template", new_type, old_type | ||
) | ||
update_account_type(env, "account_fiscalyear_closing_type", new_type, old_type) |
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
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
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
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
Oops, something went wrong.