-
-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by TheMule71
- Loading branch information
Showing
10 changed files
with
400 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from . import test_account_invoice | ||
from . import test_notification |
119 changes: 119 additions & 0 deletions
119
l10n_it_fatturapa_sdicoop/tests/data/IT05979361218_001.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<p:FatturaElettronica versione="FPA12" 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>IT</IdPaese> | ||
<IdCodice>05979361218</IdCodice> | ||
</IdTrasmittente> | ||
<ProgressivoInvio>001</ProgressivoInvio> | ||
<FormatoTrasmissione>FPA12</FormatoTrasmissione> | ||
<CodiceDestinatario>UFPQ1O</CodiceDestinatario> | ||
</DatiTrasmissione> | ||
<CedentePrestatore> | ||
<DatiAnagrafici> | ||
<IdFiscaleIVA> | ||
<IdPaese>IT</IdPaese> | ||
<IdCodice>05979361218 </IdCodice> | ||
</IdFiscaleIVA> | ||
<Anagrafica> | ||
<Denominazione>SOCIETA' ALPHA BETA SRL</Denominazione> | ||
</Anagrafica> | ||
<AlboProfessionale>Albo di test</AlboProfessionale> | ||
<ProvinciaAlbo>TO</ProvinciaAlbo> | ||
<NumeroIscrizioneAlbo>TO1258B</NumeroIscrizioneAlbo> | ||
<DataIscrizioneAlbo>2010-01-16</DataIscrizioneAlbo> | ||
<RegimeFiscale>RF02</RegimeFiscale> | ||
</DatiAnagrafici> | ||
<Sede> | ||
<Indirizzo>VIALE ROMA 543B</Indirizzo> | ||
<CAP>07100</CAP> | ||
<Comune>SASSARI</Comune> | ||
<Provincia>SS</Provincia> | ||
<Nazione></Nazione> | ||
</Sede> | ||
</CedentePrestatore> | ||
<CessionarioCommittente> | ||
<DatiAnagrafici> | ||
<CodiceFiscale>80213330584</CodiceFiscale> | ||
<Anagrafica> | ||
<Denominazione>AMMINISTRAZIONE BETA</Denominazione> | ||
</Anagrafica> | ||
</DatiAnagrafici> | ||
<Sede> | ||
<Indirizzo>VIA TORINO 38-B</Indirizzo> | ||
<CAP>00145</CAP> | ||
<Comune>ROMA</Comune> | ||
<Provincia>RM</Provincia> | ||
<Nazione>IT</Nazione> | ||
</Sede> | ||
</CessionarioCommittente> | ||
</FatturaElettronicaHeader> | ||
<FatturaElettronicaBody> | ||
<DatiGenerali> | ||
<DatiGeneraliDocumento> | ||
<TipoDocumento>TD01</TipoDocumento> | ||
<Divisa>EUR</Divisa> | ||
<Data>2015-02-16</Data> | ||
<Numero>FT/2015/0006</Numero> | ||
<DatiCassaPrevidenziale> | ||
<TipoCassa>TC22</TipoCassa> | ||
<AlCassa>0.00</AlCassa> | ||
<ImportoContributoCassa>3.00</ImportoContributoCassa> | ||
<ImponibileCassa>3.00</ImponibileCassa> | ||
<AliquotaIVA>0.00</AliquotaIVA> | ||
<Natura>N4</Natura> | ||
</DatiCassaPrevidenziale> | ||
<Causale>Rif ordine MAPA: --- Nr. Identificativo Ordine 1234567</Causale> | ||
</DatiGeneraliDocumento> | ||
<DatiTrasporto> | ||
<PesoLordo>0.00</PesoLordo> | ||
<PesoNetto>0.00</PesoNetto> | ||
</DatiTrasporto> | ||
</DatiGenerali> | ||
<DatiBeniServizi> | ||
<DettaglioLinee> | ||
<NumeroLinea>1</NumeroLinea> | ||
<Descrizione>Prodotto di test al giorno</Descrizione> | ||
<Quantita>15.00</Quantita> | ||
<UnitaMisura>Giorno(i)</UnitaMisura> | ||
<PrezzoUnitario>3.60</PrezzoUnitario> | ||
<PrezzoTotale>54.00</PrezzoTotale> | ||
<AliquotaIVA>0.00</AliquotaIVA> | ||
<Natura>N4</Natura> | ||
<AltriDatiGestionali> | ||
<TipoDato>Vostro RIF</TipoDato> | ||
<RiferimentoTesto>Riferimento</RiferimentoTesto> | ||
<RiferimentoNumero>3.00</RiferimentoNumero> | ||
</AltriDatiGestionali> | ||
<AltriDatiGestionali> | ||
<TipoDato>Vostro RIF</TipoDato> | ||
<RiferimentoTesto>Riferimento2</RiferimentoTesto> | ||
</AltriDatiGestionali> | ||
</DettaglioLinee> | ||
<DatiRiepilogo> | ||
<AliquotaIVA>0.00</AliquotaIVA> | ||
<Natura>N4</Natura> | ||
<ImponibileImporto>57.00</ImponibileImporto> | ||
<Imposta>0.00</Imposta> | ||
<RiferimentoNormativo>Operazioni senza addebito imposta regime contribuenti minimi art.27 c.1-2 DL.98/11</RiferimentoNormativo> | ||
</DatiRiepilogo> | ||
</DatiBeniServizi> | ||
<DatiPagamento> | ||
<CondizioniPagamento>TP01</CondizioniPagamento> | ||
<DettaglioPagamento> | ||
<ModalitaPagamento>MP05</ModalitaPagamento> | ||
<DataScadenzaPagamento>2015-03-18</DataScadenzaPagamento> | ||
<ImportoPagamento>27.00</ImportoPagamento> | ||
</DettaglioPagamento> | ||
<DettaglioPagamento> | ||
<ModalitaPagamento>MP05</ModalitaPagamento> | ||
<DataScadenzaPagamento>2015-04-17</DataScadenzaPagamento> | ||
<ImportoPagamento>27.00</ImportoPagamento> | ||
</DettaglioPagamento> | ||
</DatiPagamento> | ||
</FatturaElettronicaBody> | ||
</p:FatturaElettronica> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Copyright 2022 Simone Rubino - TAKOBI | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo.addons.l10n_it_fatturapa_in.tests.fatturapa_common import ( | ||
FatturapaCommon, | ||
) | ||
from odoo.tests import new_test_user | ||
|
||
|
||
class TestBillNotification (FatturapaCommon): | ||
|
||
def setUp(self): | ||
super().setUp() | ||
self.notified_user = new_test_user( | ||
self.env, | ||
login='Notify E-bill', | ||
) | ||
self.sdicoop_channel = self.env.ref( | ||
'l10n_it_fatturapa_sdicoop.sdi_channel_sdicoop', | ||
) | ||
|
||
def test_e_bill_created_notify(self): | ||
""" | ||
When an E-bill is received, | ||
the followers of the SdI channel are notified. | ||
""" | ||
# Arrange: Set the channel in the company, | ||
# and a follower for the channel | ||
company = self.env.user.company_id | ||
notified_partner = self.notified_user.partner_id | ||
company.sdi_channel_id = self.sdicoop_channel | ||
company.sdi_channel_id.message_subscribe( | ||
partner_ids=notified_partner.ids, | ||
) | ||
# pre-condition: the partner is following the SdI channel | ||
self.assertIn( | ||
notified_partner, | ||
company.sdi_channel_id.message_partner_ids, | ||
) | ||
|
||
# Act: Receive the E-bill | ||
file_name = 'IT05979361218_001.xml' | ||
file_path, file_content = self.getFile( | ||
file_name, | ||
module_name='l10n_it_fatturapa_sdicoop', | ||
) | ||
attachment = company.sdi_channel_id.receive_fe( | ||
{ | ||
file_name: file_content, | ||
}, | ||
{}, | ||
) | ||
|
||
# Assert: The SdI channel's follower is following the E-bill | ||
self.assertIn( | ||
notified_partner, | ||
attachment.message_partner_ids, | ||
) | ||
# There is a message of subtype E-bill received | ||
received_e_bill_subtype = self.env.ref( | ||
'l10n_it_sdi_channel.e_bill_received', | ||
) | ||
messages = attachment.message_ids | ||
received_e_bill_message = messages.filtered( | ||
lambda m: m.subtype_id == received_e_bill_subtype | ||
) | ||
self.assertEqual(len(received_e_bill_message), 1) | ||
# The message notifies the SdI channel's follower | ||
self.assertIn( | ||
notified_partner, | ||
received_e_bill_message.needaction_partner_ids, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<!-- | ||
~ Copyright 2022 Simone Rubino - TAKOBI | ||
~ License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
--> | ||
<odoo> | ||
<!-- Subtypes for e-invoice --> | ||
<record id="e_invoice_ready" model="mail.message.subtype"> | ||
<field name="name">Ready to Send</field> | ||
<field name="res_model">fatturapa.attachment.out</field> | ||
<field name="default" eval="False"/> | ||
<field name="description">E-invoice Ready to Send</field> | ||
</record> | ||
|
||
<record id="e_invoice_sent" model="mail.message.subtype"> | ||
<field name="name">Sent</field> | ||
<field name="res_model">fatturapa.attachment.out</field> | ||
<field name="default" eval="False"/> | ||
<field name="description">E-invoice Sent</field> | ||
</record> | ||
|
||
<record id="e_invoice_sender_error" model="mail.message.subtype"> | ||
<field name="name">Sender Error</field> | ||
<field name="res_model">fatturapa.attachment.out</field> | ||
<field name="default" eval="True"/> | ||
<field name="description">E-invoice Sender Error</field> | ||
</record> | ||
|
||
<record id="e_invoice_recipient_error" model="mail.message.subtype"> | ||
<field name="name">Not delivered</field> | ||
<field name="res_model">fatturapa.attachment.out</field> | ||
<field name="default" eval="False"/> | ||
<field name="description">E-invoice Not Delivered</field> | ||
</record> | ||
|
||
<record id="e_invoice_rejected" model="mail.message.subtype"> | ||
<field name="name">Rejected (PA)</field> | ||
<field name="res_model">fatturapa.attachment.out</field> | ||
<field name="default" eval="False"/> | ||
<field name="description">E-invoice Rejected (PA)</field> | ||
</record> | ||
|
||
<record id="e_invoice_validated" model="mail.message.subtype"> | ||
<field name="name">Delivered</field> | ||
<field name="res_model">fatturapa.attachment.out</field> | ||
<field name="default" eval="False"/> | ||
<field name="description">E-invoice Delivered</field> | ||
</record> | ||
|
||
<record id="e_invoice_accepted" model="mail.message.subtype"> | ||
<field name="name">Accepted</field> | ||
<field name="res_model">fatturapa.attachment.out</field> | ||
<field name="default" eval="False"/> | ||
<field name="description">E-invoice Accepted</field> | ||
</record> | ||
|
||
<!-- Subtypes for e-bill --> | ||
<record id="e_bill_received" model="mail.message.subtype"> | ||
<field name="name">E-bill received</field> | ||
<field name="res_model">fatturapa.attachment.in</field> | ||
<field name="default" eval="True"/> | ||
<field name="description">E-bill received</field> | ||
</record> | ||
|
||
<!-- Subtypes for SdI channel --> | ||
<record id="sdi_channel_e_invoice_ready" model="mail.message.subtype"> | ||
<field name="name">E-invoice Ready to Send</field> | ||
<field name="res_model">sdi.channel</field> | ||
<field name="parent_id" eval="ref('e_invoice_ready')"/> | ||
<field name="relation_field">channel_id</field> | ||
<field name="default" eval="False"/> | ||
</record> | ||
|
||
<record id="sdi_channel_e_invoice_sent" model="mail.message.subtype"> | ||
<field name="name">E-invoice Sent</field> | ||
<field name="res_model">sdi.channel</field> | ||
<field name="parent_id" eval="ref('e_invoice_sent')"/> | ||
<field name="relation_field">channel_id</field> | ||
<field name="default" eval="False"/> | ||
</record> | ||
|
||
<record id="sdi_channel_e_invoice_sender_error" model="mail.message.subtype"> | ||
<field name="name">E-invoice Sender Error</field> | ||
<field name="res_model">sdi.channel</field> | ||
<field name="parent_id" eval="ref('e_invoice_sender_error')"/> | ||
<field name="relation_field">channel_id</field> | ||
<field name="default" eval="True"/> | ||
</record> | ||
|
||
<record id="sdi_channel_e_invoice_recipient_error" model="mail.message.subtype"> | ||
<field name="name">E-invoice Not Delivered</field> | ||
<field name="res_model">sdi.channel</field> | ||
<field name="parent_id" eval="ref('e_invoice_recipient_error')"/> | ||
<field name="relation_field">channel_id</field> | ||
<field name="default" eval="False"/> | ||
</record> | ||
|
||
<record id="sdi_channel_e_invoice_rejected" model="mail.message.subtype"> | ||
<field name="name">E-invoice Rejected (PA)</field> | ||
<field name="res_model">sdi.channel</field> | ||
<field name="parent_id" eval="ref('e_invoice_rejected')"/> | ||
<field name="relation_field">channel_id</field> | ||
<field name="default" eval="False"/> | ||
</record> | ||
|
||
<record id="sdi_channel_e_invoice_validated" model="mail.message.subtype"> | ||
<field name="name">E-invoice Delivered</field> | ||
<field name="res_model">sdi.channel</field> | ||
<field name="parent_id" eval="ref('e_invoice_validated')"/> | ||
<field name="relation_field">channel_id</field> | ||
<field name="default" eval="False"/> | ||
</record> | ||
|
||
<record id="sdi_channel_e_invoice_accepted" model="mail.message.subtype"> | ||
<field name="name">E-invoice Accepted</field> | ||
<field name="res_model">sdi.channel</field> | ||
<field name="parent_id" eval="ref('e_invoice_accepted')"/> | ||
<field name="relation_field">channel_id</field> | ||
<field name="default" eval="False"/> | ||
</record> | ||
|
||
<record id="sdi_channel_e_bill_received" model="mail.message.subtype"> | ||
<field name="name">E-bill received</field> | ||
<field name="res_model">sdi.channel</field> | ||
<field name="parent_id" eval="ref('e_bill_received')"/> | ||
<field name="relation_field">channel_id</field> | ||
</record> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from . import account_invoice | ||
from . import fatturapa_attachment_out | ||
from . import company | ||
from . import fatturapa_attachment | ||
from . import fatturapa_attachment_out | ||
from . import sdi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright 2022 Simone Rubino - TAKOBI | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class FatturaPAAttachment (models.AbstractModel): | ||
_inherit = 'fatturapa.attachment' | ||
|
||
channel_id = fields.Many2one( | ||
comodel_name='sdi.channel', | ||
related="company_id.sdi_channel_id", | ||
store=True, | ||
) | ||
|
||
def _message_auto_subscribe_followers( | ||
self, updated_values, default_subtype_ids): | ||
res = super()._message_auto_subscribe_followers( | ||
updated_values, default_subtype_ids) | ||
updated_channel_id = updated_values.get('channel_id') | ||
if not updated_channel_id: | ||
# SdI channel is not explicitly set, so SdI channel's followers | ||
# won't be subscribed to current attachments. | ||
# Attachments might have the SdI channel set anyway | ||
# because it is a related field. | ||
# Add the SdI channel's followers | ||
# but only if all the attachments share the same SdI channel | ||
channel = self.mapped('channel_id') | ||
if all(attachment.channel_id == channel for attachment in self): | ||
for partner_follower in channel.message_partner_ids: | ||
res.append(( | ||
partner_follower.id, | ||
default_subtype_ids, | ||
False, | ||
)) | ||
return res |
Oops, something went wrong.