-
-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] l10n_it_account_tax_kind: Migration to 18.0
- Loading branch information
Showing
9 changed files
with
102 additions
and
44 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
55 changes: 55 additions & 0 deletions
55
l10n_it_account_tax_kind/migrations/18.0.1.0.0/pre-migrate.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,55 @@ | ||
# Dinamiche Aziendali srl (<http://www.dinamicheaziendali.it/>) | ||
# @author: Giuseppe Borruso (gborruso@dinamicheaziendali.it) | ||
# License GPL-3.0 or later (http://www.gnu.org/licenses/gpl.html). | ||
|
||
from openupgradelib import openupgrade | ||
from psycopg2 import sql | ||
|
||
from odoo import SUPERUSER_ID, api | ||
|
||
MODEL = "account.tax" | ||
OLD_MODEL = "account.tax.kind" | ||
RENAMED_FIELDS = [ | ||
( | ||
"law_reference", | ||
"l10n_it_law_reference", | ||
), | ||
] | ||
|
||
|
||
def migrate(cr, version): | ||
env = api.Environment(cr, SUPERUSER_ID, {}) | ||
|
||
openupgrade.logged_query( | ||
env.cr, | ||
sql.SQL(f""" | ||
UPDATE | ||
{MODEL.replace(".", "_")} | ||
SET | ||
l10n_it_exempt_reason = kind_id.code | ||
FROM | ||
{OLD_MODEL.replace(".", "_")} AS kind | ||
WHERE | ||
{MODEL.replace(".", "_")}.kind_id = kind.id | ||
AND {MODEL.replace(".", "_")}.kind_id IS NOT NULL | ||
"""), | ||
) | ||
|
||
field_spec = [] | ||
for renamed_field in RENAMED_FIELDS: | ||
old_field, new_field = renamed_field | ||
field_spec.append( | ||
( | ||
MODEL, | ||
MODEL.replace(".", "_"), | ||
old_field, | ||
new_field, | ||
) | ||
) | ||
openupgrade.rename_fields( | ||
env, | ||
field_spec, | ||
) | ||
|
||
module = env["ir.module.module"].search([("name", "=", "l10n_it_account_tax_kind")]) | ||
module.button_immediate_uninstall() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" | ||
"access_account_tax_kind_user","account_tax_kind user","model_account_tax_kind",,1,0,0,0 | ||
"access_account_tax_kind_user","account_tax_kind user","model_account_tax_kind","base.group_user",1,0,0,0 | ||
"access_account_tax_kind_manager","account_tax_kind manager","model_account_tax_kind","account.group_account_invoice",1,1,1,1 |
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