Skip to content

Commit 463c060

Browse files
CopilotodooNextev
authored andcommitted
[IMP] l10n_it_edi_extension: add AltriDatiGestionali (2.2.1.16) export support for XML invoices
1 parent dc0d9d6 commit 463c060

File tree

14 files changed

+1034
-418
lines changed

14 files changed

+1034
-418
lines changed

l10n_it_edi_extension/README.rst

Lines changed: 357 additions & 333 deletions
Large diffs are not rendered by default.

l10n_it_edi_extension/__manifest__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"security/ir.model.access.csv",
2626
"data/invoice_it_template.xml",
2727
"data/res.city.it.code.csv",
28+
"views/l10n_it_edi_move_line_other_data_view.xml",
2829
"views/l10n_it_view.xml",
2930
"views/res_partner_view.xml",
3031
"views/company_view.xml",

l10n_it_edi_extension/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from . import l10n_it_edi_article_code
77
from . import l10n_it_edi_discount_rise_price
88
from . import l10n_it_edi_line_other_data
9+
from . import l10n_it_edi_move_line_other_data
910
from . import l10n_it_edi_activity_progress
1011
from . import l10n_it_edi_summary_data
1112
from . import l10n_it_edi_line

l10n_it_edi_extension/models/account_move.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,24 @@ def _l10n_it_edi_add_base_lines_xml_values(
208208
)
209209
for base_line, _aggregated_values in base_lines_aggregated_values:
210210
line = base_line["record"]
211+
# Build other_data list from l10n_it_edi_other_data_ids
212+
other_data_list = []
213+
for other_data in line.l10n_it_edi_other_data_ids:
214+
other_data_dict = {
215+
"tipo_dato": other_data.name,
216+
"riferimento_testo": other_data.text_ref or False,
217+
"riferimento_numero": other_data.num_ref or False,
218+
# Pass date object directly, format_date() in template handles it
219+
"riferimento_data": other_data.date_ref or False,
220+
}
221+
other_data_list.append(other_data_dict)
222+
223+
# Get existing altri_dati_gestionali_list or initialize empty list
224+
existing_list = base_line["it_values"].get("altri_dati_gestionali_list", [])
211225
base_line["it_values"].update(
212226
{
213227
"admin_ref": line.l10n_it_edi_admin_ref or None,
228+
"altri_dati_gestionali_list": existing_list + other_data_list,
214229
}
215230
)
216231
return res
Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,33 @@
11
# Copyright 2025 Giuseppe Borruso - Dinamiche Aziendali srl
22
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
33

4-
from odoo import fields, models
4+
from odoo import _, fields, models
55

66

77
class AccountMoveLineInherit(models.Model):
88
_inherit = "account.move.line"
99

