Skip to content

Commit 94182b1

Browse files
committed
Merge PR #4916 into 18.0
Signed-off-by tafaRU
2 parents 7f63f7c + 6841c4c commit 94182b1

8 files changed

Lines changed: 163 additions & 22 deletions

File tree

l10n_it_vat_settlement_date/README.rst

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
.. image:: https://odoo-community.org/readme-banner-image
2-
:target: https://odoo-community.org/get-involved?utm_source=readme
3-
:alt: Odoo Community Association
4-
51
=========================
62
ITA - Data competenza IVA
73
=========================
@@ -17,7 +13,7 @@ ITA - Data competenza IVA
1713
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
1814
:target: https://odoo-community.org/page/development-status
1915
:alt: Beta
20-
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
2117
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
2218
:alt: License: AGPL-3
2319
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github
@@ -36,10 +32,25 @@ ITA - Data competenza IVA
3632

3733
Aggiunge la data competenza IVA per le fatture fornitori.
3834

35+
La data di competenza IVA può essere impostata nella fattura e viene
36+
utilizzata automaticamente in:
37+
38+
- Liquidazione IVA (modulo
39+
``l10n_it_account_vat_period_end_settlement``)
40+
- Registro IVA (modulo ``l10n_it_vat_registries``)
41+
- Saldo delle imposte (modulo ``account_tax_balance``)
42+
3943
**English**
4044

4145
Add settlement date for bills.
4246

47+
The VAT settlement date can be set in the invoice and is automatically
48+
used in:
49+
50+
- VAT Settlement (module ``l10n_it_account_vat_period_end_settlement``)
51+
- VAT Registry (module ``l10n_it_vat_registries``)
52+
- Tax Balance (module ``account_tax_balance``)
53+
4354
**Table of contents**
4455

4556
.. contents::
@@ -66,9 +77,9 @@ Authors
6677
Contributors
6778
------------
6879

69-
- `Aion Tech <https://aiontech.company/>`__:
80+
- `Aion Tech <https://aiontech.company/>`__:
7081

71-
- Simone Rubino <simone.rubino@aion-tech.it>
82+
- Simone Rubino <simone.rubino@aion-tech.it>
7283

7384
Maintainers
7485
-----------

l10n_it_vat_settlement_date/models/account_tax.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# Copyright 2024 Simone Rubino - Aion Tech
33
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
44

5+
import re
6+
57
from odoo import models
68
from odoo.osv import expression
79

@@ -46,3 +48,19 @@ def get_move_line_partial_domain(self, from_date, to_date, company_ids):
4648
if self.env.context.get("use_l10n_it_vat_settlement_date"):
4749
domain = self._inject_vat_settlement_date_domain(domain)
4850
return domain
51+
52+
def _inject_vat_settlement_date_query(self, query):
53+
date_field_name = "date"
54+
settlement_date_field_name = "l10n_it_vat_settlement_date"
55+
settled_query = re.sub(
56+
rf"\b{date_field_name}\b", # Substitute only whole word
57+
settlement_date_field_name,
58+
query,
59+
)
60+
return settled_query
61+
62+
def _account_tax_ids_with_moves_query(self):
63+
query, params = super()._account_tax_ids_with_moves_query()
64+
if self.env.context.get("use_l10n_it_vat_settlement_date"):
65+
query = self._inject_vat_settlement_date_query(query)
66+
return query, params

l10n_it_vat_settlement_date/readme/DESCRIPTION.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
Aggiunge la data competenza IVA per le fatture fornitori.
44

5+
La data di competenza IVA può essere impostata nella fattura e viene utilizzata automaticamente in:
6+
- Liquidazione IVA (modulo `l10n_it_account_vat_period_end_settlement`)
7+
- Registro IVA (modulo `l10n_it_vat_registries`)
8+
- Saldo delle imposte (modulo `account_tax_balance`)
9+
510
**English**
611

712
Add settlement date for bills.
13+
14+
The VAT settlement date can be set in the invoice and is automatically used in:
15+
- VAT Settlement (module `l10n_it_account_vat_period_end_settlement`)
16+
- VAT Registry (module `l10n_it_vat_registries`)
17+
- Tax Balance (module `account_tax_balance`)

l10n_it_vat_settlement_date/static/description/index.html

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6-
<title>README.rst</title>
6+
<title>ITA - Data competenza IVA</title>
77
<style type="text/css">
88

