Skip to content

Commit

Permalink
[ADD] l10n_it_edi_extension: adding tag Causale in xml
Browse files Browse the repository at this point in the history
  • Loading branch information
Borruso committed Oct 2, 2024
1 parent 054b3e5 commit d130bad
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
3 changes: 2 additions & 1 deletion l10n_it_edi_extension/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "Italy - E-invoicing - Base Feature",
"version": "17.5.1.0.0",
"version": "18.0.1.0.0",
"category": "Accounting/Localizations/EDI",
"development_status": "Production/Stable",
"summary": "E-invoice base feature",
Expand All @@ -14,6 +14,7 @@
"l10n_it_edi",
],
"data": [
"data/invoice_it_template.xml",
"views/l10n_it_view.xml",
],
"installable": True,
Expand Down
11 changes: 11 additions & 0 deletions l10n_it_edi_extension/data/invoice_it_template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<template id="account_invoice_it_FatturaPA_export_causale" inherit_id="l10n_it_edi.account_invoice_it_FatturaPA_export">
<xpath expr="//DatiGeneraliDocumento/ImportoTotaleDocumento" position="after">
<t t-foreach="causale" t-as="c">
<Causale t-out="c" />
</t>
</xpath>
</template>
</odoo>
30 changes: 30 additions & 0 deletions l10n_it_edi_extension/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models
from odoo.tools import html2plaintext


class AccountMoveInherit(models.Model):
Expand Down Expand Up @@ -40,3 +41,32 @@ def action_l10n_it_edi_attachment_preview(self):
"url": self.l10n_it_edi_attachment_preview_link,
"target": "new",
}

# -------------------------------------------------------------------------
# Helpers
# -------------------------------------------------------------------------

def _l10n_it_edi_get_values(self, pdf_values=None):
res = super()._l10n_it_edi_get_values(pdf_values)

causale_list = []
if self.narration:

try:
narration_text = html2plaintext(self.narration)
except Exception:
narration_text = ""

# max length of Causale is 200
for causale in narration_text.split("\n"):
if not causale:
continue
causale_list_200 = [
causale[i : i + 200] for i in range(0, len(causale), 200)
]
for causale200 in causale_list_200:
causale_list.append(causale200)

res["causale"] = causale_list

return res

0 comments on commit d130bad

Please sign in to comment.