-
-
Notifications
You must be signed in to change notification settings - Fork 520
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] l10n_es_aeat: Migration to 17.0
- Loading branch information
1 parent
dabdd88
commit 65c5b3b
Showing
28 changed files
with
687 additions
and
586 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<function model="aeat.account" name="update_accounts" /> | ||
</odoo> |
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,4 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<function model="aeat.tax" name="update_taxes" /> | ||
</odoo> |
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
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,48 @@ | ||
# Copyright 2016 Tecnativa - Antonio Espinosa | ||
# Copyright 2019 Tecnativa - Pedro M. Baeza | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl | ||
import logging | ||
import traceback | ||
|
||
from odoo import api, fields, models | ||
|
||
_logger = logging.getLogger() | ||
|
||
|
||
class AeatAccount(models.Model): | ||
_name = "aeat.account" | ||
_description = "AEAT Account" | ||
_order = "name" | ||
|
||
name = fields.Char() | ||
xmlid = fields.Char() | ||
|
||
@api.model | ||
def update_accounts(self): | ||
try: | ||
chart_template = self.env["account.chart.template"].sudo() | ||
accounts = {} | ||
data = chart_template._parse_csv("es_common", "account.account", "l10n_es") | ||
for key in data: | ||
accounts[ | ||
key | ||
] = f"{data[key]['code']} - {data[key].get('name@es') or data[key]['name']}" | ||
self._update_accounts(accounts) | ||
except Exception: | ||
_logger.error(traceback.format_exc()) | ||
raise | ||
|
||
def _update_accounts(self, account_data): | ||
accounts = self.env["aeat.account"].search([]) | ||
accounts.filtered(lambda x: x.xmlid not in account_data).unlink() | ||
accounts._load_records( | ||
[ | ||
{ | ||
"xml_id": f"l10n_es_aeat.{key}", | ||
"noupdate": True, | ||
"values": {"xmlid": key, "name": name}, | ||
} | ||
for key, name in account_data.items() | ||
], | ||
update=True, | ||
) |
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,46 @@ | ||
# Copyright 2016 Tecnativa - Antonio Espinosa | ||
# Copyright 2019 Tecnativa - Pedro M. Baeza | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl | ||
import logging | ||
import traceback | ||
|
||
from odoo import api, fields, models | ||
|
||
_logger = logging.getLogger() | ||
|
||
|
||
class AeatTax(models.Model): | ||
_name = "aeat.tax" | ||
_description = "AEAT Tax" | ||
_order = "name" | ||
|
||
name = fields.Char() | ||
xmlid = fields.Char() | ||
|
||
@api.model | ||
def update_taxes(self): | ||
try: | ||
chart_template = self.env["account.chart.template"].sudo() | ||
taxes = {} | ||
data = chart_template._parse_csv("es_common", "account.tax", "l10n_es") | ||
for key in data: | ||
taxes[key] = data[key].get("description@es") or data[key]["description"] | ||
self._update_taxes(taxes) | ||
except Exception: | ||
_logger.error(traceback.format_exc()) | ||
raise | ||
|
||
def _update_taxes(self, tax_data): | ||
taxes = self.env["aeat.tax"].search([]) | ||
taxes.filtered(lambda x: x.xmlid not in tax_data).unlink() | ||
taxes._load_records( | ||
[ | ||
{ | ||
"xml_id": f"l10n_es_aeat.{key}", | ||
"noupdate": True, | ||
"values": {"xmlid": key, "name": name}, | ||
} | ||
for key, name in tax_data.items() | ||
], | ||
update=True, | ||
) |
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
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.