[IMP] l10n_it_edi_pa: Split Payment

New module is created (`l10n_it_edi_pa`) to add fields that are required to handle Split Payment, and it will be merged in master.

- `l10n_it_origin_document_type`
- `l10n_it_origin_document_date`
- `l10n_it_origin_document_name`
- `l10n_it_cup`
- `l10n_it_cig`

These fields are required to track money used that comes from funding to the Public Administration business for purchases, be it ordinary or project based spending.
They also need to be exported in XML during the EDI phase, in different
XML nodes depending on the `l10n_it_origin_document_type` field

ref: https://fex-app.com/FatturaElettronica/FatturaElettronicaBody/DatiGenerali/DatiOrdineAcquisto
Task link: https://www.odoo.com/web#id=2823645&model=project.task
task-2823645

X-original-commit: e07fb2503f28af1f23ef74efec6741f9623ce401
Part-of: odoo/odoo#134348
This commit is contained in:
Paolo Gatti (pgi)
2023-09-06 11:51:00 +00:00
committed by Josse Colpaert
parent 733abedc18
commit 2dc1612ddc
13 changed files with 566 additions and 3 deletions
@@ -140,11 +140,11 @@
</DatiBollo>
<ImportoTotaleDocumento t-out="format_monetary(document_total, currency)"/>
</DatiGeneraliDocumento>
<DatiOrdineAcquisto t-if="record.ref and not record.reversed_entry_id">
<IdDocumento t-out="format_alphanumeric(record.ref, 20)"/>
<DatiOrdineAcquisto t-if="origin_document_type == 'purchase_order'">
<t t-call="l10n_it_edi.account_invoice_FatturaPA_origin_document"/>
</DatiOrdineAcquisto>
<DatiOrdineAcquisto t-elif="record.ref and not record.reversed_entry_id">
<IdDocumento t-out="format_alphanumeric(record.ref; 20)"/>
<IdDocumento t-out="format_alphanumeric(record.ref, 20)"/>
</DatiOrdineAcquisto>
<DatiContratto t-if="origin_document_type == 'contract'">
<t t-call="l10n_it_edi.account_invoice_FatturaPA_origin_document"/>
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="utf-8"?>
<p:FatturaElettronica xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xsi:schemaLocation="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2 http://www.fatturapa.gov.it/export/fatturazione/sdi/fatturapa/v1.2/Schema_del_file_xml_FatturaPA_versione_1.2.xsd" versione="FPA12">
<FatturaElettronicaHeader>
<DatiTrasmissione>
<IdTrasmittente>
<IdPaese>IT</IdPaese>
<IdCodice>01234560157</IdCodice>
</IdTrasmittente>
<FormatoTrasmissione>FPA12</FormatoTrasmissione>
<CodiceDestinatario>123456</CodiceDestinatario>
<ContattiTrasmittente>
<Telefono>0266766700</Telefono>
<Email>test@test.it</Email>
</ContattiTrasmittente>
</DatiTrasmissione>
<CedentePrestatore>
<DatiAnagrafici>
<IdFiscaleIVA>
<IdPaese>IT</IdPaese>
<IdCodice>01234560157</IdCodice>
</IdFiscaleIVA>
<CodiceFiscale>01234560157</CodiceFiscale>
<Anagrafica>
<Denominazione>company_2_data</Denominazione>
</Anagrafica>
<RegimeFiscale>RF01</RegimeFiscale>
</DatiAnagrafici>
<Sede>
<Indirizzo>1234 Test Street </Indirizzo>
<CAP>12345</CAP>
<Comune>Prova</Comune>
<Nazione>IT</Nazione>
</Sede>
</CedentePrestatore>
<CessionarioCommittente>
<DatiAnagrafici>
<IdFiscaleIVA>
<IdPaese>IT</IdPaese>
<IdCodice>06655971007</IdCodice>
</IdFiscaleIVA>
<CodiceFiscale>06655971007</CodiceFiscale>
<Anagrafica>
<Denominazione>pa partner</Denominazione>
</Anagrafica>
</DatiAnagrafici>
<Sede>
<Indirizzo>Via Test PA </Indirizzo>
<CAP>32121</CAP>
<Comune>PA Town</Comune>
<Nazione>IT</Nazione>
</Sede>
</CessionarioCommittente>
</FatturaElettronicaHeader>
<FatturaElettronicaBody>
<DatiGenerali>
<DatiGeneraliDocumento>
<TipoDocumento>TD01</TipoDocumento>
<Divisa>EUR</Divisa>
<Data>2022-03-24</Data>
<Numero>INV/2022/00001</Numero>
<ImportoTotaleDocumento>976.49</ImportoTotaleDocumento>
</DatiGeneraliDocumento>
<DatiOrdineAcquisto>
<IdDocumento>INV/2022/0001</IdDocumento>
<Data>2022-03-23</Data>
<CodiceCUP>0123456789</CodiceCUP>
<CodiceCIG>0987654321</CodiceCIG>
</DatiOrdineAcquisto>
</DatiGenerali>
<DatiBeniServizi>
<DettaglioLinee>
<NumeroLinea>1</NumeroLinea>
<Descrizione>standard_line</Descrizione>
<Quantita>1.00</Quantita>
<PrezzoUnitario>800.400000</PrezzoUnitario>
<PrezzoTotale>800.40</PrezzoTotale>
<AliquotaIVA>22.00</AliquotaIVA>
</DettaglioLinee>
<DatiRiepilogo>
<AliquotaIVA>22.00</AliquotaIVA>
<ImponibileImporto>800.40</ImponibileImporto>
<Imposta>176.09</Imposta>
<EsigibilitaIVA>S</EsigibilitaIVA>
</DatiRiepilogo>
</DatiBeniServizi>
<DatiPagamento>
<CondizioniPagamento>TP02</CondizioniPagamento>
<DettaglioPagamento>
<ModalitaPagamento>MP05</ModalitaPagamento>
<DataScadenzaPagamento>2022-03-24</DataScadenzaPagamento>
<ImportoPagamento>800.40</ImportoPagamento>
<CodicePagamento>___ignore___</CodicePagamento>
</DettaglioPagamento>
</DatiPagamento>
</FatturaElettronicaBody>
</p:FatturaElettronica>
+3
View File
@@ -0,0 +1,3 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import models
+28
View File
@@ -0,0 +1,28 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': 'Italy - E-invoicing (PA)',
'version': '0.1',
'depends': [
'l10n_it_edi'
],
'auto_install': ['l10n_it_edi'],
'author': 'Odoo',
'description': """
Public Administration partners flow handling for the E-invoice implementation for Italy.
Several more fields are required for invoicing Public Administration businesses.
The Origin Document is to be exported in the XML when invoicing the Public Administration,
It can be a Contract, an Agreement, a Purchase Order, a Linked Invoice or a Down Payment,
it will need the CIG and CUP fields which are mandatory.
They both serve the purpose to trace public funds being invested on purchases.
CIG is the Tender Unique Identifier, CUP identifies the Public Project of Investment.
""",
'category': 'Accounting/Localizations/EDI',
'website': 'https://www.odoo.com/documentation/16.0/applications/finance/accounting/fiscal_localizations/localizations/italy.html',
'data': [
'views/account_move_view.xml',
'views/report_invoice.xml',
],
'license': 'LGPL-3',
}
+130
View File
@@ -0,0 +1,130 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * l10n_it_edi_pa
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-08-19 00:02+0000\n"
"PO-Revision-Date: 2023-08-19 00:02+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: l10n_it_edi_pa
#: model:ir.model.fields.selection,name:l10n_it_edi_pa.selection__account_move__l10n_it_origin_document_type__agreement
msgid "Agreement"
msgstr "Convenzione"
#. module: l10n_it_edi_pa
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_cig
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_move__l10n_it_cig
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_payment__l10n_it_cig
msgid "CIG"
msgstr ""
#. module: l10n_it_edi_pa
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_cup
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_move__l10n_it_cup
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_payment__l10n_it_cup
msgid "CUP"
msgstr ""
#. module: l10n_it_edi_pa
#: model:ir.model.fields.selection,name:l10n_it_edi_pa.selection__account_move__l10n_it_origin_document_type__contract
msgid "Contract"
msgstr "Contratto"
#. module: l10n_it_edi_pa
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_partner_pa_index
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_move__l10n_it_partner_pa_index
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_payment__l10n_it_partner_pa_index
msgid "Destination Code"
msgstr "Codice Destinatario"
#. module: l10n_it_edi_pa
#: model:ir.model,name:l10n_it_edi_pa.model_account_edi_format
msgid "EDI format"
msgstr "Formato EDI"
#. module: l10n_it_edi_pa
#: model:ir.model,name:l10n_it_edi_pa.model_account_move
msgid "Journal Entry"
msgstr "Movimento Contabile"
#. module: l10n_it_edi_pa
#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_partner_pa_index
#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_move__l10n_it_partner_pa_index
#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_payment__l10n_it_partner_pa_index
msgid ""
"Must contain the 6-character (or 7) code, present in the PA "
"Index in the information relative to the electronic invoicing service,"
" associated with the office which, within the addressee "
"administration, deals with receiving (and processing) the "
"invoice."
msgstr "Deve contenere il codice da 6-7 caratteri presente nell'indice della PA "
"nelle informazioni relative al servizio di Fatturazione Elettronica, "
"associato all'ufficio dell'amministrazione che riceverá (ed elaborerá) la Fattura."
#. module: l10n_it_edi_pa
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_origin_document_date
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_move__l10n_it_origin_document_date
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_payment__l10n_it_origin_document_date
msgid "Origin Document Date"
msgstr "Data Documento Origine"
#. module: l10n_it_edi_pa
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_origin_document_name
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_move__l10n_it_origin_document_name
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_payment__l10n_it_origin_document_name
msgid "Origin Document Name"
msgstr "Nome Documento Origine"
#. module: l10n_it_edi_pa
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_origin_document_type
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_move__l10n_it_origin_document_type
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_payment__l10n_it_origin_document_type
msgid "Origin Document Type"
msgstr "Tipo Documento Origine"
#. module: l10n_it_edi_pa
#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_cup
#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_move__l10n_it_cup
#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_payment__l10n_it_cup
msgid "Public Investment Unique Identifier"
msgstr "CUP"
#. module: l10n_it_edi_pa
#: model:ir.model.fields.selection,name:l10n_it_edi_pa.selection__account_move__l10n_it_origin_document_type__purchase_order
msgid "Purchase Order"
msgstr "Ordine d'Acquisto"
#. module: l10n_it_edi_pa
#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_cig
#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_move__l10n_it_cig
#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_payment__l10n_it_cig
msgid "Tender Unique Identifier"
msgstr "CIG"
#. module: l10n_it_edi_pa
#. odoo-python
#: code:addons/l10n_it_edi_pa/models/account_edi_format.py:0
#, python-format
msgid "The Origin Document Date cannot be in the future."
msgstr "La Data Documento Origine non può essere nel futuro."
#. module: l10n_it_edi_pa
#. odoo-python
#: code:addons/l10n_it_edi_pa/models/account_edi_format.py:0
#, python-format
msgid ""
"This invoice targets the Public Administration, please fill out Origin "
"Document Type field in the Electronic Invoicing tab."
msgstr ""
"Questa fattura ha come cliente la Pubblica Amministrazione, "
"per favore riempi il Tipo Documento Origine nel tab Fatturazione "
"Elettronica"
@@ -0,0 +1,125 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * l10n_it_edi_pa
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-08-19 00:02+0000\n"
"PO-Revision-Date: 2023-08-19 00:02+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: l10n_it_edi_pa
#: model:ir.model.fields.selection,name:l10n_it_edi_pa.selection__account_move__l10n_it_origin_document_type__agreement
msgid "Agreement"
msgstr ""
#. module: l10n_it_edi_pa
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_cig
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_move__l10n_it_cig
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_payment__l10n_it_cig
msgid "CIG"
msgstr ""
#. module: l10n_it_edi_pa
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_cup
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_move__l10n_it_cup
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_payment__l10n_it_cup
msgid "CUP"
msgstr ""
#. module: l10n_it_edi_pa
#: model:ir.model.fields.selection,name:l10n_it_edi_pa.selection__account_move__l10n_it_origin_document_type__contract
msgid "Contract"
msgstr ""
#. module: l10n_it_edi_pa
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_partner_pa_index
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_move__l10n_it_partner_pa_index
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_payment__l10n_it_partner_pa_index
msgid "Destination Code"
msgstr ""
#. module: l10n_it_edi_pa
#: model:ir.model,name:l10n_it_edi_pa.model_account_edi_format
msgid "EDI format"
msgstr ""
#. module: l10n_it_edi_pa
#: model:ir.model,name:l10n_it_edi_pa.model_account_move
msgid "Journal Entry"
msgstr ""
#. module: l10n_it_edi_pa
#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_partner_pa_index
#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_move__l10n_it_partner_pa_index
#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_payment__l10n_it_partner_pa_index
msgid ""
"Must contain the 6-character (or 7) code, present in the PA "
"Index in the information relative to the electronic invoicing service,"
" associated with the office which, within the addressee "
"administration, deals with receiving (and processing) the "
"invoice."
msgstr ""
#. module: l10n_it_edi_pa
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_origin_document_date
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_move__l10n_it_origin_document_date
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_payment__l10n_it_origin_document_date
msgid "Origin Document Date"
msgstr ""
#. module: l10n_it_edi_pa
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_origin_document_name
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_move__l10n_it_origin_document_name
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_payment__l10n_it_origin_document_name
msgid "Origin Document Name"
msgstr ""
#. module: l10n_it_edi_pa
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_origin_document_type
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_move__l10n_it_origin_document_type
#: model:ir.model.fields,field_description:l10n_it_edi_pa.field_account_payment__l10n_it_origin_document_type
msgid "Origin Document Type"
msgstr ""
#. module: l10n_it_edi_pa
#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_cup
#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_move__l10n_it_cup
#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_payment__l10n_it_cup
msgid "Public Investment Unique Identifier"
msgstr ""
#. module: l10n_it_edi_pa
#: model:ir.model.fields.selection,name:l10n_it_edi_pa.selection__account_move__l10n_it_origin_document_type__purchase_order
msgid "Purchase Order"
msgstr ""
#. module: l10n_it_edi_pa
#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_bank_statement_line__l10n_it_cig
#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_move__l10n_it_cig
#: model:ir.model.fields,help:l10n_it_edi_pa.field_account_payment__l10n_it_cig
msgid "Tender Unique Identifier"
msgstr ""
#. module: l10n_it_edi_pa
#. odoo-python
#: code:addons/l10n_it_edi_pa/models/account_edi_format.py:0
#, python-format
msgid "The Origin Document Date cannot be in the future."
msgstr ""
#. module: l10n_it_edi_pa
#. odoo-python
#: code:addons/l10n_it_edi_pa/models/account_edi_format.py:0
#, python-format
msgid ""
"This invoice targets the Public Administration, please fill out Origin "
"Document Type field in the Electronic Invoicing tab."
msgstr ""
+4
View File
@@ -0,0 +1,4 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import account_move
from . import account_edi_format
@@ -0,0 +1,17 @@
# 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
@@ -0,0 +1,46 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
class AccountMove(models.Model):
_inherit = 'account.move'
l10n_it_origin_document_type = fields.Selection(
string="Origin Document Type",
selection=[('purchase_order', 'Purchase Order'), ('contract', 'Contract'), ('agreement', 'Agreement')],
copy=False)
l10n_it_origin_document_name = fields.Char(
string="Origin Document Name",
copy=False)
l10n_it_origin_document_date = fields.Date(
string="Origin Document Date",
copy=False)
l10n_it_cig = fields.Char(
string="CIG",
copy=False,
help="Tender Unique Identifier")
l10n_it_cup = fields.Char(
string="CUP",
copy=False,
help="Public Investment Unique Identifier")
# Technical field for showing the above fields or not
l10n_it_partner_pa = fields.Boolean(compute='_compute_l10n_it_partner_pa')
@api.depends('commercial_partner_id.l10n_it_pa_index', 'company_id')
def _compute_l10n_it_partner_pa(self):
for move in self:
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):
"""Add origin document features."""
template_values = super()._prepare_fatturapa_export_values()
template_values.update({
'origin_document_type': self.l10n_it_origin_document_type,
'origin_document_name': self.l10n_it_origin_document_name,
'origin_document_date': self.l10n_it_origin_document_date,
'cig': self.l10n_it_cig,
'cup': self.l10n_it_cup,
})
return template_values
+3
View File
@@ -0,0 +1,3 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import test_edi_pa
@@ -0,0 +1,75 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import datetime
from lxml import etree
from odoo.addons.l10n_it_edi.tests.common import TestItEdi
from odoo.exceptions import UserError
from odoo.tests.common import tagged
from odoo import tools
from odoo import Command
@tagged('post_install_l10n', 'post_install', '-at_install')
class TestItEdiPa(TestItEdi):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.Move = cls.env['account.move'].with_company(cls.company)
journal_code = cls.company_data_2['default_journal_sale'].code
cls.split_payment_tax = cls.env['account.tax'].with_company(cls.company).search([('name', '=', '22% SP')])
cls.split_payment_line_data = {
'name': 'standard_line',
'quantity': 1,
'price_unit': 800.40,
'tax_ids': [Command.set(cls.split_payment_tax.ids)],
}
cls.pa_partner_invoice_data = {
'move_type': 'out_invoice',
'invoice_date': datetime.date(2022, 3, 24),
'invoice_date_due': datetime.date(2022, 3, 24),
'partner_id': cls.italian_partner_b.id,
'partner_bank_id': cls.test_bank.id,
'invoice_line_ids': [
Command.create(cls.split_payment_line_data),
],
'l10n_it_origin_document_type': 'purchase_order',
'l10n_it_origin_document_date': datetime.date(2022, 3, 23),
'l10n_it_origin_document_name': f"{journal_code}/2022/0001",
'l10n_it_cup': '0123456789',
'l10n_it_cig': '0987654321'
}
cls.pa_partner_invoice = cls.Move.create(cls.pa_partner_invoice_data)
cls.pa_partner_invoice_2 = cls.Move.create({
**cls.pa_partner_invoice_data,
'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)
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="account_invoice_form_l10n_it_pa" model="ir.ui.view">
<field name="name">account.move.form.l10n.it.pa</field>
<field name="model">account.move</field>
<field name="priority">20</field>
<field name="inherit_id" ref="l10n_it_edi.account_invoice_form_l10n_it"/>
<field name="arch" type="xml">
<data>
<xpath expr="//page[@name='electronic_invoicing']/group" position="inside">
<field name="l10n_it_partner_pa" invisible="1"/>
<group invisible="not l10n_it_partner_pa">
<field name="l10n_it_origin_document_type" readonly="state != 'draft'"/>
<field name="l10n_it_origin_document_name" readonly="state != 'draft'"/>
<field name="l10n_it_origin_document_date" readonly="state != 'draft'"/>
<field name="l10n_it_cig" readonly="state != 'draft'"/>
<field name="l10n_it_cup" readonly="state != 'draft'"/>
</group>
</xpath>
</data>
</field>
</record>
</odoo>
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="report_invoice_document" inherit_id="account.report_invoice_document">
<div name="comment" position="before">
<div t-if="o.l10n_it_origin_document_type" name="pa_fields">
<b><span t-field="o.l10n_it_origin_document_type"/></b>: <span t-field="o.l10n_it_origin_document_name"/><br/>
<t t-if="o.l10n_it_origin_document_date"><b>Document Date: </b><span t-field="o.l10n_it_origin_document_date"/><br/></t>
<t t-if="o.l10n_it_cig"><b>CIG: </b><span t-field="o.l10n_it_cig"/><br/></t>
<t t-if="o.l10n_it_cup"><b>CUP: </b><span t-field="o.l10n_it_cup"/><br/></t>
</div>
</div>
</template>
</odoo>