From 89544f9031f12a91dc252925cddd6142eff7aa50 Mon Sep 17 00:00:00 2001 From: Mark Schuit Date: Thu, 18 Jan 2024 14:49:41 +0800 Subject: [PATCH] [MIG] 15.0 l10m_de_tax_statement: Migration to 15.0 Changes: - Adjusted manifest - Removed migrations - Refactored unlink() to @api.ondelete - Removed unused methods and imports from tests - Tests now use setUpClass instead of setUp - Removed widgets from chatter --- l10n_de_tax_statement/__manifest__.py | 8 +- .../migrations/13.0.1.0.0/post-migration.py | 14 -- .../models/l10n_de_tax_statement.py | 4 +- .../models/l10n_de_tax_statement_line.py | 4 +- l10n_de_tax_statement/readme/CONTRIBUTORS.rst | 1 + l10n_de_tax_statement/templates/assets.xml | 18 --- .../tests/test_l10n_de_tax_statement.py | 138 +++++++----------- .../views/l10n_de_tax_statement_view.xml | 6 +- 8 files changed, 65 insertions(+), 128 deletions(-) delete mode 100644 l10n_de_tax_statement/migrations/13.0.1.0.0/post-migration.py delete mode 100644 l10n_de_tax_statement/templates/assets.xml diff --git a/l10n_de_tax_statement/__manifest__.py b/l10n_de_tax_statement/__manifest__.py index 000623da6..23e6ed48f 100644 --- a/l10n_de_tax_statement/__manifest__.py +++ b/l10n_de_tax_statement/__manifest__.py @@ -4,7 +4,7 @@ { "name": "German VAT Statement", - "version": "14.0.1.0.0", + "version": "15.0.1.0.0", "category": "Localization", "license": "AGPL-3", "author": "Onestein, Odoo Community Association (OCA)", @@ -14,11 +14,15 @@ "security/ir.model.access.csv", "security/tax_statement_security_rule.xml", "data/paperformat.xml", - "templates/assets.xml", "views/l10n_de_tax_statement_view.xml", "views/report_tax_statement.xml", "views/res_config_settings.xml", "report/report_tax_statement.xml", ], + "assets": { + "web.report_assets_common": [ + "/l10n_de_tax_statement/static/src/css/report.css", + ], + }, "installable": True, } diff --git a/l10n_de_tax_statement/migrations/13.0.1.0.0/post-migration.py b/l10n_de_tax_statement/migrations/13.0.1.0.0/post-migration.py deleted file mode 100644 index bd75e5eae..000000000 --- a/l10n_de_tax_statement/migrations/13.0.1.0.0/post-migration.py +++ /dev/null @@ -1,14 +0,0 @@ -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). - -from odoo import SUPERUSER_ID, api - - -def migrate(cr, version): - env = api.Environment(cr, SUPERUSER_ID, {}) - rule = env.ref( - "l10n_de_tax_statement.tax_statement_security_rule", - raise_if_not_found=False, - ) - if rule: - domain = "['|',('company_id','=',False),('company_id','in',company_ids)]" - rule.write({"domain_force": domain}) diff --git a/l10n_de_tax_statement/models/l10n_de_tax_statement.py b/l10n_de_tax_statement/models/l10n_de_tax_statement.py index fc50f002f..7b05412b7 100644 --- a/l10n_de_tax_statement/models/l10n_de_tax_statement.py +++ b/l10n_de_tax_statement/models/l10n_de_tax_statement.py @@ -440,7 +440,8 @@ def write(self, values): ) return super().write(values) - def unlink(self): + @api.ondelete(at_uninstall=False) + def _unlink_except_if_posted_or_final(self): for statement in self: if statement.state == "posted": raise UserError( @@ -451,7 +452,6 @@ def unlink(self): ) if statement.state == "final": raise UserError(_("You cannot delete a statement set as final!")) - super().unlink() @api.depends("line_ids.tax") def _compute_tax_total(self): diff --git a/l10n_de_tax_statement/models/l10n_de_tax_statement_line.py b/l10n_de_tax_statement/models/l10n_de_tax_statement_line.py index f81405a07..121db121b 100644 --- a/l10n_de_tax_statement/models/l10n_de_tax_statement_line.py +++ b/l10n_de_tax_statement/models/l10n_de_tax_statement_line.py @@ -105,7 +105,8 @@ def _compute_is_readonly(self): else: line.is_readonly = True - def unlink(self): + @api.ondelete(at_uninstall=False) + def _unlink_except_if_posted_or_final(self): for line in self: if line.statement_id.state == "posted": raise UserError( @@ -118,7 +119,6 @@ def unlink(self): raise UserError( _("You cannot delete lines of a statement set as final!") ) - super().unlink() def view_tax_lines(self): self.ensure_one() diff --git a/l10n_de_tax_statement/readme/CONTRIBUTORS.rst b/l10n_de_tax_statement/readme/CONTRIBUTORS.rst index 2f1bc6d25..a081dc770 100644 --- a/l10n_de_tax_statement/readme/CONTRIBUTORS.rst +++ b/l10n_de_tax_statement/readme/CONTRIBUTORS.rst @@ -1,3 +1,4 @@ * Andrea Stirpe * Thorsten Vocks * Helly kapatel +* Mark Schuit diff --git a/l10n_de_tax_statement/templates/assets.xml b/l10n_de_tax_statement/templates/assets.xml deleted file mode 100644 index 2dcbf2015..000000000 --- a/l10n_de_tax_statement/templates/assets.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - diff --git a/l10n_de_tax_statement/tests/test_l10n_de_tax_statement.py b/l10n_de_tax_statement/tests/test_l10n_de_tax_statement.py index e6bfc5b23..651fb0350 100644 --- a/l10n_de_tax_statement/tests/test_l10n_de_tax_statement.py +++ b/l10n_de_tax_statement/tests/test_l10n_de_tax_statement.py @@ -8,157 +8,121 @@ from odoo import fields from odoo.exceptions import UserError -from odoo.modules.module import get_resource_path from odoo.tests import Form from odoo.tests.common import TransactionCase -from odoo.tools import convert_file class TestVatStatement(TransactionCase): - def _load(self, module, *args): - convert_file( - self.cr, - "l10n_de", - get_resource_path(module, *args), - {}, - "init", - False, - "test", - self.registry._assertion_report, - ) - - def _create_company_children(self): - self.company_child_1 = self.env["res.company"].create( - { - "name": "Child 1 Company", - "country_id": self.env.ref("base.de").id, - "parent_id": self.company_parent.id, - } - ) - self.env.user.company_id = self.company_child_1 - self.coa.try_loading() - self.company_child_2 = self.env["res.company"].create( - { - "name": "Child 2 Company", - "country_id": self.env.ref("base.de").id, - "parent_id": self.company_parent.id, - } - ) - self.env.user.company_id = self.company_child_2 - self.coa.try_loading() - self.env.user.company_id = self.company_parent - - def setUp(self): - super().setUp() - - self.eur = self.env["res.currency"].search([("name", "=", "EUR")]) - self.coa = self.env.ref("l10n_de_skr03.l10n_de_chart_template", False) - self.coa = self.coa or self.env.ref( - "l10n_generic_coa.configurable_chart_template" - ) - self.company_parent = self.env["res.company"].create( + @classmethod + def setUpClass(cls): + super().setUpClass() + + cls.eur = cls.env["res.currency"].search([("name", "=", "EUR")]) + cls.coa = cls.env.ref("l10n_de_skr03.l10n_de_chart_template", False) + cls.coa = cls.coa or cls.env.ref("l10n_generic_coa.configurable_chart_template") + cls.company_parent = cls.env["res.company"].create( { "name": "Parent Company", - "country_id": self.env.ref("base.de").id, - "currency_id": self.eur.id, + "country_id": cls.env.ref("base.de").id, + "currency_id": cls.eur.id, } ) - self.env.user.company_id = self.company_parent - self.coa.try_loading() - self.env["l10n.de.tax.statement"].search([("state", "!=", "posted")]).unlink() + cls.env.user.company_id = cls.company_parent + cls.coa.try_loading(install_demo=False) + cls.env["l10n.de.tax.statement"].search([("state", "!=", "posted")]).unlink() - self.tag_1 = self.env["account.account.tag"].create( + cls.tag_1 = cls.env["account.account.tag"].create( { "name": "+81 base", "applicability": "taxes", - "country_id": self.env.ref("base.de").id, + "country_id": cls.env.ref("base.de").id, } ) - self.tag_2 = self.env["account.account.tag"].create( + cls.tag_2 = cls.env["account.account.tag"].create( { "name": "+81 tax", "applicability": "taxes", - "country_id": self.env.ref("base.de").id, + "country_id": cls.env.ref("base.de").id, } ) - self.tag_3 = self.env["account.account.tag"].create( + cls.tag_3 = cls.env["account.account.tag"].create( { "name": "+86 base", "applicability": "taxes", - "country_id": self.env.ref("base.de").id, + "country_id": cls.env.ref("base.de").id, } ) - self.tag_4 = self.env["account.account.tag"].create( + cls.tag_4 = cls.env["account.account.tag"].create( { "name": "+86 tax", "applicability": "taxes", - "country_id": self.env.ref("base.de").id, + "country_id": cls.env.ref("base.de").id, } ) - self.tag_5 = self.env["account.account.tag"].create( + cls.tag_5 = cls.env["account.account.tag"].create( { "name": "+41", "applicability": "taxes", - "country_id": self.env.ref("base.de").id, + "country_id": cls.env.ref("base.de").id, } ) - self.tag_6 = self.env["account.account.tag"].create( + cls.tag_6 = cls.env["account.account.tag"].create( { "name": "+62", "applicability": "taxes", - "country_id": self.env.ref("base.de").id, + "country_id": cls.env.ref("base.de").id, } ) - self.tag_7 = self.env["account.account.tag"].create( + cls.tag_7 = cls.env["account.account.tag"].create( { "name": "46", - "country_id": self.env.ref("base.de").id, + "country_id": cls.env.ref("base.de").id, } ) - self.tag_8 = self.env["account.account.tag"].create( + cls.tag_8 = cls.env["account.account.tag"].create( { "name": "47", - "country_id": self.env.ref("base.de").id, + "country_id": cls.env.ref("base.de").id, } ) - self.tag_9 = self.env["account.account.tag"].create( + cls.tag_9 = cls.env["account.account.tag"].create( { "name": "84", - "country_id": self.env.ref("base.de").id, + "country_id": cls.env.ref("base.de").id, } ) - self.tag_10 = self.env["account.account.tag"].create( + cls.tag_10 = cls.env["account.account.tag"].create( { "name": "85", - "country_id": self.env.ref("base.de").id, + "country_id": cls.env.ref("base.de").id, } ) - self.tax_1 = self.env["account.tax"].create({"name": "Tax 1", "amount": 19}) - self.tax_1.invoice_repartition_line_ids[0].tag_ids = self.tag_1 - self.tax_1.invoice_repartition_line_ids[1].tag_ids = self.tag_2 + cls.tax_1 = cls.env["account.tax"].create({"name": "Tax 1", "amount": 19}) + cls.tax_1.invoice_repartition_line_ids[0].tag_ids = cls.tag_1 + cls.tax_1.invoice_repartition_line_ids[1].tag_ids = cls.tag_2 - self.tax_2 = self.env["account.tax"].create({"name": "Tax 2", "amount": 7}) - self.tax_2.invoice_repartition_line_ids[0].tag_ids = self.tag_3 - self.tax_2.invoice_repartition_line_ids[1].tag_ids = self.tag_4 + cls.tax_2 = cls.env["account.tax"].create({"name": "Tax 2", "amount": 7}) + cls.tax_2.invoice_repartition_line_ids[0].tag_ids = cls.tag_3 + cls.tax_2.invoice_repartition_line_ids[1].tag_ids = cls.tag_4 - self.tax_3 = self.env["account.tax"].create({"name": "Tax 3", "amount": 25}) - self.tax_3.invoice_repartition_line_ids[0].tag_ids = self.tag_5 - self.tax_3.invoice_repartition_line_ids[1].tag_ids = self.tag_5 + cls.tax_3 = cls.env["account.tax"].create({"name": "Tax 3", "amount": 25}) + cls.tax_3.invoice_repartition_line_ids[0].tag_ids = cls.tag_5 + cls.tax_3.invoice_repartition_line_ids[1].tag_ids = cls.tag_5 - self.tax_4 = self.env["account.tax"].create({"name": "Tax 4", "amount": 5}) - self.tax_4.invoice_repartition_line_ids[0].tag_ids = self.tag_6 + cls.tax_4 = cls.env["account.tax"].create({"name": "Tax 4", "amount": 5}) + cls.tax_4.invoice_repartition_line_ids[0].tag_ids = cls.tag_6 - self.tax_5 = self.env["account.tax"].create({"name": "Tax 5", "amount": 19}) - self.tax_5.invoice_repartition_line_ids[0].tag_ids = self.tag_7 - self.tax_5.invoice_repartition_line_ids[1].tag_ids = self.tag_8 + cls.tax_5 = cls.env["account.tax"].create({"name": "Tax 5", "amount": 19}) + cls.tax_5.invoice_repartition_line_ids[0].tag_ids = cls.tag_7 + cls.tax_5.invoice_repartition_line_ids[1].tag_ids = cls.tag_8 - self.tax_6 = self.env["account.tax"].create({"name": "Tax 6", "amount": 7}) - self.tax_6.refund_repartition_line_ids[0].tag_ids = self.tag_9 - self.tax_6.refund_repartition_line_ids[1].tag_ids = self.tag_10 + cls.tax_6 = cls.env["account.tax"].create({"name": "Tax 6", "amount": 7}) + cls.tax_6.refund_repartition_line_ids[0].tag_ids = cls.tag_9 + cls.tax_6.refund_repartition_line_ids[1].tag_ids = cls.tag_10 - self.statement_1 = self.env["l10n.de.tax.statement"].create( + cls.statement_1 = cls.env["l10n.de.tax.statement"].create( {"name": "Statement 1", "version": "2018"} ) diff --git a/l10n_de_tax_statement/views/l10n_de_tax_statement_view.xml b/l10n_de_tax_statement/views/l10n_de_tax_statement_view.xml index 7e7457048..71c39d020 100644 --- a/l10n_de_tax_statement/views/l10n_de_tax_statement_view.xml +++ b/l10n_de_tax_statement/views/l10n_de_tax_statement_view.xml @@ -220,9 +220,9 @@
- - - + + +