diff --git a/l10n_nl_tax_statement_date_range/README.rst b/l10n_nl_tax_statement_date_range/README.rst new file mode 100644 index 000000000..ec1452534 --- /dev/null +++ b/l10n_nl_tax_statement_date_range/README.rst @@ -0,0 +1,84 @@ +====================================== +Netherlands BTW Statement - Date range +====================================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :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/16.0/l10n_nl_tax_statement_date_range + :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-16-0/l10n-netherlands-16-0-l10n_nl_tax_statement_date_range + :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/16.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module provides the "Netherlands BTW Statement" with the Date Range feature. + +**Table of contents** + +.. contents:: + :local: + +Installation +============ + +* This module is installed automatically in case both ``l10n_nl_tax_statement`` and ``date_range`` are installed. + +Usage +===== + +When creating a statement you can select a date range: the fields +``From Date`` and ``To Date`` will be automatically set. + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Onestein + +Contributors +~~~~~~~~~~~~ + +* Andrea Stirpe + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/l10n_nl_tax_statement_date_range/__init__.py b/l10n_nl_tax_statement_date_range/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/l10n_nl_tax_statement_date_range/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/l10n_nl_tax_statement_date_range/__manifest__.py b/l10n_nl_tax_statement_date_range/__manifest__.py new file mode 100644 index 000000000..1dc8c49ae --- /dev/null +++ b/l10n_nl_tax_statement_date_range/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2023 Onestein () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Netherlands BTW Statement - Date range", + "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": ["l10n_nl_tax_statement", "date_range"], + "data": [ + "views/l10n_nl_vat_statement_view.xml", + ], + "installable": True, + "auto_install": True, +} diff --git a/l10n_nl_tax_statement_date_range/models/__init__.py b/l10n_nl_tax_statement_date_range/models/__init__.py new file mode 100644 index 000000000..3e81ad36c --- /dev/null +++ b/l10n_nl_tax_statement_date_range/models/__init__.py @@ -0,0 +1 @@ +from . import l10n_nl_vat_statement diff --git a/l10n_nl_tax_statement_date_range/models/l10n_nl_vat_statement.py b/l10n_nl_tax_statement_date_range/models/l10n_nl_vat_statement.py new file mode 100644 index 000000000..465d69013 --- /dev/null +++ b/l10n_nl_tax_statement_date_range/models/l10n_nl_vat_statement.py @@ -0,0 +1,20 @@ +# Copyright 2023 Onestein () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class VatStatement(models.Model): + _inherit = "l10n.nl.vat.statement" + + date_range_id = fields.Many2one("date.range", "Date range") + + @api.onchange("date_range_id") + def onchange_date_range_id(self): + if self.date_range_id and self.state == "draft": + self.update( + { + "from_date": self.date_range_id.date_start, + "to_date": self.date_range_id.date_end, + } + ) diff --git a/l10n_nl_tax_statement_date_range/readme/CONTRIBUTORS.rst b/l10n_nl_tax_statement_date_range/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..4518218c8 --- /dev/null +++ b/l10n_nl_tax_statement_date_range/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Andrea Stirpe diff --git a/l10n_nl_tax_statement_date_range/readme/DESCRIPTION.rst b/l10n_nl_tax_statement_date_range/readme/DESCRIPTION.rst new file mode 100644 index 000000000..df07fa348 --- /dev/null +++ b/l10n_nl_tax_statement_date_range/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module provides the "Netherlands BTW Statement" with the Date Range feature. diff --git a/l10n_nl_tax_statement_date_range/readme/INSTALL.rst b/l10n_nl_tax_statement_date_range/readme/INSTALL.rst new file mode 100644 index 000000000..c0f617c6f --- /dev/null +++ b/l10n_nl_tax_statement_date_range/readme/INSTALL.rst @@ -0,0 +1 @@ +* This module is installed automatically in case both ``l10n_nl_tax_statement`` and ``date_range`` are installed. diff --git a/l10n_nl_tax_statement_date_range/readme/USAGE.rst b/l10n_nl_tax_statement_date_range/readme/USAGE.rst new file mode 100644 index 000000000..119109894 --- /dev/null +++ b/l10n_nl_tax_statement_date_range/readme/USAGE.rst @@ -0,0 +1,2 @@ +When creating a statement you can select a date range: the fields +``From Date`` and ``To Date`` will be automatically set. diff --git a/l10n_nl_tax_statement_date_range/static/description/icon.png b/l10n_nl_tax_statement_date_range/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/l10n_nl_tax_statement_date_range/static/description/icon.png differ diff --git a/l10n_nl_tax_statement_date_range/tests/__init__.py b/l10n_nl_tax_statement_date_range/tests/__init__.py new file mode 100644 index 000000000..95db42a30 --- /dev/null +++ b/l10n_nl_tax_statement_date_range/tests/__init__.py @@ -0,0 +1 @@ +from . import test_l10n_nl_vat_statement diff --git a/l10n_nl_tax_statement_date_range/tests/test_l10n_nl_vat_statement.py b/l10n_nl_tax_statement_date_range/tests/test_l10n_nl_vat_statement.py new file mode 100644 index 000000000..a21c60d9c --- /dev/null +++ b/l10n_nl_tax_statement_date_range/tests/test_l10n_nl_vat_statement.py @@ -0,0 +1,57 @@ +# Copyright 2023 Onestein () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +import datetime + +from odoo.tests import Form + +from odoo.addons.l10n_nl_tax_statement.tests.test_l10n_nl_vat_statement import ( + TestVatStatement, +) + + +class TestTaxStatementIcp(TestVatStatement): + @classmethod + def setUpClass(cls): + super().setUpClass() + daterange_type = cls.env["date.range.type"].create({"name": "Type 1"}) + daterange_vals = { + "name": "Daterange 1", + "type_id": daterange_type.id, + "date_start": "2016-01-01", + "date_end": "2016-12-31", + } + cls.daterange = cls.env["date.range"].create(daterange_vals) + + def test_01_date_range(self): + """When setting the Date Range, the From Date and To Date are updated accordingly""" + self.assertEqual(self.statement_1.state, "draft") + self.assertNotEqual(self.statement_1.from_date, datetime.date(2016, 1, 1)) + self.assertNotEqual(self.statement_1.to_date, datetime.date(2016, 12, 31)) + + # setting the date range modifies the From Date and To Date + form = Form(self.statement_1) + form.date_range_id = self.daterange + form.save() + self.assertEqual(self.statement_1.from_date, datetime.date(2016, 1, 1)) + self.assertEqual(self.statement_1.to_date, datetime.date(2016, 12, 31)) + + # removing the date range doesn't affect the From Date and To Date + form = Form(self.statement_1) + form.date_range_id = self.env["date.range"] + form.save() + self.assertEqual(self.statement_1.from_date, datetime.date(2016, 1, 1)) + self.assertEqual(self.statement_1.to_date, datetime.date(2016, 12, 31)) + + def test_02_date_range(self): + """Setting the Date Range is allowed only when the statement is in draft""" + self.statement_1.statement_update() + self.statement_1.post() + self.assertEqual(self.statement_1.state, "posted") + self.assertNotEqual(self.statement_1.from_date, datetime.date(2016, 1, 1)) + self.assertNotEqual(self.statement_1.to_date, datetime.date(2016, 12, 31)) + + # setting the date range is not allowed + form = Form(self.statement_1) + with self.assertRaises(AssertionError): + form.date_range_id = self.daterange diff --git a/l10n_nl_tax_statement_date_range/views/l10n_nl_vat_statement_view.xml b/l10n_nl_tax_statement_date_range/views/l10n_nl_vat_statement_view.xml new file mode 100644 index 000000000..100baa459 --- /dev/null +++ b/l10n_nl_tax_statement_date_range/views/l10n_nl_vat_statement_view.xml @@ -0,0 +1,18 @@ + + + + l10n.nl.vat.statement + + + + + + + + diff --git a/setup/l10n_nl_tax_statement_date_range/odoo/addons/l10n_nl_tax_statement_date_range b/setup/l10n_nl_tax_statement_date_range/odoo/addons/l10n_nl_tax_statement_date_range new file mode 120000 index 000000000..4c632c3d1 --- /dev/null +++ b/setup/l10n_nl_tax_statement_date_range/odoo/addons/l10n_nl_tax_statement_date_range @@ -0,0 +1 @@ +../../../../l10n_nl_tax_statement_date_range \ No newline at end of file diff --git a/setup/l10n_nl_tax_statement_date_range/setup.py b/setup/l10n_nl_tax_statement_date_range/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/l10n_nl_tax_statement_date_range/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)