Skip to content

Commit

Permalink
[16.0][MIG] l10n_nl_tax_statement
Browse files Browse the repository at this point in the history
  • Loading branch information
astirpe committed Feb 24, 2023
1 parent 19c225f commit 922477c
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 132 deletions.
15 changes: 5 additions & 10 deletions l10n_nl_tax_statement/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Netherlands BTW Statement
: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--netherlands-lightgray.png?logo=github
:target: https://github.com/OCA/l10n-netherlands/tree/15.0/l10n_nl_tax_statement
:target: https://github.com/OCA/l10n-netherlands/tree/16.0/l10n_nl_tax_statement
:alt: OCA/l10n-netherlands
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/l10n-netherlands-15-0/l10n-netherlands-15-0-l10n_nl_tax_statement
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/176/15.0
:target: https://runbot.odoo-community.org/runbot/176/16.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand All @@ -45,11 +45,6 @@ in: https://www.belastingdienst.nl/wps/wcm/connect/bldcontentnl/belastingdienst/
.. contents::
:local:

Installation
============

* This module depends on module ``date_range``.

Configuration
=============

Expand Down Expand Up @@ -83,7 +78,7 @@ Usage

To create a statement you need to:

#. Verify that you have enough permits. You need to belong to the *Show Full Accounting Features* group.
#. Verify that you have enough permits. You need to belong at least to the *Billing Manager* or the *Accountant* group.
#. Go to the menu: `Invoicing -> Reporting > NL BTW Statement`
#. Create a statement, providing a name and specifying start date and end date
#. Press the Update button to calculate the report: the report lines will be displayed in the tab `Statement`
Expand Down Expand Up @@ -130,7 +125,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-netherlands/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/l10n-netherlands/issues/new?body=module:%20l10n_nl_tax_statement%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/l10n-netherlands/issues/new?body=module:%20l10n_nl_tax_statement%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Expand Down Expand Up @@ -161,6 +156,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-netherlands <https://github.com/OCA/l10n-netherlands/tree/15.0/l10n_nl_tax_statement>`_ project on GitHub.
This module is part of the `OCA/l10n-netherlands <https://github.com/OCA/l10n-netherlands/tree/16.0/l10n_nl_tax_statement>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 2 additions & 2 deletions l10n_nl_tax_statement/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

{
"name": "Netherlands BTW Statement",
"version": "15.0.1.0.1",
"version": "16.0.1.0.0",
"category": "Localization",
"license": "AGPL-3",
"author": "Onestein, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-netherlands",
"depends": ["account", "date_range"],
"depends": ["account"],
"data": [
"security/ir.model.access.csv",
"security/tax_statement_security_rule.xml",
Expand Down
1 change: 0 additions & 1 deletion l10n_nl_tax_statement/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def _get_l10n_nl_vat_statement_protected_fields(self):
"date",
"debit",
"credit",
"balance",
"tax_ids",
"l10n_nl_vat_statement_include",
"tax_tag_ids",
Expand Down
22 changes: 4 additions & 18 deletions l10n_nl_tax_statement/models/l10n_nl_vat_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,8 @@ class VatStatement(models.Model):
readonly=True,
default=lambda self: self.env.company,
)
from_date = fields.Date(
required=True, store=True, readonly=False, compute="_compute_date_range"
)
to_date = fields.Date(
required=True, store=True, readonly=False, compute="_compute_date_range"
)
date_range_id = fields.Many2one("date.range", "Date range")
from_date = fields.Date(required=True)
to_date = fields.Date(required=True)
currency_id = fields.Many2one("res.currency", related="company_id.currency_id")
date_posted = fields.Datetime(readonly=True)
date_update = fields.Datetime(readonly=True)
Expand Down Expand Up @@ -207,15 +202,6 @@ def default_get(self, fields_list):
defaults.setdefault("name", self.env.company.name)
return defaults

@api.depends("date_range_id")
def _compute_date_range(self):
for statement in self:
if statement.date_range_id and statement.state == "draft":
statement.from_date = statement.date_range_id.date_start
statement.to_date = statement.date_range_id.date_end
statement.from_date = statement.from_date
statement.to_date = statement.to_date

@api.depends("from_date", "to_date")
def _compute_name(self):
for statement in self:
Expand Down Expand Up @@ -482,10 +468,10 @@ def post(self):
self.unreported_move_ids.filtered(
lambda m: m.l10n_nl_vat_statement_include
).write({"l10n_nl_vat_statement_id": self.id})
self.unreported_move_ids.flush()
self.unreported_move_ids.flush_recordset()
move_lines = self._compute_move_lines()
move_lines.move_id.write({"l10n_nl_vat_statement_id": self.id})
move_lines.move_id.flush()
move_lines.move_id.flush_recordset()

def _get_move_lines_domain(self):
domain = self._init_move_line_domain()
Expand Down
1 change: 0 additions & 1 deletion l10n_nl_tax_statement/readme/INSTALL.rst

This file was deleted.

2 changes: 1 addition & 1 deletion l10n_nl_tax_statement/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
To create a statement you need to:

#. Verify that you have enough permits. You need to belong to the *Show Full Accounting Features* group.
#. Verify that you have enough permits. You need to belong at least to the *Billing Manager* or the *Accountant* group.
#. Go to the menu: `Invoicing -> Reporting > NL BTW Statement`
#. Create a statement, providing a name and specifying start date and end date
#. Press the Update button to calculate the report: the report lines will be displayed in the tab `Statement`
Expand Down
13 changes: 3 additions & 10 deletions l10n_nl_tax_statement/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Netherlands BTW Statement</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/l10n-netherlands/tree/15.0/l10n_nl_tax_statement"><img alt="OCA/l10n-netherlands" src="https://img.shields.io/badge/github-OCA%2Fl10n--netherlands-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/l10n-netherlands-15-0/l10n-netherlands-15-0-l10n_nl_tax_statement"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/176/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/l10n-netherlands/tree/16.0/l10n_nl_tax_statement"><img alt="OCA/l10n-netherlands" src="https://img.shields.io/badge/github-OCA%2Fl10n--netherlands-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/l10n-netherlands-15-0/l10n-netherlands-15-0-l10n_nl_tax_statement"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/176/16.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module provides you with the Tax Statement in the Dutch format.</p>
<p>The Tax Statement can be generated in two ways, according to
the chosen Dutch accounting system:</p>
Expand All @@ -383,7 +383,6 @@ <h1 class="title">Netherlands BTW Statement</h1>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#installation" id="id1">Installation</a></li>
<li><a class="reference internal" href="#configuration" id="id2">Configuration</a></li>
<li><a class="reference internal" href="#usage" id="id3">Usage</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="id4">Known issues / Roadmap</a></li>
Expand All @@ -396,12 +395,6 @@ <h1 class="title">Netherlands BTW Statement</h1>
</li>
</ul>
</div>
<div class="section" id="installation">
<h1><a class="toc-backref" href="#id1">Installation</a></h1>
<ul class="simple">
<li>This module depends on module <tt class="docutils literal">date_range</tt>.</li>
</ul>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#id2">Configuration</a></h1>
<p>This module makes use of the tax tags (eg.: 1a, 1b, 1c, 1d, 2a…) as prescribed by the Dutch tax laws.</p>
Expand Down Expand Up @@ -478,7 +471,7 @@ <h1><a class="toc-backref" href="#id5">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/l10n-netherlands/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/l10n-netherlands/issues/new?body=module:%20l10n_nl_tax_statement%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/l10n-netherlands/issues/new?body=module:%20l10n_nl_tax_statement%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -503,7 +496,7 @@ <h2><a class="toc-backref" href="#id9">Maintainers</a></h2>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/l10n-netherlands/tree/15.0/l10n_nl_tax_statement">OCA/l10n-netherlands</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/l10n-netherlands/tree/16.0/l10n_nl_tax_statement">OCA/l10n-netherlands</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
110 changes: 39 additions & 71 deletions l10n_nl_tax_statement/tests/test_l10n_nl_vat_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,11 @@
import odoo
from odoo import fields
from odoo.exceptions import UserError, ValidationError
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_nl",
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(
{
Expand All @@ -45,98 +31,90 @@ def _create_company_children(self):
)
self.coa.try_loading(company=self.company_child_2, install_demo=False)

def setUp(self):
super().setUp()
self.eur = self.env.ref("base.EUR")
self.coa = self.env.ref("l10n_nl.l10nnl_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.ref("base.EUR")
cls.coa = cls.env.ref("l10n_nl.l10nnl_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.nl").id,
"currency_id": self.eur.id,
"country_id": cls.env.ref("base.nl").id,
"currency_id": cls.eur.id,
}
)
self.env.user.company_id = self.company_parent
self.coa.try_loading(company=self.company_parent, install_demo=False)
cls.env.user.company_id = cls.company_parent
cls.coa.try_loading(company=cls.company_parent, install_demo=False)

self.env["l10n.nl.vat.statement"].search([]).unlink()
cls.env["l10n.nl.vat.statement"].search([]).unlink()

self.tag_1 = self.env["account.account.tag"].create(
cls.tag_1 = cls.env["account.account.tag"].create(
{
"name": "+1a omzet",
"applicability": "taxes",
"country_id": self.env.ref("base.nl").id,
"country_id": cls.env.ref("base.nl").id,
}
)
self.tag_2 = self.env["account.account.tag"].create(
cls.tag_2 = cls.env["account.account.tag"].create(
{
"name": "+1a btw",
"applicability": "taxes",
"country_id": self.env.ref("base.nl").id,
"country_id": cls.env.ref("base.nl").id,
}
)
self.tag_3 = self.env["account.account.tag"].create(
cls.tag_3 = cls.env["account.account.tag"].create(
{
"name": "+2a omzet",
"applicability": "taxes",
"country_id": self.env.ref("base.nl").id,
"country_id": cls.env.ref("base.nl").id,
}
)
self.tag_4 = self.env["account.account.tag"].create(
cls.tag_4 = cls.env["account.account.tag"].create(
{
"name": "-2a omzet",
"applicability": "taxes",
"country_id": self.env.ref("base.nl").id,
"country_id": cls.env.ref("base.nl").id,
}
)
self.tag_5 = self.env["account.account.tag"].create(
cls.tag_5 = cls.env["account.account.tag"].create(
{
"name": "+3b omzet",
"applicability": "taxes",
"country_id": self.env.ref("base.nl").id,
"country_id": cls.env.ref("base.nl").id,
}
)
self.tag_6 = self.env["account.account.tag"].create(
cls.tag_6 = cls.env["account.account.tag"].create(
{
"name": "+3b omzet d",
"applicability": "taxes",
"country_id": self.env.ref("base.nl").id,
"country_id": cls.env.ref("base.nl").id,
}
)

self.tax_1 = self.env["account.tax"].create(
{"name": "Tax 1", "amount": 21, "country_id": self.env.ref("base.nl").id}
cls.tax_1 = cls.env["account.tax"].create(
{"name": "Tax 1", "amount": 21, "country_id": cls.env.ref("base.nl").id}
)
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.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": 21, "country_id": self.env.ref("base.nl").id}
cls.tax_2 = cls.env["account.tax"].create(
{"name": "Tax 2", "amount": 21, "country_id": cls.env.ref("base.nl").id}
)
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.invoice_repartition_line_ids[0].tag_ids = cls.tag_3
cls.tax_2.invoice_repartition_line_ids[1].tag_ids = cls.tag_4

self.statement_1 = self.env["l10n.nl.vat.statement"].create(
cls.statement_1 = cls.env["l10n.nl.vat.statement"].create(
{"name": "Statement 1"}
)

def _create_test_invoice(self):
self.company_parent.compute_account_tax_fiscal_country()
journal = self.env["account.journal"].create(
{
"name": "Journal 1",
"code": "Jou1",
"type": "sale",
"company_id": self.company_parent.id,
}
)

partner = self.env["res.partner"].create({"name": "Test partner"})
account_receivable = self.env["account.account"].create(
self.env["account.account"].create(
{
"user_type_id": self.env.ref("account.data_account_type_expenses").id,
"account_type": "expense",
"code": "EXPTEST",
"name": "Test expense account",
}
Expand All @@ -145,36 +123,26 @@ def _create_test_invoice(self):
self.env["account.move"].with_context(default_move_type="out_invoice")
)
invoice_form.partner_id = partner
invoice_form.journal_id = journal

with invoice_form.invoice_line_ids.new() as line:
line.name = "Test line"
line.quantity = 1.0
line.account_id = account_receivable
line.price_unit = 100.0
line.tax_ids.clear()
line.tax_ids.add(self.tax_1)
with invoice_form.invoice_line_ids.new() as line:
line.name = "Test line"
line.quantity = 1.0
line.account_id = account_receivable
line.price_unit = 50.0
line.tax_ids.clear()
line.tax_ids.add(self.tax_2)
self.invoice_1 = invoice_form.save()
self.assertEqual(len(self.invoice_1.line_ids), 5)

def test_01_onchange(self):
daterange_type = self.env["date.range.type"].create({"name": "Type 1"})
daterange = self.env["date.range"].create(
{
"name": "Daterange 1",
"type_id": daterange_type.id,
"date_start": "2016-01-01",
"date_end": "2016-12-31",
}
)
form = Form(self.statement_1)
form.date_range_id = daterange
form.from_date = datetime.date(2016, 1, 1)
form.to_date = datetime.date(2016, 12, 31)
statement = form.save()
self.assertEqual(statement.from_date, datetime.date(2016, 1, 1))
self.assertEqual(statement.to_date, datetime.date(2016, 12, 31))
Expand Down
Loading

0 comments on commit 922477c

Please sign in to comment.