Files
odoo_source/addons/l10n_it_edi/data/invoice_it_template.xml
T
Paolo Gatti 459684e2a1 [FIX] l10n_it_edi: Non EU VAT fix
Non EU vendor bills are sent to the Tax Agency as self-invoices,
so the partner actually is the seller, but the same checks on the
VAT must apply as it was the buyer.

Task: https://www.odoo.com/web#id=3010849&model=project.task
opw-3010849

closes odoo/odoo#106312

X-original-commit: 8c18b870ecc04314380fcdb6b61179de78e28703
Signed-off-by: Josse Colpaert <jco@odoo.com>
Signed-off-by: Paolo Gatti (pgi) <pgi@odoo.com>
2022-11-23 13:24:54 +01:00

223 lines
14 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="account_invoice_line_it_FatturaPA">
<DettaglioLinee>
<NumeroLinea t-out="line_dict['line_number']"/>
<CodiceArticolo t-if="line.product_id.barcode">
<CodiceTipo>EAN</CodiceTipo>
<CodiceValore t-out="format_alphanumeric(line.product_id.barcode)"/>
</CodiceArticolo>
<CodiceArticolo t-elif="line.product_id.default_code">
<CodiceTipo>INTERNAL</CodiceTipo>
<CodiceValore t-out="format_alphanumeric(line.product_id.default_code)"/>
</CodiceArticolo>
<Descrizione t-out="format_alphanumeric(line_dict['description'])"/>
<Quantita t-out="format_numbers(abs(line.quantity))"/>
<UnitaMisura t-if="line.product_uom_id.category_id != env.ref('uom.product_uom_categ_unit')" t-out="format_alphanumeric(line.product_uom_id.name)"/>
<PrezzoUnitario t-out="'%.06f' % (line_dict['unit_price'])"/>
<ScontoMaggiorazione t-if="line.discount != 0">
<Tipo t-out="discount_type(line.discount)"/>
<Percentuale t-out="format_numbers(abs(line.discount))"/>
</ScontoMaggiorazione>
<PrezzoTotale t-out="format_monetary(line_dict['subtotal_price'], currency)"/>
<AliquotaIVA t-if="line.tax_ids.amount_type == 'percent'" t-out="format_numbers(line.tax_ids.amount)"/>
<AliquotaIVA t-elif="line.tax_ids.amount_type != 'percent'" t-out="'0.00'"/>
<Natura t-if="line.tax_ids.l10n_it_has_exoneration" t-out="line.tax_ids.l10n_it_kind_exoneration"/>
<AltriDatiGestionali t-if="conversion_rate">
<TipoDato>Currency</TipoDato>
<RiferimentoTesto t-out="format_alphanumeric(record.currency_id.name)"/>
<RiferimentoNumero t-out="'%.06f' % line.price_subtotal"/>
</AltriDatiGestionali>
<AltriDatiGestionali t-if="conversion_rate">
<TipoDato>Exch.Rate</TipoDato>
<RiferimentoNumero t-out="conversion_rate"/>
<RiferimentoData t-out="format_date(record.invoice_date)"/>
</AltriDatiGestionali>
</DettaglioLinee>
</template>
<template id="account_invoice_it_FatturaPA_export">
<p:FatturaElettronica t-att-versione="formato_trasmissione" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:p="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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">
<FatturaElettronicaHeader>
<DatiTrasmissione>
<IdTrasmittente>
<IdPaese t-out="get_vat_country(sender.vat)"/>
<IdCodice t-out="normalize_codice_fiscale(sender.l10n_it_codice_fiscale) or get_vat_number(sender.vat)"/>
</IdTrasmittente>
<ProgressivoInvio t-out="format_alphanumeric(record.name.replace('/','')[-10:])"/>
<FormatoTrasmissione t-out="formato_trasmissione"/>
<CodiceDestinatario t-out="codice_destinatario"/>
<ContattiTrasmittente>
<Telefono t-if="sender_partner.phone" t-out="format_alphanumeric(format_phone(sender_partner.phone))"/>
<Telefono t-elif="sender_partner.mobile" t-out="format_alphanumeric(format_phone(sender_partner.mobile))"/>
<Email t-if="sender_partner.email" t-out="sender_partner.email"/>
</ContattiTrasmittente>
<PECDestinatario t-if="not is_self_invoice and partner.l10n_it_pec_email" t-out="partner.l10n_it_pec_email"/>
</DatiTrasmissione>
<CedentePrestatore>
<DatiAnagrafici>
<IdFiscaleIVA t-if="seller.vat and in_eu(seller)">
<IdPaese t-out="get_vat_country(seller.vat)"/>
<IdCodice t-out="get_vat_number(seller.vat)"/>
</IdFiscaleIVA>
<IdFiscaleIVA t-if="seller.vat and not in_eu(seller)">
<IdPaese t-out="seller.country_id.code"/>
<IdCodice t-out="'OO99999999999'"/>
</IdFiscaleIVA>
<IdFiscaleIVA t-if="not seller.vat and seller.country_id.code != 'IT'">
<IdPaese t-out="seller.country_id.code"/>
<IdCodice t-out="'0000000'"/>
</IdFiscaleIVA>
<CodiceFiscale t-if="seller.l10n_it_codice_fiscale" t-out="normalize_codice_fiscale(seller.l10n_it_codice_fiscale)"/>
<Anagrafica>
<Denominazione t-out="format_alphanumeric(seller_partner.display_name[:80])"/>
</Anagrafica>
<RegimeFiscale t-out="regime_fiscale"/>
</DatiAnagrafici>
<t t-call="l10n_it_edi.account_invoice_it_FatturaPA_sede">
<t t-set="partner" t-value="seller_partner"/>
</t>
<IscrizioneREA t-if="not is_self_invoice and company.l10n_it_has_eco_index">
<Ufficio t-out="company.l10n_it_eco_index_office.code"/>
<NumeroREA t-out="format_alphanumeric(company.l10n_it_eco_index_number)"/>
<CapitaleSociale t-if="company.l10n_it_eco_index_share_capital != 0" t-out="format_numbers_two(company.l10n_it_eco_index_share_capital)"/>
<SocioUnico t-if="company.l10n_it_eco_index_sole_shareholder != 'NO'" t-out="company.l10n_it_eco_index_sole_shareholder"/>
<StatoLiquidazione t-out="company.l10n_it_eco_index_liquidation_state"/>
</IscrizioneREA>
</CedentePrestatore>
<RappresentanteFiscale t-if="not is_self_invoice and representative">
<DatiAnagrafici>
<IdFiscaleIVA>
<IdPaese t-out="get_vat_country(representative.vat)"/>
<IdCodice t-out="get_vat_number(representative.vat)"/>
</IdFiscaleIVA>
<CodiceFiscale t-if="representative.l10n_it_codice_fiscale" t-out="normalize_codice_fiscale(representative.l10n_it_codice_fiscale)"/>
<Anagrafica>
<t t-if="representative.is_company">
<Denominazione t-out="format_alphanumeric(representative.display_name[:80])"/>
</t>
<t t-else="">
<Nome t-out="format_alphanumeric(' '.join(representative.name.split()[:1])[:60])"/>
<Cognome t-out="format_alphanumeric(' '.join(representative.name.split()[1:])[:60])"/>
</t>
</Anagrafica>
</DatiAnagrafici>
</RappresentanteFiscale>
<CessionarioCommittente>
<DatiAnagrafici>
<IdFiscaleIVA t-if="buyer.vat and in_eu(buyer)">
<IdPaese t-out="get_vat_country(buyer.vat)"/>
<IdCodice t-out="get_vat_number(buyer.vat)"/>
</IdFiscaleIVA>
<IdFiscaleIVA t-if="buyer.vat and not in_eu(buyer)">
<IdPaese t-out="buyer.country_id.code"/>
<IdCodice t-out="'OO99999999999'"/>
</IdFiscaleIVA>
<IdFiscaleIVA t-if="not buyer.vat and buyer.country_id.code != 'IT'">
<IdPaese t-out="buyer.country_id.code"/>
<IdCodice t-out="'0000000'"/>
</IdFiscaleIVA>
<CodiceFiscale t-if="not buyer.vat and buyer.l10n_it_codice_fiscale" t-out="normalize_codice_fiscale(buyer.l10n_it_codice_fiscale)"/>
<CodiceFiscale t-elif="not buyer.vat and not buyer.l10n_it_codice_fiscale" t-out="99999999999"/>
<Anagrafica>
<t t-if="buyer_is_company">
<Denominazione t-out="format_alphanumeric(buyer.display_name[:80])"/>
</t>
<t t-else="">
<Nome t-out="format_alphanumeric(' '.join(buyer.name.split()[:1])[:60])"/>
<Cognome t-out="format_alphanumeric(' '.join(buyer.name.split()[1:])[:60])"/>
</t>
</Anagrafica>
</DatiAnagrafici>
<t t-call="l10n_it_edi.account_invoice_it_FatturaPA_sede">
<t t-set="partner" t-value="buyer_partner"/>
</t>
</CessionarioCommittente>
</FatturaElettronicaHeader>
<FatturaElettronicaBody>
<DatiGenerali>
<DatiGeneraliDocumento>
<TipoDocumento t-out="document_type"/>
<Divisa t-out="currency.name"/>
<Data t-out="format_date(record.invoice_date)"/>
<Numero t-out="format_alphanumeric(record.name[-20:])"/>
<DatiBollo t-if="record.l10n_it_stamp_duty">
<BolloVirtuale>SI</BolloVirtuale>
<ImportoBollo t-out="format_numbers(record.l10n_it_stamp_duty)"/>
</DatiBollo>
<ImportoTotaleDocumento t-out="format_monetary(document_total, currency)"/>
</DatiGeneraliDocumento>
<DatiOrdineAcquisto t-if="record.ref">
<IdDocumento t-out="format_alphanumeric(record.ref[:20])"/>
</DatiOrdineAcquisto>
<DatiDDT t-if="record.l10n_it_ddt_id">
<NumeroDDT t-out="format_alphanumeric(record.l10n_it_ddt_id.name[-20:])"/>
<DataDDT t-out="format_date(record.l10n_it_ddt_id.date)"/>
</DatiDDT>
</DatiGenerali>
<DatiBeniServizi>
<t t-foreach="invoice_lines" t-as="line_dict">
<t t-set="line" t-value="line_dict['line']"/>
<t t-call="l10n_it_edi.account_invoice_line_it_FatturaPA"/>
</t>
<t t-foreach="tax_lines" t-as="tax_line">
<t t-set="tax" t-value="tax_line['tax']"/>
<t t-set="has_exoneration" t-value="tax.l10n_it_has_exoneration"/>
<t t-set="kind_exoneration" t-value="tax.l10n_it_kind_exoneration"/>
<DatiRiepilogo>
<AliquotaIVA t-out="format_numbers(tax.amount)"/>
<Natura t-if="has_exoneration" t-out="kind_exoneration"/>
<Arrotondamento t-if="tax_line.get('rounding')" t-out="format_numbers(-tax_line['rounding'])"/>
<t t-if="rc_refund">
<ImponibileImporto t-out="format_monetary(balance_multiplicator * tax_line['base_amount'], currency)"/>
<Imposta t-out="format_monetary(balance_multiplicator * tax_line['tax_amount'], currency)"/>
</t>
<t t-else="">
<ImponibileImporto t-out="format_monetary(abs(tax_line['base_amount']), currency)"/>
<Imposta t-out="format_monetary(abs(tax_line['tax_amount']), currency)"/>
</t>
<EsigibilitaIVA t-if="not has_exoneration or kind_exoneration == 'N6'" t-out="tax.l10n_it_vat_due_date"/>
<RiferimentoNormativo t-if="tax.l10n_it_law_reference" t-esc="format_alphanumeric(tax.l10n_it_law_reference[:100])"/>
</DatiRiepilogo>
</t>
</DatiBeniServizi>
<DatiPagamento t-if="partner_bank and record.move_type != 'out_refund'">
<t t-set="payments" t-value="record.line_ids.filtered(lambda line: line.account_id.account_type in ('asset_receivable', 'liability_payable'))"/>
<CondizioniPagamento><t t-if="len(payments) == 1">TP02</t><t t-else="">TP01</t></CondizioniPagamento>
<t t-foreach="payments" t-as="payment">
<DettaglioPagamento>
<ModalitaPagamento>MP05</ModalitaPagamento>
<DataScadenzaPagamento t-out="format_date(payment.date_maturity)"/>
<ImportoPagamento t-out="format_monetary(abs(payment.amount_currency), currency)"/>
<IstitutoFinanziario t-if="partner_bank.bank_id" t-out="format_alphanumeric(partner_bank.bank_id.name[:80])"/>
<IBAN t-if="partner_bank.acc_type == 'iban'" t-out="partner_bank.sanitized_acc_number"/>
<BIC t-elif="partner_bank.acc_type == 'bank' and partner_bank.bank_id.bic" t-out="partner_bank.bank_id.bic"/>
<CodicePagamento t-if="record.payment_reference" t-out="format_alphanumeric(record.payment_reference[:60])"/>
</DettaglioPagamento>
</t>
</DatiPagamento>
<Allegati t-if="pdf">
<NomeAttachment t-out="format_alphanumeric(pdf_name[:60])"/>
<FormatoAttachment>PDF</FormatoAttachment>
<Attachment t-out="pdf"/>
</Allegati>
</FatturaElettronicaBody>
</p:FatturaElettronica>
</template>
<template id="account_invoice_it_FatturaPA_sede">
<Sede>
<Indirizzo><t t-if="partner.street" t-out="format_alphanumeric(partner.street)"/> <t t-if="partner.street2" t-out="format_alphanumeric(partner.street2)"/></Indirizzo>
<CAP><t t-if="partner.country_id.code != 'IT'" t-out="'00000'"/><t t-else="" t-out="partner.zip"/></CAP>
<Comune t-out="format_alphanumeric(partner.city)"/>
<Provincia t-if="partner.country_id.code == 'IT'" t-out="partner.state_id.code"/>
<Nazione t-out="partner.country_id.code"/>
</Sede>
</template>
</data>
</odoo>