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 18, 2024
1 parent 0166d31 commit 4bc5795
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions l10n_it_edi_extension/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 4bc5795

Please sign in to comment.