-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] l10n_nl_account_tax_unece: add migration script
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
l10n_nl_account_tax_unece/migrations/14.0.1.1.0/post-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,38 @@ | ||
# 2021 Bosd | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
""" | ||
The unece tags have been set with the no update tag. | ||
Use openupgradelib to force load the changes. | ||
""" | ||
|
||
|
||
import logging | ||
|
||
from odoo import SUPERUSER_ID, api | ||
|
||
_logger = logging.getLogger(__name__) | ||
try: | ||
from openupgradelib import openupgrade | ||
except ImportError: | ||
openupgrade = None | ||
|
||
|
||
def set_unece_on_taxes(cr): | ||
with api.Environment.manage(): | ||
env = api.Environment(cr, SUPERUSER_ID, {}) | ||
for company in env["res.company"].search([]): | ||
company._l10n_nl_set_unece_on_taxes() | ||
|
||
|
||
def migrate(cr, version): | ||
if openupgrade is None: | ||
_logger.warning( | ||
"OpenUpgradeLib is not found, can't update l10n_nl_account_tax_unece tags" | ||
) | ||
return | ||
_logger.warning("OpenUpgradeLib is going to upgrade nl l10n_nl_account_tax_unece") | ||
openupgrade.load_data( | ||
cr, "l10n_nl_account_tax_unece", "data/account_tax_template.xml", mode="init" | ||
) | ||
set_unece_on_taxes(cr) |