1010
l10n_it_edi_admin_ref = fields.Char(string="Admin. ref.", size=20, copy=False)
11+
l10n_it_edi_other_data_ids = fields.One2many(
12+
"l10n_it_edi.move.line.other.data",
13+
"move_line_id",
14+
string="Other Management Data",
15+
copy=True,
16+
help="Additional management data (AltriDatiGestionali) to be exported "
17+
"in the FatturaPA XML.",
18+
)
19+
20+
def action_open_other_data(self):
21+
"""Open a popup to manage Other Management Data for this invoice line."""
22+
self.ensure_one()
23+
return {
24+
"name": _("Altri Dati Gestionali"),
25+
"type": "ir.actions.act_window",
26+
"res_model": "l10n_it_edi.move.line.other.data",
27+
"view_mode": "list,form",
28+
"domain": [("move_line_id", "=", self.id)],
29+
"context": {
30+
"default_move_line_id": self.id,
31+
},
32+
"target": "new",
33+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Copyright 2025 Nextev Srl
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
4+
from odoo import _, api, fields, models
5+
from odoo.exceptions import ValidationError
6+
7+
8+
class MoveLineOtherData(models.Model):
9+
"""Model for storing AltriDatiGestionali (2.2.1.16) on invoice lines for export.
10+
11+
This model stores additional management data that can be manually entered
12+
on account.move.line records and exported into the FatturaPA XML.
13+
"""
14+
15+
_name = "l10n_it_edi.move.line.other.data"
16+
_description = "Invoice Line Other Data for Export"
17+
_rec_name = "display_name"
18+
19+
move_line_id = fields.Many2one(
20+
"account.move.line",
21+
string="Invoice Line",
22+
required=True,
23+
ondelete="cascade",
24+
index=True,
25+
)
26+
name = fields.Char(
27+
string="Data Type",
28+
required=True,
29+
help="TipoDato: Type of additional data (max 10 characters)",
30+
)
31+
text_ref = fields.Char(
32+
string="Text Reference",
33+
help="RiferimentoTesto: Text reference (max 60 characters)",
34+
)
35+
num_ref = fields.Float(
36+
string="Number Reference",
37+
digits=(16, 8),
38+
help="RiferimentoNumero: Numeric reference (up to 8 decimal places)",
39+
)
40+
date_ref = fields.Date(
41+
string="Date Reference",
42+
help="RiferimentoData: Date reference",
43+
)
44+
45+
@api.depends("name", "text_ref", "num_ref", "date_ref")
46+
def _compute_display_name(self):
47+
for record in self:
48+
parts = [record.name]
49+
if record.text_ref:
50+
parts.append(record.text_ref)
51+
if record.num_ref:
52+
parts.append(str(record.num_ref))
53+
if record.date_ref:
54+
parts.append(str(record.date_ref))
55+
record.display_name = ": ".join(parts)
56+
57+
@api.constrains("name")
58+
def _check_name_length(self):
59+
for record in self:
60+
if record.name and len(record.name) > 10:
61+
raise ValidationError(
62+
_("Data Type (TipoDato) must not exceed 10 characters.")
63+
)
64+
65+
@api.constrains("text_ref")
66+
def _check_text_ref_length(self):
67+
for record in self:
68+
if record.text_ref and len(record.text_ref) > 60:
69+
raise ValidationError(
70+
_(
71+
"Text Reference (RiferimentoTesto) "
72+
"must not exceed 60 characters."
73+
)
74+
)
75+
76+
@api.constrains("name", "text_ref", "num_ref", "date_ref")
77+
def _check_at_least_one_ref(self):
78+
for record in self:
79+
has_text = bool(record.text_ref)
80+
# For Float fields, check if value was explicitly set (not default 0.0)
81+
has_num = bool(record.num_ref)
82+
has_date = bool(record.date_ref)
83+
if not has_text and not has_num and not has_date:
84+
raise ValidationError(
85+
_(
86+
"At least one of Text Reference, Number Reference, "
87+
"or Date Reference must be provided."
88+
)
89+
)

l10n_it_edi_extension/readme/DESCRIPTION.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ Le funzionalità principali incluse sono:
1515
- `<StabileOrganizzazione>`: rappresenta i dati della sede operativa stabile del cedente/prestatore in Italia se diversa dalla sede legale. Da impostare in odoo nell'azienda, tab "Informazioni Generali"
1616
- `<Causale>`: in questo caso non c'è un campo apposito, ma trascrive i "Termini e condizioni" della fattura
1717
- `<Art73>`: indica se il documento è stato emesso secondo modalità e termini stabiliti con decreto ministeriale ai sensi dell'articolo 73 del DPR 633/72. Da impostare in odoo nell'azienda o direttamente in fattura.
18+
- `<AltriDatiGestionali>` (2.2.1.16): dati gestionali aggiuntivi che possono essere inseriti manualmente su ogni riga fattura ed esportati nel file XML FatturaPA. Ogni voce include:
19+
- `<TipoDato>`: tipo di dato (max 10 caratteri, obbligatorio)
20+
- `<RiferimentoTesto>`: riferimento testuale (max 60 caratteri)
21+
- `<RiferimentoNumero>`: riferimento numerico (fino a 8 decimali)
22+
- `<RiferimentoData>`: riferimento data
23+
- Per aggiungere questi dati, aprire la riga fattura e compilare la sezione "Altri Dati Gestionali".
1824
- `<IndirizzoResa>`: rappresenta l'indirizzo di consegna della merce.
1925

2026
3. Miglioramenti nell'import delle fatture XML:
@@ -97,6 +103,12 @@ The main features included are:
97103
- `<StabileOrganizzazione>`: represents the data of the seller/provider's permanent establishment in Italy if different from the registered office
98104
- `<Causale>`: in this case there is no specific field, but it transcribes the "Terms and conditions" of the invoice.
99105
- `<Art73>`: indicates if the document was issued according to methods and terms established by ministerial decree pursuant to article 73 of DPR 633/72
106+
- `<AltriDatiGestionali>` (2.2.1.16): additional management data that can be manually entered on each invoice line and exported to the FatturaPA XML file. Each entry includes:
107+
- `<TipoDato>`: data type (max 10 characters, required)
108+
- `<RiferimentoTesto>`: text reference (max 60 characters)
109+
- `<RiferimentoNumero>`: numeric reference (up to 8 decimal places)
110+
- `<RiferimentoData>`: date reference
111+
- To add this data, open the invoice line and fill in the "Other Management Data" section.
100112
- `<IndirizzoResa>`: represents the shipping address of the goods.
101113

102114
3. Improvements in XML invoice import:

l10n_it_edi_extension/security/ir.model.access.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ access_l10n_it_edi_line_other_data,access_l10n_it_edi_line_other_data,l10n_it_ed
99
access_l10n_it_edi_activity_progress,access_l10n_it_edi_activity_progress,l10n_it_edi_extension.model_l10n_it_edi_activity_progress,account.group_account_invoice,1,1,1,1
1010
access_l10n_it_edi_summary_data,access_l10n_it_edi_summary_data,l10n_it_edi_extension.model_l10n_it_edi_summary_data,account.group_account_invoice,1,1,1,1
1111
access_l10n_it_edi_line,access_l10n_it_edi_line,l10n_it_edi_extension.model_l10n_it_edi_line,account.group_account_invoice,1,1,1,1
12+
access_l10n_it_edi_move_line_other_data,access_l10n_it_edi_move_line_other_data,l10n_it_edi_extension.model_l10n_it_edi_move_line_other_data,account.group_account_invoice,1,1,1,1
1213
access_l10n_it_edi_import_file_wizard,access_l10n_it_edi_import_file_wizard,l10n_it_edi_extension.model_l10n_it_edi_import_file_wizard,account.group_account_invoice,1,1,1,1
1314
access_wizard_compute_fc_group_all,wizard_compute_fc group_user_all,l10n_it_edi_extension.model_wizard_compute_fc,base.group_user,1,0,0,0
1415
access_wizard_compute_fc_group_user,wizard_compute_fc group_user,l10n_it_edi_extension.model_wizard_compute_fc,base.group_partner_manager,1,1,1,1

0 commit comments

Comments
 (0)