Skip to content

Commit 5f32e28

Browse files
BorrusoeLBati
authored andcommitted
Integrating #5023
1 parent 1a22110 commit 5f32e28

File tree

6 files changed

+60
-3
lines changed

6 files changed

+60
-3
lines changed

l10n_it_edi_oss/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from . import models
22
from . import wizard
3+
from .hooks import pre_absorb_old_module
34

45
OSS_EXEMPT_REASON = "N3.2"
56
OSS_LAW_REFERENCE = "Art. 41 D.L. 331/1993"

l10n_it_edi_oss/__manifest__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"l10n_it_edi",
1515
"l10n_eu_oss_oca",
1616
],
17+
"external_dependencies": {"python": ["openupgradelib"]},
1718
"installable": True,
19+
"pre_init_hook": "pre_absorb_old_module",
1820
"post_init_hook": "_l10n_it_edi_oss_post_init_hook",
1921
}

l10n_it_edi_oss/hooks.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright 2025 Giuseppe Borruso - Dinamiche Aziendali srl
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from openupgradelib import openupgrade
5+
6+
_old_module = "l10n_it_fatturapa_out_oss"
7+
_new_module = "l10n_it_edi_oss"
8+
9+
10+
def pre_absorb_old_module(env):
11+
if openupgrade.is_module_installed(env, _old_module):
12+
openupgrade.update_module_names(
13+
env, [(_old_module, _new_module)], merge_modules=True
14+
)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright 2025 Giuseppe Borruso - Dinamiche Aziendali srl
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from openupgradelib import openupgrade
5+
6+
from odoo.addons.l10n_it_edi_oss import hooks
7+
8+
9+
@openupgrade.migrate()
10+
def migrate(env, version):
11+
# Used by OpenUpgrade when module is in `apriori`
12+
hooks.pre_absorb_old_module(env)

l10n_it_edi_oss/models/account_move.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ def _l10n_it_edi_grouping_function_tax_lines(self, base_line, tax_data):
1919
result = super()._l10n_it_edi_grouping_function_tax_lines(base_line, tax_data)
2020
if result and tax_data and tax_data["tax"].oss_country_id:
2121
result["tax_amount_field"] = 0.0
22-
result["is_oss"] = True
22+
result["oss_country_id"] = tax_data["tax"].oss_country_id
2323
return result
2424

2525
def _l10n_it_edi_add_base_lines_xml_values(
2626
self, base_lines_aggregated_values, is_downpayment
2727
):
28-
super()._l10n_it_edi_add_base_lines_xml_values(
28+
result = super()._l10n_it_edi_add_base_lines_xml_values(
2929
base_lines_aggregated_values, is_downpayment
3030
)
3131
for base_line, _aggregated_values in base_lines_aggregated_values:
@@ -39,6 +39,7 @@ def _l10n_it_edi_add_base_lines_xml_values(
3939
"riferimento_data": None,
4040
}
4141
)
42+
return result
4243

4344
def _l10n_it_edi_get_tax_lines_xml_values(
4445
self, base_lines_aggregated_values, values_per_grouping_key
@@ -54,7 +55,7 @@ def _l10n_it_edi_get_tax_lines_xml_values(
5455
grouping_key = values["grouping_key"]
5556
if not grouping_key or grouping_key.get("skip"):
5657
continue
57-
if grouping_key.get("is_oss") and idx < len(tax_lines):
58+
if grouping_key.get("oss_country_id") and idx < len(tax_lines):
5859
tax_lines[idx]["imposta"] = 0.0
5960
idx += 1
6061
return tax_lines

l10n_it_edi_oss/tests/test_edi_oss_export.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright 2026 Lorenzo Battistini
22
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
33

4+
from lxml import etree
5+
46
from odoo.tests import tagged
57

68
from odoo.addons.l10n_it_edi.tests.common import TestItEdi
@@ -56,3 +58,28 @@ def test_oss_invoice_export(self):
5658
invoice.invoice_date_due = invoice.date
5759
invoice.action_post()
5860
self._assert_export_invoice(invoice, "oss_invoice.xml")
61+
62+
def test_non_oss_invoice_export(self):
63+
"""Non-OSS invoices are not affected by this module."""
64+
invoice = self.init_invoice(
65+
"out_invoice",
66+
amounts=[100],
67+
company=self.company,
68+
partner=self.italian_partner_a,
69+
taxes=self.default_tax,
70+
)
71+
invoice.invoice_date_due = invoice.date
72+
invoice.action_post()
73+
xml = invoice._l10n_it_edi_render_xml()
74+
tree = etree.fromstring(xml)
75+
oss_nodes = [n for n in tree.iter("TipoDato") if n.text == "OSS"]
76+
self.assertFalse(
77+
oss_nodes, "Non-OSS invoice should not have OSS AltriDatiGestionali"
78+
)
79+
aliquota_nodes = list(tree.iter("AliquotaIVA"))
80+
for node in aliquota_nodes:
81+
self.assertNotEqual(
82+
node.text,
83+
"0.00",
84+
"Non-OSS invoice should have actual tax rate",
85+
)

0 commit comments

Comments
 (0)