Skip to content

Commit bdcf23f

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

19 files changed

+1113
-0
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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.
37+
38+
**Italiano**
39+
40+
Modulo per la gestione dei tipi di documenti collegati alle fatture. I
41+
dati relativi ai documenti collegati vengono poi esportati nell'XML
42+
della fattura elettronica oppure importati durante la creazione di una
43+
fattura da XML.
44+
45+
**Table of contents**
46+
47+
.. contents::
48+
:local:
49+
50+
Configuration
51+
=============
52+
53+
54+
55+
Bug Tracker
56+
===========
57+
58+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-italy/issues>`_.
59+
In case of trouble, please check there if your issue has already been reported.
60+
If you spotted it first, help us to smash it by providing a detailed and welcomed
61+
`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**>`_.
62+
63+
Do not contact contributors directly about support or help with technical issues.
64+
65+
Credits
66+
=======
67+
68+
Authors
69+
-------
70+
71+
* Nextev Srl
72+
73+
Contributors
74+
------------
75+
76+
- Nextev Srl <[email protected]>
77+
78+
Maintainers
79+
-----------
80+
81+
This module is maintained by the OCA.
82+
83+
.. image:: https://odoo-community.org/logo.png
84+
:alt: Odoo Community Association
85+
:target: https://odoo-community.org
86+
87+
OCA, or the Odoo Community Association, is a nonprofit organization whose
88+
mission is to support the collaborative development of Odoo features and
89+
promote its widespread use.
90+
91+
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.
92+
93+
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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
2+
3+
from . import account_move
4+
from . import account_move_line
5+
# from . import company
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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_line_id = fields.Many2one(
32+
"account.move.line",
33+
"Related Invoice Line",
34+
ondelete="cascade",
35+
index=True,
36+
readonly=True,
37+
)
38+
invoice_id = fields.Many2one(
39+
"account.move",
40+
"Related Invoice",
41+
ondelete="cascade",
42+
index=True,
43+
readonly=True,
44+
)
45+
date = fields.Date()
46+
numitem = fields.Char("Item Num.", size=20)
47+
code = fields.Char("Order Agreement Code", size=100)
48+
cig = fields.Char("CIG Code", size=15)
49+
cup = fields.Char("CUP Code", size=15)
50+
51+
# @api.model_create_multi
52+
# def create(self, vals_list):
53+
# line_obj = self.env["account.move.line"]
54+
# for vals in vals_list:
55+
# if vals.get("invoice_line_id"):
56+
# line = line_obj.browse(vals["invoice_line_id"])
57+
# vals["lineRef"] = line.sequence
58+
# return super().create(vals_list)
59+
60+
# def setlineRef(self, n):
61+
# self.lineRef = n
62+
63+
64+
class AccountMove(models.Model):
65+
# _position = ['2.1', '2.2', '2.3', '2.4', '2.5']
66+
_inherit = "account.move"
67+
68+
related_documents = fields.One2many(
69+
"account.move.related_document_type", "invoice_id", copy=False
70+
)
71+
72+
def _l10n_it_edi_get_values(self, pdf_values=None):
73+
res = super()._l10n_it_edi_get_values(pdf_values=pdf_values)
74+
res["related_documents"] = self.related_documents
75+
return res
76+
77+
def _l10n_it_edi_import_invoice(self, invoice, data, is_new):
78+
res = super()._l10n_it_edi_import_invoice(invoice, data, is_new)
79+
tree = data["xml_tree"]
80+
rel_docs_dict = {
81+
# 2.1.2
82+
"order": tree.xpath(".//DatiOrdineAcquisto"),
83+
# 2.1.3
84+
"contract": tree.xpath(".//DatiContratto"),
85+
# 2.1.4
86+
"agreement": tree.xpath(".//DatiConvenzione"),
87+
# 2.1.5
88+
"reception": tree.xpath(".//DatiRicezione"),
89+
# 2.1.6
90+
"invoice": tree.xpath(".//DatiFattureCollegate"),
91+
}
92+
self.create_related_document_types(invoice, rel_docs_dict)
93+
return res
94+
95+
def create_related_document_types(self, invoice, rel_docs_dict):
96+
result = []
97+
for key, rel_doc in rel_docs_dict.items():
98+
for element in rel_doc:
99+
entry = {
100+
"type": key,
101+
"lineRef": get_text(element, "./RiferimentoNumeroLinea"),
102+
"name": get_text(element, "./IdDocumento"),
103+
"date": get_text(element, "./Data"),
104+
"numitem": get_text(element, "./NumItem"),
105+
"code": get_text(element, "./CodiceCommessaConvenzione"),
106+
"cup": get_text(element, "./CodiceCUP"),
107+
"cig": get_text(element, "./CodiceCIG"),
108+
"invoice_id": invoice.id,
109+
}
110+
entry = {k: v for k, v in entry.items() if v}
111+
result.append(entry)
112+
model = self.env["account.move.related_document_type"]
113+
model.create(result)
114+
return result
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from odoo import fields, models
2+
3+
4+
class AccountInvoiceLine(models.Model):
5+
# _position = ['2.2.1']
6+
_inherit = "account.move.line"
7+
8+
related_documents = fields.One2many(
9+
"account.move.related_document_type",
10+
"invoice_line_id",
11+
"Related Documents Type",
12+
copy=False,
13+
)
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"

l10n_it_edi_related_document_type/readme/CONFIGURE.md

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Nextev Srl \<<[email protected]>\>

0 commit comments

Comments
 (0)