99
/*
@@ -360,25 +360,35 @@
360360
</style>
361361
</head>
362362
<body>
363-
<div class="document">
363+
<div class="document" id="ita-data-competenza-iva">
364+
<h1 class="title">ITA - Data competenza IVA</h1>
364365

365-
366-
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
367-
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
368-
</a>
369-
<div class="section" id="ita-data-competenza-iva">
370-
<h1>ITA - Data competenza IVA</h1>
371366
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
372367
!! This file is generated by oca-gen-addon-readme !!
373368
!! changes will be overwritten. !!
374369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375370
!! source digest: sha256:b5b3d591cbd4d4e9de44633e88e09fef38ba0ca0cacf20c7f9e3229b6b6106a1
376371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377-
<p><a class="reference external image-reference" 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 image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/l10n-italy/tree/18.0/l10n_it_vat_settlement_date"><img alt="OCA/l10n-italy" src="https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/l10n-italy-18-0/l10n-italy-18-0-l10n_it_vat_settlement_date"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/l10n-italy&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372+
<p><a class="reference external image-reference" 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 image-reference" 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 image-reference" href="https://github.com/OCA/l10n-italy/tree/18.0/l10n_it_vat_settlement_date"><img alt="OCA/l10n-italy" src="https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/l10n-italy-18-0/l10n-italy-18-0-l10n_it_vat_settlement_date"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/l10n-italy&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378373
<p><strong>Italiano</strong></p>
379374
<p>Aggiunge la data competenza IVA per le fatture fornitori.</p>
375+
<p>La data di competenza IVA può essere impostata nella fattura e viene
376+
utilizzata automaticamente in:</p>
377+
<ul class="simple">
378+
<li>Liquidazione IVA (modulo
379+
<tt class="docutils literal">l10n_it_account_vat_period_end_settlement</tt>)</li>
380+
<li>Registro IVA (modulo <tt class="docutils literal">l10n_it_vat_registries</tt>)</li>
381+
<li>Saldo delle imposte (modulo <tt class="docutils literal">account_tax_balance</tt>)</li>
382+
</ul>
380383
<p><strong>English</strong></p>
381384
<p>Add settlement date for bills.</p>
385+
<p>The VAT settlement date can be set in the invoice and is automatically
386+
used in:</p>
387+
<ul class="simple">
388+
<li>VAT Settlement (module <tt class="docutils literal">l10n_it_account_vat_period_end_settlement</tt>)</li>
389+
<li>VAT Registry (module <tt class="docutils literal">l10n_it_vat_registries</tt>)</li>
390+
<li>Tax Balance (module <tt class="docutils literal">account_tax_balance</tt>)</li>
391+
</ul>
382392
<p><strong>Table of contents</strong></p>
383393
<div class="contents local topic" id="contents">
384394
<ul class="simple">
@@ -392,23 +402,23 @@ <h1>ITA - Data competenza IVA</h1>
392402
</ul>
393403
</div>
394404
<div class="section" id="bug-tracker">
395-
<h2><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h2>
405+
<h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
396406
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/l10n-italy/issues">GitHub Issues</a>.
397407
In case of trouble, please check there if your issue has already been reported.
398408
If you spotted it first, help us to smash it by providing a detailed and welcomed
399409
<a class="reference external" href="https://github.com/OCA/l10n-italy/issues/new?body=module:%20l10n_it_vat_settlement_date%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
400410
<p>Do not contact contributors directly about support or help with technical issues.</p>
401411
</div>
402412
<div class="section" id="credits">
403-
<h2><a class="toc-backref" href="#toc-entry-2">Credits</a></h2>
413+
<h1><a class="toc-backref" href="#toc-entry-2">Credits</a></h1>
404414
<div class="section" id="authors">
405-
<h3><a class="toc-backref" href="#toc-entry-3">Authors</a></h3>
415+
<h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
406416
<ul class="simple">
407417
<li>Marco Colombo</li>
408418
</ul>
409419
</div>
410420
<div class="section" id="contributors">
411-
<h3><a class="toc-backref" href="#toc-entry-4">Contributors</a></h3>
421+
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
412422
<ul class="simple">
413423
<li><a class="reference external" href="https://aiontech.company/">Aion Tech</a>:<ul>
414424
<li>Simone Rubino &lt;<a class="reference external" href="mailto:simone.rubino&#64;aion-tech.it">simone.rubino&#64;aion-tech.it</a>&gt;</li>
@@ -417,7 +427,7 @@ <h3><a class="toc-backref" href="#toc-entry-4">Contributors</a></h3>
417427
</ul>
418428
</div>
419429
<div class="section" id="maintainers">
420-
<h3><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h3>
430+
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
421431
<p>This module is maintained by the OCA.</p>
422432
<a class="reference external image-reference" href="https://odoo-community.org">
423433
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
@@ -430,6 +440,5 @@ <h3><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h3>
430440
</div>
431441
</div>
432442
</div>
433-
</div>
434443
</body>
435444
</html>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
22

3+
from . import test_open_tax_balances
34
from . import test_vat_period_end_statement
45
from . import test_vat_registry
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Copyright 2025 Simone Rubino
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
import datetime
5+
6+
from dateutil.relativedelta import relativedelta
7+
8+
from odoo.tests import Form, tagged
9+
from odoo.tools.safe_eval import safe_eval
10+
11+
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
12+
13+
14+
@tagged("post_install", "-at_install")
15+
class TestOpenTaxBalances(AccountTestInvoicingCommon):
16+
@classmethod
17+
def setUpClass(cls):
18+
super().setUpClass()
19+
cls.supplier_bill = cls.init_invoice(
20+
"in_invoice",
21+
invoice_date=datetime.date(2020, 6, 15),
22+
amounts=[
23+
100,
24+
],
25+
taxes=cls.tax_sale_a,
26+
post=True,
27+
)
28+
29+
def _get_wizard(self, from_date, to_date):
30+
"""Create the wizard to show the Tax Balances."""
31+
wizard_form = Form(self.env["wizard.open.tax.balances"])
32+
wizard_form.from_date = from_date
33+
wizard_form.to_date = to_date
34+
wizard = wizard_form.save()
35+
return wizard
36+
37+
def _get_tax_balances(self, from_date, to_date):
38+
"""Get the Taxes shown by the wizard."""
39+
wizard = self._get_wizard(from_date, to_date)
40+
taxes_action = wizard.open_taxes()
41+
return (
42+
self.env[taxes_action["res_model"]]
43+
.with_context(**taxes_action["context"])
44+
.search(safe_eval(taxes_action["domain"]))
45+
)
46+
47+
def test_wizard(self):
48+
"""The settlement date is used in the Tax Balances."""
49+
# Arrange
50+
bill = self.supplier_bill
51+
bill_tax_amount = bill.amount_tax
52+
accounting_date = bill.date
53+
settlement_date = accounting_date + relativedelta(years=1)
54+
from_date = datetime.date(2021, 1, 1)
55+
to_date = datetime.date(2021, 12, 31)
56+
taxes = self._get_tax_balances(from_date, to_date)
57+
tax_balance = taxes.filtered(
58+
lambda tax, bill_tax=bill.line_ids.tax_ids: tax == bill_tax
59+
).balance_regular
60+
# pre-condition
61+
self.assertTrue(bill_tax_amount)
62+
self.assertFalse(from_date <= accounting_date <= to_date)
63+
self.assertTrue(from_date <= settlement_date <= to_date)
64+
65+
# Act
66+
bill.l10n_it_vat_settlement_date = settlement_date
67+
taxes = self._get_tax_balances(from_date, to_date)
68+
69+
# Assert
70+
settled_tax_balance = taxes.filtered(
71+
lambda tax, bill_tax=bill.line_ids.tax_ids: tax == bill_tax
72+
).balance_regular
73+
self.assertEqual(
74+
tax_balance - bill_tax_amount,
75+
settled_tax_balance,
76+
"Tax Balance hasn't changed "
77+
"when bill settlement date is out of the wizard range",
78+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
22

3+
from . import open_tax_balances
34
from . import report_registro_iva_xlsx
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2025 Simone Rubino
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
4+
from odoo import models
5+
6+
7+
class WizardOpenTaxBalances(models.TransientModel):
8+
_inherit = "wizard.open.tax.balances"
9+
10+
def open_taxes(self):
11+
action = super().open_taxes()
12+
action.setdefault("context", dict())["use_l10n_it_vat_settlement_date"] = True
13+
return action

0 commit comments

Comments
 (0)