Skip to content

Commit

Permalink
[MIG] 15.0 l10m_de_tax_statement: Migration to 15.0
Browse files Browse the repository at this point in the history
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
  • Loading branch information
MrGigSolutions committed Jan 19, 2024
1 parent dc1d96c commit 89544f9
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 128 deletions.
8 changes: 6 additions & 2 deletions l10n_de_tax_statement/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand All @@ -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,
}
14 changes: 0 additions & 14 deletions l10n_de_tax_statement/migrations/13.0.1.0.0/post-migration.py

This file was deleted.

4 changes: 2 additions & 2 deletions l10n_de_tax_statement/models/l10n_de_tax_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions l10n_de_tax_statement/models/l10n_de_tax_statement_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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()
Expand Down
1 change: 1 addition & 0 deletions l10n_de_tax_statement/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* Andrea Stirpe <[email protected]>
* Thorsten Vocks <[email protected]>
* Helly kapatel <[email protected]>
* Mark Schuit <[email protected]>
18 changes: 0 additions & 18 deletions l10n_de_tax_statement/templates/assets.xml

This file was deleted.

138 changes: 51 additions & 87 deletions l10n_de_tax_statement/tests/test_l10n_de_tax_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
)

Expand Down
6 changes: 3 additions & 3 deletions l10n_de_tax_statement/views/l10n_de_tax_statement_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers" />
<field name="message_ids" widget="mail_thread" />
<field name="activity_ids" widget="mail_activity" />
<field name="message_follower_ids" />
<field name="message_ids" />
<field name="activity_ids" />
</div>
</form>
</field>
Expand Down

0 comments on commit 89544f9

Please sign in to comment.