Invio e ricezione fatture elettroniche tramite PEC
Project description
ITA - Fattura elettronica - Supporto PEC
Italiano
Questo modulo implementa il canale PEC (Posta Elettronica Certificata) per la comunicazione con il Sistema di Interscambio (SdI), in alternativa al proxy IAP standard di Odoo.
Si basa su l10n_it_edi_sdi per la logica condivisa di elaborazione delle notifiche e ricezione delle fatture, aggiungendo il trasporto specifico via PEC.
Funzionalità principali:
Invio fatture elettroniche via PEC al SdI
Ricezione email PEC dal SdI e instradamento ai gestori appropriati
Gestione errori PEC con notifica automatica ai contatti configurati e disabilitazione del server dopo ripetuti fallimenti
Configurazione server SMTP e IMAP/POP3 dedicati alla PEC
English
This module implements the PEC (Certified Email) transport channel for communication with the Italian Exchange System (SdI), as an alternative to Odoo’s standard IAP proxy.
It builds on l10n_it_edi_sdi for the shared notification processing and invoice reception logic, adding PEC-specific transport.
Main features:
Send electronic invoices to SdI via PEC
Receive PEC emails from SdI and route to appropriate handlers
PEC error handling with automatic notification to configured contacts and server auto-disable after repeated failures
Dedicated SMTP and IMAP/POP3 server configuration for PEC
Table of contents
Configuration
Italiano
Configurare un server SMTP in uscita per la PEC:
Andare in Impostazioni → Tecnico → Server di posta in uscita
Creare un nuovo server con i parametri del provider PEC
Spuntare “E-invoice PEC server”
Inserire l’indirizzo email PEC mittente
Configurare un server di posta in ingresso per la PEC:
Andare in Impostazioni → Tecnico → Server di posta in ingresso
Creare un nuovo server IMAP o POP3 con i parametri del provider PEC
Spuntare “E-invoice PEC server”
Configurare i contatti da notificare in caso di errore
Abilitare il canale PEC per l’azienda:
Andare in Impostazioni → Contabilità → Fatturazione elettronica
Spuntare “Use PEC for e-invoicing”
Selezionare i server PEC in uscita e in ingresso
Inserire l’indirizzo PEC del SdI
Il parametro di sistema fetchmail.pec.max.retry (default: 5) controlla il numero massimo di errori consecutivi prima che il server di posta in ingresso venga disabilitato automaticamente. Modificare il valore in Impostazioni → Tecnico → Parametri → Parametri di sistema se necessario.
English
Configure an outgoing PEC SMTP server:
Go to Settings → Technical → Outgoing Mail Servers
Create a new server with your PEC provider parameters
Check “E-invoice PEC server”
Enter the PEC sender email address
Configure an incoming PEC mail server:
Go to Settings → Technical → Incoming Mail Servers
Create a new IMAP or POP3 server with your PEC provider parameters
Check “E-invoice PEC server”
Configure contacts to notify on errors
Enable PEC channel for the company:
Go to Settings → Accounting → Italian Electronic Invoicing
Check “Use PEC for e-invoicing”
Select the outgoing and incoming PEC servers
Enter the SdI PEC email address
The system parameter fetchmail.pec.max.retry (default: 5) controls the maximum number of consecutive errors before the incoming mail server is automatically disabled. Change its value in Settings → Technical → Parameters → System Parameters if needed.
Usage
Italiano
Invio fatture
Le fatture vengono inviate al SdI tramite PEC quando si utilizza il normale flusso di invio fattura elettronica di Odoo. Il modulo intercetta l’invio e usa la PEC al posto del proxy IAP standard.
Ricezione notifiche
Le notifiche dal SdI vengono ricevute automaticamente tramite il cron di fetchmail. Lo stato della fattura viene aggiornato automaticamente in base alla notifica ricevuta:
RC (Ricevuta di Consegna) → Inoltrata al destinatario
NS (Notifica di Scarto) → Rifiutata
MC (Mancata Consegna) → Inoltro al destinatario fallito
NE (Notifica Esito) → Accettata/Rifiutata dal partner PA
DT (Decorrenza Termini) → Accettata per decorrenza termini
Ricezione fatture passive
Le fatture dei fornitori inviate tramite SdI vengono ricevute automaticamente via PEC e importate come fatture in bozza.
Verifica manuale stato
Il pulsante “Verifica stato” sulla fattura inviata avvia una lettura manuale della casella PEC per recuperare eventuali notifiche in attesa.
English
Sending invoices
Invoices are sent to SdI via PEC when using Odoo’s standard electronic invoice sending flow. The module intercepts the send and uses PEC instead of the standard IAP proxy.
Receiving notifications
SdI notifications are received automatically via the fetchmail cron. The invoice state is updated automatically based on the notification received:
RC (Delivery Receipt) → Forwarded to recipient
NS (Rejection) → Rejected
MC (Failed Delivery) → Forward to recipient failed
NE (Outcome Notification) → Accepted/Rejected by PA partner
DT (Deadline Expiry) → Accepted after term expiry
Receiving vendor bills
Vendor bills sent through SdI are automatically received via PEC and imported as draft invoices.
Manual status check
The “Check status” button on a sent invoice triggers a manual PEC mailbox read to retrieve any pending notifications.
Changelog
Migration from 16.0 (l10n_it_fatturapa_pec) to 18.0 (l10n_it_edi_pec)
This module replaces l10n_it_fatturapa_pec (Odoo 16) with a complete rewrite based on Odoo 18’s native l10n_it_edi architecture.
Name change and dependencies
The module was renamed from l10n_it_fatturapa_pec to l10n_it_edi_pec.
Dependencies were drastically simplified:
v16: l10n_it_fatturapa_out, l10n_it_fatturapa_in, l10n_it_sdi_channel, mail
v18: l10n_it_edi, mail
The modules l10n_it_fatturapa_out, l10n_it_fatturapa_in and l10n_it_sdi_channel are no longer needed.
Integration with l10n_it_edi core
The module now extends Odoo 18’s l10n_it_edi core methods instead of implementing a standalone flow:
_l10n_it_edi_upload() on account.move: intercepts sending for PEC-enabled companies and sends directly via SMTP, with fallback to super() for the proxy channel
_l10n_it_edi_update_send_state(): excludes PEC invoices from proxy polling
_l10n_it_edi_export_check(): validates PEC configuration and removes the proxy user requirement
action_check_l10n_it_edi(): triggers PEC fetchmail for manual status check
Removed sdi.channel model
The sdi.channel model has been completely removed. PEC configuration is now managed directly on res.company through the fields:
l10n_it_edi_use_pec (Boolean)
l10n_it_edi_pec_server_id (Many2one -> ir.mail_server)
l10n_it_edi_pec_fetch_server_id (Many2one -> fetchmail.server)
l10n_it_edi_pec_email_exchange_system (Char)
These fields are exposed in Settings via res.config.settings. The views sdi_view.xml and company_view.xml are replaced by res_config_settings_views.xml.
Removed fatturapa.attachment.out model
In v16, fatturapa.attachment.out managed the lifecycle of sent invoices and SdI notification parsing (_message_type_ns, _message_type_rc, etc.). In v18, the entire flow is handled directly on account.move through the core notification chain:
_l10n_it_edi_parse_notification() -> _l10n_it_edi_transform_notification() -> _l10n_it_edi_get_message() -> _l10n_it_edi_write_send_state()
Removed fatturapa.attachment.in model
Incoming vendor bill reception no longer uses fatturapa.attachment.in. The module now directly creates an empty account.move, attaches the XML file and calls move._extend_with_attachments() to populate fields from the electronic invoice.
SdI state mapping
State mapping has changed to align with the l10n_it_edi core:
SdI Code |
v16 (fatturapa.attachment.out) |
v18 (account.move) |
|---|---|---|
NS (Notifica di Scarto) |
sender_error |
rejected |
RC (Ricevuta di Consegna) |
validated |
forwarded |
MC (Mancata Consegna) |
recipient_error |
forward_failed |
NE (Notifica Esito) |
accepted / rejected |
accepted / rejected |
DT (Decorrenza Termini) |
validated |
accepted |
Removed first_invoice_sent flow
The first PEC sending management mechanism (first_invoice_sent field on sdi.channel, initial address sdi01@pec.fatturapa.it and automatic address change after first sending) has been removed. The SdI PEC address must now be configured directly in the l10n_it_edi_pec_email_exchange_system field.
Simplified sending mechanism
v16: sdi.channel.send_via_pec() created mail.message and mail.mail records, then delegated sending to Odoo’s mail system
v18: _l10n_it_edi_upload() directly builds a Python EmailMessage and sends it via ir.mail_server.send_email(), without creating intermediate database records
Field renames
v16 |
v18 |
|---|---|
is_fatturapa_pec |
is_l10n_it_edi_pec |
email_from_for_fatturaPA |
l10n_it_edi_pec_email_from |
Tests
The test base class changed from FatturaPACommon (l10n_it_fatturapa_out.tests) to TestItEdi (l10n_it_edi.tests.common), consistent with the new core extension pattern.
Bug Tracker
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed feedback.
Do not contact contributors directly about support or help with technical issues.
Credits
Contributors
Andrea Colangelo (andreacolangelo@openforce.it)
Sergio Corato https://efatto.it
Lorenzo Battistini https://github.com/eLBati
Sergio Zanchetta (Associazione PNLUG - Gruppo Odoo)
Roberto Fichera https://levelprime.com
Simone Rubino
Maintainers
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
This module is part of the OCA/l10n-italy project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file odoo_addon_l10n_it_edi_pec-18.0.1.0.0.2-py3-none-any.whl.
File metadata
- Download URL: odoo_addon_l10n_it_edi_pec-18.0.1.0.0.2-py3-none-any.whl
- Upload date:
- Size: 200.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13166e9b0884e6a647df72fd5dc202d1e70c0d9f9fde01128b673eeab78c0ebb
|
|
| MD5 |
5dc2aebdba1986efe1495becc5abdfad
|
|
| BLAKE2b-256 |
0987c52961503098ef12283e80b671d0323ae74fd0c409d7b54ac18785fee3bd
|