[IMP] l10n_it_edi_pa: adapt to account_edi removal changes

closes odoo/odoo#122194

Related: odoo/upgrade#4893
Signed-off-by: Josse Colpaert <jco@odoo.com>
This commit is contained in:
Josse Colpaert
2023-09-19 16:37:09 +00:00
committed by Paolo Gatti (pgi)
parent c02d8b177f
commit edca41774a
5 changed files with 15 additions and 40 deletions
@@ -6,6 +6,7 @@
<IdPaese>IT</IdPaese>
<IdCodice>01234560157</IdCodice>
</IdTrasmittente>
<ProgressivoInvio>___ignore___</ProgressivoInvio>
<FormatoTrasmissione>FPA12</FormatoTrasmissione>
<CodiceDestinatario>123456</CodiceDestinatario>
<ContattiTrasmittente>
-1
View File
@@ -1,4 +1,3 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import account_move
from . import account_edi_format
@@ -1,17 +0,0 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import _, fields, models
class AccountEdiFormat(models.Model):
_inherit = 'account.edi.format'
def _l10n_it_edi_check_ordinary_invoice_configuration(self, invoice):
errors = super()._l10n_it_edi_check_ordinary_invoice_configuration(invoice)
if invoice._is_commercial_partner_pa():
if not invoice.l10n_it_origin_document_type:
errors.append(_("This invoice targets the Public Administration, please fill out"
" Origin Document Type field in the Electronic Invoicing tab."))
if invoice.l10n_it_origin_document_date and invoice.l10n_it_origin_document_date > fields.Date.today():
errors.append(_("The Origin Document Date cannot be in the future."))
return errors
+13 -3
View File
@@ -1,6 +1,6 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
from odoo import api, fields, models, _
class AccountMove(models.Model):
@@ -33,9 +33,9 @@ class AccountMove(models.Model):
move.l10n_it_partner_pa = (move.country_code == 'IT' and move.commercial_partner_id.l10n_it_pa_index and
len(move.commercial_partner_id.l10n_it_pa_index) == 6)
def _prepare_fatturapa_export_values(self):
def _l10n_it_edi_get_values(self, pdf_values=None):
"""Add origin document features."""
template_values = super()._prepare_fatturapa_export_values()
template_values = super()._l10n_it_edi_get_values(pdf_values=pdf_values)
template_values.update({
'origin_document_type': self.l10n_it_origin_document_type,
'origin_document_name': self.l10n_it_origin_document_name,
@@ -44,3 +44,13 @@ class AccountMove(models.Model):
'cup': self.l10n_it_cup,
})
return template_values
def _l10n_it_edi_base_export_data_check(self):
errors = super()._l10n_it_edi_base_export_data_check()
if self.l10n_it_partner_pa:
if not self.l10n_it_origin_document_type:
errors.append(_("This invoice targets the Public Administration, please fill out"
" Origin Document Type field in the Electronic Invoicing tab."))
if self.l10n_it_origin_document_date and self.l10n_it_origin_document_date > fields.Date.today():
errors.append(_("The Origin Document Date cannot be in the future."))
return errors
+1 -19
View File
@@ -43,30 +43,12 @@ class TestItEdiPa(TestItEdi):
'l10n_it_origin_document_type': False,
})
cls.pa_partner_invoice._post()
cls.split_payment_invoice_content = cls._get_test_file_content('split_payment.xml')
@classmethod
def _get_test_file_content(cls, filename):
""" Get the content of a test file inside this module """
path = 'l10n_it_edi/tests/export_xmls/' + filename
with tools.file_open(path, mode='rb') as test_file:
return test_file.read()
def test_send_pa_partner(self):
res = self.edi_format._l10n_it_post_invoices_step_1(self.pa_partner_invoice)
self.assertEqual(res[self.pa_partner_invoice], {'attachment': self.pa_partner_invoice.l10n_it_edi_attachment_id, 'success': True})
def test_send_pa_partner_missing_field(self):
with self.assertRaises(UserError):
self.pa_partner_invoice_2._post()
def test_split_payment(self):
""" ImportoTotaleDocumento must include VAT
ImportoPagamento must be without VAT
EsigibilitaIva of the Split payment tax must be 'S'
The orgin_document fields must appear in the XML.
Use reference validator: https://fex-app.com/servizi/inizia
"""
invoice_etree = self._cleanup_etree(self.edi_format._l10n_it_edi_export_invoice_as_xml(self.pa_partner_invoice))
expected_etree = etree.fromstring(self.split_payment_invoice_content)
self.assertXmlTreeEqual(invoice_etree, expected_etree)
self._assert_export_invoice(self.pa_partner_invoice, 'split_payment.xml')