forked from OCA/l10n-spain
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] l10n_es_irnr: Add xmlid rename in script migration
- Loading branch information
1 parent
928df31
commit 2e3ce9f
Showing
1 changed file
with
53 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,53 @@ | ||
# Copyright 2024 Aritz Olea <[email protected]> | ||
# Copyright 2025 Luis Rodríguez <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from odoo import SUPERUSER_ID, api | ||
from openupgradelib import openupgrade | ||
|
||
taxes_to_rename = [ | ||
( | ||
"l10n_es_irnr.%s_account_tax_template_s_irpfnrnue24", | ||
"l10n_es.%s_account_tax_template_s_irpfnrnue24", | ||
), | ||
( | ||
"l10n_es_irnr.%s_account_tax_template_p_irpfnrnue24p", | ||
"l10n_es.%s_account_tax_template_p_irpfnrnue24p", | ||
), | ||
( | ||
"l10n_es_irnr.%s_account_tax_template_s_irpfnrue19", | ||
"l10n_es.%s_account_tax_template_s_irpfnrue19", | ||
), | ||
( | ||
"l10n_es_irnr.%s_account_tax_template_p_irpfnrue19p", | ||
"l10n_es.%s_account_tax_template_p_irpfnrue19p", | ||
), | ||
( | ||
"l10n_es_irnr.%s_account_tax_template_s_irpfnrnue0", | ||
"l10n_es.%s_account_tax_template_s_irpfnrnue0", | ||
), | ||
( | ||
"l10n_es_irnr.%s_account_tax_template_p_irpfnrnue0p", | ||
"l10n_es.%s_account_tax_template_p_irpfnrnue0p", | ||
), | ||
( | ||
"l10n_es_irnr.%s_account_tax_template_s_irpfnrue0", | ||
"l10n_es.%s_account_tax_template_s_irpfnrue0", | ||
), | ||
( | ||
"l10n_es_irnr.%s_account_tax_template_p_irpfnrue0p", | ||
"l10n_es.%s_account_tax_template_p_irpfnrue0p", | ||
), | ||
] | ||
|
||
def migrate(cr, version): | ||
env = api.Environment(cr, SUPERUSER_ID, {}) | ||
|
||
def rename_xmlids(env): | ||
for company in env["res.company"].search([]): | ||
taxes_to_rename_by_company = [ | ||
(a % company.id, b % company.id) for (a, b) in taxes_to_rename | ||
] | ||
openupgrade.rename_xmlids(env.cr, taxes_to_rename_by_company) | ||
|
||
|
||
def migrate_tax_groups(env): | ||
retenciones_24 = env.ref("l10n_es.tax_group_retenciones_24") | ||
retenciones_19 = env.ref("l10n_es.tax_group_retenciones_19") | ||
retenciones_0 = env.ref("l10n_es.tax_group_retenciones_0") | ||
|
@@ -30,3 +73,10 @@ def migrate(cr, version): | |
.mapped("res_id") | ||
) | ||
env["account.tax"].browse(record_ids).tax_group_id = tax_write[1] | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
|
||
migrate_tax_groups(env) | ||
rename_xmlids(env) |