From ae8ab105e990e9feb9f0ba0b8a0be6b4abf6696f Mon Sep 17 00:00:00 2001 From: Borruso Date: Fri, 20 Dec 2024 17:01:37 +0100 Subject: [PATCH] [MIG] l10n_it_account_tax_kind: Migration to 18.0 --- l10n_it_account_tax_kind/README.rst | 10 ++-- l10n_it_account_tax_kind/__manifest__.py | 4 +- .../migrations/18.0.1.0.0/pre-migrate.py | 55 +++++++++++++++++++ .../model/account_tax_kind.py | 9 ++- .../security/ir.model.access.csv | 2 +- .../static/description/index.html | 17 +++--- .../tests/test_account_tax_kind.py | 22 ++++---- .../view/account_tax_kind_view.xml | 24 ++++---- .../view/account_tax_view.xml | 3 +- 9 files changed, 102 insertions(+), 44 deletions(-) create mode 100644 l10n_it_account_tax_kind/migrations/18.0.1.0.0/pre-migrate.py diff --git a/l10n_it_account_tax_kind/README.rst b/l10n_it_account_tax_kind/README.rst index 08c22a913095..408b2d5c7689 100644 --- a/l10n_it_account_tax_kind/README.rst +++ b/l10n_it_account_tax_kind/README.rst @@ -17,13 +17,13 @@ ITA - Natura delle aliquote IVA :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github - :target: https://github.com/OCA/l10n-italy/tree/16.0/l10n_it_account_tax_kind + :target: https://github.com/OCA/l10n-italy/tree/18.0/l10n_it_account_tax_kind :alt: OCA/l10n-italy .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/l10n-italy-16-0/l10n-italy-16-0-l10n_it_account_tax_kind + :target: https://translation.odoo-community.org/projects/l10n-italy-18-0/l10n-italy-18-0-l10n_it_account_tax_kind :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-italy&target_branch=16.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-italy&target_branch=18.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -91,7 +91,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -125,6 +125,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/l10n-italy `_ project on GitHub. +This module is part of the `OCA/l10n-italy `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/l10n_it_account_tax_kind/__manifest__.py b/l10n_it_account_tax_kind/__manifest__.py index 09b7ce8fd7b4..e60bcf3bbead 100644 --- a/l10n_it_account_tax_kind/__manifest__.py +++ b/l10n_it_account_tax_kind/__manifest__.py @@ -8,7 +8,7 @@ { "name": "ITA - Natura delle aliquote IVA", - "version": "16.0.1.0.1", + "version": "18.0.1.0.0", "development_status": "Production/Stable", "category": "Localization/Italy", "summary": "Gestione natura delle aliquote IVA", @@ -16,7 +16,7 @@ "website": "https://github.com/OCA/l10n-italy", "license": "AGPL-3", "depends": [ - "l10n_it_account", + "l10n_it", ], "data": [ "view/account_tax_kind_view.xml", diff --git a/l10n_it_account_tax_kind/migrations/18.0.1.0.0/pre-migrate.py b/l10n_it_account_tax_kind/migrations/18.0.1.0.0/pre-migrate.py new file mode 100644 index 000000000000..a03d4d12393e --- /dev/null +++ b/l10n_it_account_tax_kind/migrations/18.0.1.0.0/pre-migrate.py @@ -0,0 +1,55 @@ +# Dinamiche Aziendali srl () +# @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() diff --git a/l10n_it_account_tax_kind/model/account_tax_kind.py b/l10n_it_account_tax_kind/model/account_tax_kind.py index 5787f9186afd..fc2df8e0b1f7 100644 --- a/l10n_it_account_tax_kind/model/account_tax_kind.py +++ b/l10n_it_account_tax_kind/model/account_tax_kind.py @@ -1,4 +1,4 @@ -from odoo import fields, models +from odoo import api, fields, models class AccountTaxKind(models.Model): @@ -9,8 +9,7 @@ class AccountTaxKind(models.Model): code = fields.Char(size=4, required=True) name = fields.Char(required=True) - def name_get(self): - res = [] + @api.depends("code", "name") + def _compute_display_name(self): for tax_kind in self: - res.append((tax_kind.id, f"[{tax_kind.code}] {tax_kind.name}")) - return res + tax_kind.display_name = f"[{tax_kind.code}] {tax_kind.name}" diff --git a/l10n_it_account_tax_kind/security/ir.model.access.csv b/l10n_it_account_tax_kind/security/ir.model.access.csv index d1afee85ccf5..37c667c816b4 100644 --- a/l10n_it_account_tax_kind/security/ir.model.access.csv +++ b/l10n_it_account_tax_kind/security/ir.model.access.csv @@ -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 diff --git a/l10n_it_account_tax_kind/static/description/index.html b/l10n_it_account_tax_kind/static/description/index.html index c785a0861ad6..e4b97e8621ae 100644 --- a/l10n_it_account_tax_kind/static/description/index.html +++ b/l10n_it_account_tax_kind/static/description/index.html @@ -8,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -274,7 +275,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -300,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -368,7 +369,7 @@

