Skip to content

Commit 0e22e76

Browse files
committed
[ADD]l10n_it_edi_related_document_type: related invoice documen management
1 parent f0ff810 commit 0e22e76

17 files changed

+1043
-0
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
=============================
2+
Related Document Type for EDI
3+
=============================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:03af5c30726a2eeb63eafaf004b914ef4148d1bb103b8b7d5a32bfb7fe8e186f
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github
20+
:target: https://github.com/OCA/l10n-italy/tree/18.0/l10n_it_edi_related_document_type
21+
:alt: OCA/l10n-italy
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/l10n-italy-18-0/l10n-italy-18-0-l10n_it_edi_related_document_type
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-italy&target_branch=18.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
**English**
32+
33+
Module for managing the types of documents linked to invoices. The data
34+
related to the linked documents is then exported in the electronic
35+
invoice XML or imported during the creation of an invoice from an XML
36+
file. If a related document has 0 as the line reference, it means that
37+
it refers to the entire document and not to a specific invoice line.
38+
39+
**Italiano**
40+
41+
Modulo per la gestione dei tipi di documenti collegati alle fatture. I
42+
dati relativi ai documenti collegati vengono poi esportati nell'XML
43+
della fattura elettronica oppure importati durante la creazione di una
44+
fattura da XML. Nel caso in cui un documento collegato abbia 0 come
45+
riferimento linea, significa che è riferito all’intero documento e non
46+
ad una specifica linea della fattura.
47+
48+
**Table of contents**
49+
50+
.. contents::
51+
:local:
52+
53+
Bug Tracker
54+
===========
55+
56+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-italy/issues>`_.
57+
In case of trouble, please check there if your issue has already been reported.
58+
If you spotted it first, help us to smash it by providing a detailed and welcomed
59+
`feedback <https://github.com/OCA/l10n-italy/issues/new?body=module:%20l10n_it_edi_related_document_type%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
60+
61+
Do not contact contributors directly about support or help with technical issues.
62+
63+
Credits
64+
=======
65+
66+
Authors
67+
-------
68+
69+
* Nextev Srl
70+
71+
Contributors
72+
------------
73+
74+
- Nextev Srl <odoo@nextev.it>
75+
76+
Maintainers
77+
-----------
78+
79+
This module is maintained by the OCA.
80+
81+
.. image:: https://odoo-community.org/logo.png
82+
:alt: Odoo Community Association
83+
:target: https://odoo-community.org
84+
85+
OCA, or the Odoo Community Association, is a nonprofit organization whose
86+
mission is to support the collaborative development of Odoo features and
87+
promote its widespread use.
88+
89+
This module is part of the `OCA/l10n-italy <https://github.com/OCA/l10n-italy/tree/18.0/l10n_it_edi_related_document_type>`_ project on GitHub.
90+
91+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
2+
3+
from . import models
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2025 Nextev Srl
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
{
5+
"name": "Related Document Type for EDI",
6+
"version": "18.0.1.0.0",
7+
"category": "Localization/Italy",
8+
"author": "Nextev Srl, Odoo Community Association (OCA)",
9+
"website": "https://github.com/OCA/l10n-italy",
10+
"license": "AGPL-3",
11+
"depends": ["l10n_it_edi"],
12+
"data": [
13+
"views/related_document_type_views.xml",
14+
"views/l10n_it_views.xml",
15+
"views/account_move_related_documents.xml",
16+
"data/invoice_it_template.xml",
17+
"security/ir.model.access.csv",
18+
],
19+
"installable": True,
20+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo>
3+
<template
4+
id="account_invoice_it_FatturaPA_export_inherit"
5+
inherit_id="l10n_it_edi.account_invoice_it_FatturaPA_export"
6+
>
7+
<xpath expr="//DatiGeneraliDocumento" position="after">
8+
<t
9+
t-call="l10n_it_edi_related_document_type.account_invoice_it_dati_documenti_correlati"
10+
/>
11+
</xpath>
12+
</template>
13+
</odoo>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
2+
3+
from . import account_move
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
from odoo import fields, models
2+
3+
from odoo.addons.l10n_it_edi.models.account_move import get_text
4+
5+
RELATED_DOCUMENT_TYPES = {
6+
"order": "DatiOrdineAcquisto",
7+
"contract": "DatiContratto",
8+
"agreement": "DatiConvenzione",
9+
"reception": "DatiRicezione",
10+
"invoice": "DatiFattureCollegate",
11+
}
12+
13+
14+
class AccountMoveRelatedDocumentType(models.Model):
15+
_name = "account.move.related_document_type"
16+
_description = "E-invoice Related Document Type"
17+
18+
type = fields.Selection(
19+
[
20+
("order", "Order"),
21+
("contract", "Contract"),
22+
("agreement", "Agreement"),
23+
("reception", "Reception"),
24+
("invoice", "Related Invoice"),
25+
],
26+
"Document Type",
27+
required=True,
28+
)
29+
name = fields.Char("Document ID", size=20, required=True)
30+
lineRef = fields.Integer("Line Ref.")
31+
invoice_id = fields.Many2one(
32+
"account.move",
33+
"Related Invoice",
34+
ondelete="cascade",
35+
index=True,
36+
readonly=True,
37+
)
38+
date = fields.Date()
39+
numitem = fields.Char("Item Num.", size=20)
40+
code = fields.Char("Order Agreement Code", size=100)
41+
cig = fields.Char("CIG Code", size=15)
42+
cup = fields.Char("CUP Code", size=15)
43+
44+
45+
class AccountMove(models.Model):
46+
_inherit = "account.move"
47+
48+
related_document_ids = fields.One2many(
49+
"account.move.related_document_type", "invoice_id", copy=False
50+
)
51+
52+
def _l10n_it_edi_get_values(self, pdf_values=None):
53+
res = super()._l10n_it_edi_get_values(pdf_values=pdf_values)
54+
res["related_document_ids"] = self.related_document_ids
55+
return res
56+
57+
def _l10n_it_edi_import_invoice(self, invoice, data, is_new):
58+
res = super()._l10n_it_edi_import_invoice(invoice, data, is_new)
59+
tree = data["xml_tree"]
60+
rel_docs_dict = {
61+
"order": tree.xpath(".//DatiOrdineAcquisto"),
62+
"contract": tree.xpath(".//DatiContratto"),
63+
"agreement": tree.xpath(".//DatiConvenzione"),
64+
"reception": tree.xpath(".//DatiRicezione"),
65+
"invoice": tree.xpath(".//DatiFattureCollegate"),
66+
}
67+
self.create_related_document_types(invoice, rel_docs_dict)
68+
return res
69+
70+
def create_related_document_types(self, invoice, rel_docs_dict):
71+
result = []
72+
for key, rel_doc in rel_docs_dict.items():
73+
for element in rel_doc:
74+
entry = {
75+
"type": key,
76+
"lineRef": get_text(element, "./RiferimentoNumeroLinea"),
77+
"name": get_text(element, "./IdDocumento"),
78+
"date": get_text(element, "./Data"),
79+
"numitem": get_text(element, "./NumItem"),
80+
"code": get_text(element, "./CodiceCommessaConvenzione"),
81+
"cup": get_text(element, "./CodiceCUP"),
82+
"cig": get_text(element, "./CodiceCIG"),
83+
"invoice_id": invoice.id,
84+
}
85+
entry = {k: v for k, v in entry.items() if v}
86+
result.append(entry)
87+
model = self.env["account.move.related_document_type"]
88+
model.create(result)
89+
return result
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Nextev Srl \<<odoo@nextev.it>\>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
**English**
2+
3+
Module for managing the types of documents linked to invoices.
4+
The data related to the linked documents is then exported in
5+
the electronic invoice XML or imported during the creation of
6+
an invoice from an XML file.
7+
If a related document has 0 as the line reference, it means that
8+
it refers to the entire document and not to a specific
9+
invoice line.
10+
11+
**Italiano**
12+
13+
Modulo per la gestione dei tipi di documenti collegati alle fatture.
14+
I dati relativi ai documenti collegati vengono poi esportati nell'XML
15+
della fattura elettronica oppure importati durante la creazione di una
16+
fattura da XML.
17+
Nel caso in cui un documento collegato abbia 0 come riferimento linea,
18+
significa che è riferito all’intero documento e non ad una specifica
19+
linea della fattura.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
2+
l10n_it_edi_related_document_type.access_account_move_related_document_type,access_account_move_related_document_type,l10n_it_edi_related_document_type.model_account_move_related_document_type,account.group_account_invoice,1,1,1,1

0 commit comments

Comments
 (0)