diff --git a/l10n_it_fatturapa_out_rc/views/invoice_it_template.xml b/l10n_it_fatturapa_out_rc/views/invoice_it_template.xml
index f598caf3a1f5..e9c4dccb7710 100644
--- a/l10n_it_fatturapa_out_rc/views/invoice_it_template.xml
+++ b/l10n_it_fatturapa_out_rc/views/invoice_it_template.xml
@@ -50,22 +50,20 @@
t-esc="record.fiscal_document_type_id.code"
/>
-
-
-
+
+
@@ -86,7 +84,7 @@
diff --git a/l10n_it_fatturapa_out_rc/wizard/efattura.py b/l10n_it_fatturapa_out_rc/wizard/efattura.py
index f4d24d56a9dd..77fa143a106e 100644
--- a/l10n_it_fatturapa_out_rc/wizard/efattura.py
+++ b/l10n_it_fatturapa_out_rc/wizard/efattura.py
@@ -6,17 +6,10 @@
)
+# extend the EFatturaOut class to add a new helper function
class EFatturaOut(_EFatturaOut):
def get_template_values(self):
- def get_sign(invoice):
- sign = 1
- if invoice.move_type in [
- "out_refund",
- "in_refund",
- ] and invoice.fiscal_document_type_id.code not in ["TD04", "TD08"]:
- sign = -1
- return sign
-
+ get_sign = self.env["wizard.export.fatturapa"].getSign
template_values = super().get_template_values()
template_values.update({"get_sign": get_sign})
return template_values
diff --git a/l10n_it_fatturapa_out_rc/wizard/wizard_export_fatturapa.py b/l10n_it_fatturapa_out_rc/wizard/wizard_export_fatturapa.py
index 0b6c85346375..27451866b7d6 100644
--- a/l10n_it_fatturapa_out_rc/wizard/wizard_export_fatturapa.py
+++ b/l10n_it_fatturapa_out_rc/wizard/wizard_export_fatturapa.py
@@ -1,7 +1,7 @@
# Copyright 2021 Alex Comba - Agile Business Group
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from odoo import models
+from odoo import api, models
from .efattura import EFatturaOut
@@ -9,5 +9,22 @@
class WizardExportFatturapa(models.TransientModel):
_inherit = "wizard.export.fatturapa"
+ @api.model
def _get_efattura_class(self):
return EFatturaOut
+
+ @api.model
+ def getSign(self, invoice):
+ sign = 1
+ if invoice.move_type in [
+ "out_refund",
+ "in_refund",
+ ] and invoice.fiscal_document_type_id.code not in ["TD04", "TD08"]:
+ sign = -1
+ return sign
+
+ @api.model
+ def getImportoTotale(self, invoice):
+ amount_total = super().getImportoTotale(invoice)
+ amount_total *= self.getSign(invoice)
+ return amount_total