ITA - Natura delle aliquote IVA

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:3ef9107313814378f2d62f26b54735cbe6c4c582fd7184d74b0d41fdc58a5c4f !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Production/Stable License: AGPL-3 OCA/l10n-italy Translate me on Weblate Try me on Runboat

+

Production/Stable License: AGPL-3 OCA/l10n-italy Translate me on Weblate Try me on Runboat

Italiano

Questo modulo estende la funzionalità delle imposte.

Con questo modulo è possibile assegnare un tipo di esenzione per ogni @@ -430,7 +431,7 @@

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -454,11 +455,13 @@

Contributors

Maintainers

This module is maintained by the OCA.

-Odoo Community Association + +Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

-

This module is part of the OCA/l10n-italy project on GitHub.

+

This module is part of the OCA/l10n-italy project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/l10n_it_account_tax_kind/tests/test_account_tax_kind.py b/l10n_it_account_tax_kind/tests/test_account_tax_kind.py index fb86e7dca150..202d8671a2b2 100644 --- a/l10n_it_account_tax_kind/tests/test_account_tax_kind.py +++ b/l10n_it_account_tax_kind/tests/test_account_tax_kind.py @@ -2,7 +2,7 @@ from odoo.tests.common import TransactionCase -from odoo.addons.l10n_it_account.tools.account_tools import fpa_schema_get_enum +# from odoo.addons.l10n_it_account.tools.account_tools import fpa_schema_get_enum class TestAccountTaxKind(TransactionCase): @@ -21,13 +21,13 @@ def test_name_search(self): result = self.env["account.tax.kind"].name_search("Escluse ex art. 15") self.assertEqual(result and result[0][0], self.tax_kind_n1.id) - def test_compare_with_fpa_schema(self): - """Check that the values we define in this module are - the same as those defined in FPA xsd""" - - my_codes = self.env["account.tax.kind"].search([]).mapped("code") - - # from fatturapa xml Schema - xsd_codes = [code for code, descr in fpa_schema_get_enum("NaturaType")] - - self.assertCountEqual(my_codes, xsd_codes) + # def test_compare_with_fpa_schema(self): + # """Check that the values we define in this module are + # the same as those defined in FPA xsd""" + # + # my_codes = self.env["account.tax.kind"].search([]).mapped("code") + # + # # from fatturapa xml Schema + # xsd_codes = [code for code, descr in fpa_schema_get_enum("NaturaType")] + # + # self.assertCountEqual(my_codes, xsd_codes) diff --git a/l10n_it_account_tax_kind/view/account_tax_kind_view.xml b/l10n_it_account_tax_kind/view/account_tax_kind_view.xml index f64f6f6aa0bc..0c8bca9494a2 100644 --- a/l10n_it_account_tax_kind/view/account_tax_kind_view.xml +++ b/l10n_it_account_tax_kind/view/account_tax_kind_view.xml @@ -1,13 +1,13 @@ - account.tax.kind.tree + account.tax.kind.list account.tax.kind - + - + @@ -28,16 +28,16 @@ Tax Exemption Kind ir.actions.act_window account.tax.kind - tree,form + list,form - + + + + + + + + diff --git a/l10n_it_account_tax_kind/view/account_tax_view.xml b/l10n_it_account_tax_kind/view/account_tax_view.xml index 4cf2834a78fe..0d71b71ddc35 100644 --- a/l10n_it_account_tax_kind/view/account_tax_view.xml +++ b/l10n_it_account_tax_kind/view/account_tax_view.xml @@ -9,7 +9,8 @@