Skip to content

Commit

Permalink
Merge PR #380 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by hbrunn
  • Loading branch information
OCA-git-bot committed Feb 12, 2024
2 parents c356ef4 + d7269c8 commit e2c6ca4
Show file tree
Hide file tree
Showing 15 changed files with 211 additions and 0 deletions.
84 changes: 84 additions & 0 deletions l10n_nl_tax_statement_date_range/README.rst
Original file line number Diff line number Diff line change
@@ -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 <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_date_range%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.

Credits
=======

Authors
~~~~~~~

* Onestein

Contributors
~~~~~~~~~~~~

* Andrea Stirpe <[email protected]>

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 <https://github.com/OCA/l10n-netherlands/tree/16.0/l10n_nl_tax_statement_date_range>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions l10n_nl_tax_statement_date_range/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions l10n_nl_tax_statement_date_range/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2023 Onestein (<https://www.onestein.eu>)
# 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,
}
1 change: 1 addition & 0 deletions l10n_nl_tax_statement_date_range/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import l10n_nl_vat_statement
20 changes: 20 additions & 0 deletions l10n_nl_tax_statement_date_range/models/l10n_nl_vat_statement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2023 Onestein (<https://www.onestein.eu>)
# 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,
}
)
1 change: 1 addition & 0 deletions l10n_nl_tax_statement_date_range/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Andrea Stirpe <[email protected]>
1 change: 1 addition & 0 deletions l10n_nl_tax_statement_date_range/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module provides the "Netherlands BTW Statement" with the Date Range feature.
1 change: 1 addition & 0 deletions l10n_nl_tax_statement_date_range/readme/INSTALL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* This module is installed automatically in case both ``l10n_nl_tax_statement`` and ``date_range`` are installed.
2 changes: 2 additions & 0 deletions l10n_nl_tax_statement_date_range/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions l10n_nl_tax_statement_date_range/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_l10n_nl_vat_statement
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright 2023 Onestein (<https://www.onestein.eu>)
# 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_l10n_nl_vat_report_form" model="ir.ui.view">
<field name="model">l10n.nl.vat.statement</field>
<field
name="inherit_id"
ref="l10n_nl_tax_statement.view_l10n_nl_vat_report_form"
/>
<field name="arch" type="xml">
<xpath expr="//label[@for='from_date']" position="before">
<field
name="date_range_id"
attrs="{'readonly': [('state','in',['posted','final'])]}"
/>
</xpath>
</field>
</record>
</odoo>
6 changes: 6 additions & 0 deletions setup/l10n_nl_tax_statement_date_range/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit e2c6ca4

Please sign in to comment.