From 1278ca42977814d7792458f0277609553667db6b Mon Sep 17 00:00:00 2001
From: eLBati
Date: Mon, 12 Nov 2018 16:15:07 +0100
Subject: [PATCH 01/65] IMP README, SDI , attachment and invoice view FIX Mail
delivery failed via SMTP server 'smtps.pec.aruba.it'. SMTPRecipientsRefused:
{'agilebg@pec.it': (553, '5.7.1
: Sender address rejected:
not owned by user l.battistini@pec.it')} Traceback (most recent call last):
File
"/home/elbati/workspace/odoo/instances/demo10-community/parts/odoo/addons/mail/models/mail_mail.py",
line 278, in send res = IrMailServer.send_email(msg,
mail_server_id=mail.mail_server_id.id) File
"/home/elbati/workspace/odoo/instances/demo10-community/parts/odoo/odoo/addons/base/ir/ir_mail_server.py",
line 467, in send_email raise MailDeliveryException(_("Mail Delivery
Failed"), msg) MailDeliveryException: (u'Mail Delivery Failed', u"Mail
delivery failed via SMTP server 'smtps.pec.aruba.it'.\nSMTPRecipientsRefused:
{'agilebg@pec.it': (553, '5.7.1
: Sender address rejected:
not owned by user l.battistini@pec.it')}")
ADD l10n_it_fatturapa_out: tracking attachment changes
IMP mail send: raise exception in case
[IMP] default is_fatturapa_pec and split class
REF mergin l10n_it_fatturapa_in_pec and l10n_it_fatturapa_out_pec in l10n_it_fatturapa_pec
REF mergin l10n_it_fatturapa_in_pec and l10n_it_fatturapa_out_pec in l10n_it_fatturapa_pec
FIX default_is_fatturapa_pec
---
l10n_it_fatturapa_pec/README.rst | 91 ++++
l10n_it_fatturapa_pec/__init__.py | 4 +
l10n_it_fatturapa_pec/__manifest__.py | 26 ++
l10n_it_fatturapa_pec/models/__init__.py | 6 +
l10n_it_fatturapa_pec/models/account.py | 36 ++
.../models/fatturapa_attachment_out.py | 206 +++++++++
l10n_it_fatturapa_pec/models/mail_thread.py | 141 ++++++
l10n_it_fatturapa_pec/readme/CONFIGURE.rst | 1 +
l10n_it_fatturapa_pec/readme/CONTRIBUTORS.rst | 3 +
l10n_it_fatturapa_pec/readme/DESCRIPTION.rst | 5 +
l10n_it_fatturapa_pec/readme/USAGE.rst | 3 +
.../static/description/icon.png | Bin 0 -> 4829 bytes
.../static/description/index.html | 435 ++++++++++++++++++
l10n_it_fatturapa_pec/views/account.xml | 41 ++
.../views/fatturapa_attachment_out.xml | 44 ++
15 files changed, 1042 insertions(+)
create mode 100644 l10n_it_fatturapa_pec/README.rst
create mode 100644 l10n_it_fatturapa_pec/__init__.py
create mode 100644 l10n_it_fatturapa_pec/__manifest__.py
create mode 100644 l10n_it_fatturapa_pec/models/__init__.py
create mode 100644 l10n_it_fatturapa_pec/models/account.py
create mode 100644 l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py
create mode 100644 l10n_it_fatturapa_pec/models/mail_thread.py
create mode 100644 l10n_it_fatturapa_pec/readme/CONFIGURE.rst
create mode 100644 l10n_it_fatturapa_pec/readme/CONTRIBUTORS.rst
create mode 100644 l10n_it_fatturapa_pec/readme/DESCRIPTION.rst
create mode 100644 l10n_it_fatturapa_pec/readme/USAGE.rst
create mode 100644 l10n_it_fatturapa_pec/static/description/icon.png
create mode 100644 l10n_it_fatturapa_pec/static/description/index.html
create mode 100644 l10n_it_fatturapa_pec/views/account.xml
create mode 100644 l10n_it_fatturapa_pec/views/fatturapa_attachment_out.xml
diff --git a/l10n_it_fatturapa_pec/README.rst b/l10n_it_fatturapa_pec/README.rst
new file mode 100644
index 000000000000..a222cf0abfe5
--- /dev/null
+++ b/l10n_it_fatturapa_pec/README.rst
@@ -0,0 +1,91 @@
+=========================================================
+Italian Localization - FatturaPA - Emission - PEC Support
+=========================================================
+
+.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ !! This file is generated by oca-gen-addon-readme !!
+ !! changes will be overwritten. !!
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
+ :target: https://odoo-community.org/page/development-status
+ :alt: Beta
+.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
+ :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
+ :alt: License: LGPL-3
+.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github
+ :target: https://github.com/OCA/l10n-italy/tree/10.0/l10n_it_fatturapa_pec
+ :alt: OCA/l10n-italy
+.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
+ :target: https://translation.odoo-community.org/projects/l10n-italy-10-0/l10n-italy-10-0-l10n_it_fatturapa_pec
+ :alt: Translate me on Weblate
+.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
+ :target: https://runbot.odoo-community.org/runbot/122/10.0
+ :alt: Try me on Runbot
+
+|badge1| |badge2| |badge3| |badge4| |badge5|
+
+This module allows you to send and receive electronic invoice XML file version 1.2
+http://www.fatturapa.gov.it/export/fatturazione/en/sdi.htm
+via PEC
+
+Notifications from SDI are parsed and transmission state is tracked.
+
+**Table of contents**
+
+.. contents::
+ :local:
+
+Configuration
+=============
+
+See `l10n_it_sdi_channel` module
+
+Usage
+=====
+
+In electronic invoice out attachment you can click "Send Via PEC" button.
+
+Supplier electronic invoices are automatically created, fetched from PEC mailbox.
+
+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 smashing it by providing a detailed and welcomed
+`feedback `_.
+
+Do not contact contributors directly about support or help with technical issues.
+
+Credits
+=======
+
+Authors
+~~~~~~~
+
+* Openforce Srls Unipersonale
+
+Contributors
+~~~~~~~~~~~~
+
+* Andrea Colangelo
+* Sergio Corato
+* Lorenzo Battistini
+
+Maintainers
+~~~~~~~~~~~
+
+This module is maintained by the OCA.
+
+.. image:: https://odoo-community.org/logo.png
+ :alt: Odoo Community Association
+ :target: https://odoo-community.org
+
+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.
diff --git a/l10n_it_fatturapa_pec/__init__.py b/l10n_it_fatturapa_pec/__init__.py
new file mode 100644
index 000000000000..b44d765940f6
--- /dev/null
+++ b/l10n_it_fatturapa_pec/__init__.py
@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
+
+from . import models
diff --git a/l10n_it_fatturapa_pec/__manifest__.py b/l10n_it_fatturapa_pec/__manifest__.py
new file mode 100644
index 000000000000..a7fe939942d6
--- /dev/null
+++ b/l10n_it_fatturapa_pec/__manifest__.py
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+# Author(s): Andrea Colangelo (andreacolangelo@openforce.it)
+# Copyright 2018 Openforce Srls Unipersonale (www.openforce.it)
+# Copyright 2018 Sergio Corato (https://efatto.it)
+# Copyright 2018 Lorenzo Battistini
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
+{
+ 'name': 'Italian Localization - FatturaPA - Emission - PEC Support',
+ 'version': '10.0.1.0.0',
+ 'category': 'Localization/Italy',
+ 'summary': 'Send electronic invoices via PEC',
+ 'author': 'Openforce Srls Unipersonale, Odoo Community Association (OCA)',
+ 'website': 'https://github.com/OCA/l10n-italy',
+ 'license': 'LGPL-3',
+ 'depends': [
+ 'fetchmail',
+ 'l10n_it_fatturapa_out',
+ 'l10n_it_fatturapa_in',
+ 'l10n_it_sdi_channel',
+ ],
+ 'data': [
+ 'views/account.xml',
+ 'views/fatturapa_attachment_out.xml',
+ ],
+ 'installable': True
+}
diff --git a/l10n_it_fatturapa_pec/models/__init__.py b/l10n_it_fatturapa_pec/models/__init__.py
new file mode 100644
index 000000000000..f3079e86bf08
--- /dev/null
+++ b/l10n_it_fatturapa_pec/models/__init__.py
@@ -0,0 +1,6 @@
+# -*- coding: utf-8 -*-
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
+
+from . import account
+from . import fatturapa_attachment_out
+from . import mail_thread
diff --git a/l10n_it_fatturapa_pec/models/account.py b/l10n_it_fatturapa_pec/models/account.py
new file mode 100644
index 000000000000..428f3790088e
--- /dev/null
+++ b/l10n_it_fatturapa_pec/models/account.py
@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+# Author(s): Andrea Colangelo (andreacolangelo@openforce.it)
+# Copyright © 2018 Openforce Srls Unipersonale (www.openforce.it)
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
+
+
+from odoo import api, fields, models
+
+
+class AccountInvoice(models.Model):
+ _inherit = 'account.invoice'
+
+ fatturapa_state = fields.Selection(
+ [('ready', 'Ready to Send'),
+ ('sent', 'Sent'),
+ ('delivered', 'Delivered'),
+ ('error', 'Error')],
+ string='E-invoice State',
+ compute='compute_fatturapa_state',
+ store='true',
+ )
+
+ @api.multi
+ @api.depends('fatturapa_attachment_out_id.state')
+ def compute_fatturapa_state(self):
+ mapping = {
+ 'ready': 'ready',
+ 'sent': 'sent',
+ 'validated': 'delivered',
+ 'sender_error': 'error',
+ 'recipient_error': 'error',
+ 'rejected': 'error'
+ }
+ for record in self:
+ record.fatturapa_state = \
+ mapping.get(record.fatturapa_attachment_out_id.state)
diff --git a/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py b/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py
new file mode 100644
index 000000000000..206f6861f0c7
--- /dev/null
+++ b/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py
@@ -0,0 +1,206 @@
+# -*- coding: utf-8 -*-
+# Author(s): Andrea Colangelo (andreacolangelo@openforce.it)
+# Copyright © 2018 Openforce Srls Unipersonale (www.openforce.it)
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
+
+import logging
+import re
+
+from lxml import etree
+
+from odoo import api, fields, models
+
+_logger = logging.getLogger(__name__)
+
+RESPONSE_MAIL_REGEX = '[A-Z]{2}[a-zA-Z0-9]{11,16}_[a-zA-Z0-9]{,5}_[A-Z]{2}_' \
+ '[a-zA-Z0-9]{,3}'
+
+
+class FatturaPAAttachmentOut(models.Model):
+ _inherit = 'fatturapa.attachment.out'
+
+ state = fields.Selection([('ready', 'Ready to Send'),
+ ('sent', 'Sent'),
+ ('validated', 'Delivered'),
+ ('sender_error', 'Sender Error'),
+ ('recipient_error', 'Recipient Error'),
+ ('rejected', 'Rejected (PA)')],
+ string='State',
+ default='ready',)
+
+ last_sdi_response = fields.Text(
+ string='Last Response from Exchange System', default='No response yet')
+
+ @api.multi
+ def send_via_pec(self):
+
+ mail_message = self.env['mail.message'].create({
+ 'model': self._name,
+ 'res_id': self.id,
+ 'subject': self.name,
+ 'body': 'XML file for FatturaPA {} sent to Exchange System to the'
+ ' email address {}.'
+ .format(
+ self.name,
+ self.env.user.company_id.email_exchange_system),
+ 'attachment_ids': [(6, 0, self.ir_attachment_id.ids)],
+ 'email_from': self.env.user.company_id.email_from_for_fatturaPA,
+ 'mail_server_id': self.env.user.company_id.sdi_channel_id.
+ pec_server_id.id,
+ })
+
+ mail = self.env['mail.mail'].create({
+ 'mail_message_id': mail_message.id,
+ 'body_html': mail_message.body,
+ 'email_to': self.env.user.company_id.email_exchange_system,
+ })
+
+ if mail:
+ config_parameter = self.env['ir.config_parameter'].sudo()
+ bounce_alias = config_parameter.get_param("mail.bounce.alias")
+ catchall_domain = config_parameter.get_param("mail.catchall.domain")
+ catchall_alias = config_parameter.get_param("mail.catchall.alias")
+ # temporary disable email parameters incompatible with PEC
+ if bounce_alias:
+ config_parameter.set_param('mail.bounce.alias', False)
+ if catchall_domain:
+ config_parameter.set_param('mail.catchall.domain', False)
+ if catchall_alias:
+ config_parameter.set_param('mail.catchall.alias', False)
+
+ res = mail.send(raise_exception=True)
+
+ if bounce_alias:
+ config_parameter.set_param(
+ 'mail.bounce.alias', bounce_alias)
+ if catchall_domain:
+ config_parameter.set_param(
+ 'mail.catchall.domain', catchall_domain)
+ if catchall_alias:
+ config_parameter.set_param(
+ 'mail.catchall.alias', catchall_alias)
+
+ if res:
+ self.state = 'sent'
+
+ @api.multi
+ def parse_pec_response(self, message_dict):
+ message_dict['model'] = self._name
+ message_dict['res_id'] = 0
+
+ regex = re.compile(RESPONSE_MAIL_REGEX)
+ attachments = [x for x in message_dict['attachments']
+ if regex.match(x.fname)]
+
+ for attachment in attachments:
+ response_name = attachment.fname
+ message_type = response_name.split('_')[2]
+ if attachment.fname.lower().endswith('.zip'):
+ # not implemented, case of AT, todo
+ continue
+ root = etree.fromstring(attachment.content)
+ file_name = root.find('NomeFile')
+ fatturapa_attachment_out = False
+
+ if file_name is not None:
+ file_name = file_name.text
+ fatturapa_attachment_out = self.search(
+ ['|',
+ ('datas_fname', '=', file_name),
+ ('datas_fname', '=', file_name.replace('.p7m', ''))])
+ if len(fatturapa_attachment_out) > 1:
+ _logger.info('More than 1 out invoice found for incoming'
+ 'message')
+ fatturapa_attachment_out = fatturapa_attachment_out[0]
+ if not fatturapa_attachment_out:
+ if message_type == 'MT': # Metadati
+ # out invoice not found, so it is an incoming invoice
+ return message_dict
+ else:
+ _logger.info('Error: FatturaPA {} not found.'.format(
+ file_name))
+ # TODO Send a mail warning
+ return message_dict
+
+ if fatturapa_attachment_out:
+ id_sdi = root.find('IdentificativoSdI')
+ receipt_dt = root.find('DataOraRicezione')
+ message_id = root.find('MessageId')
+ id_sdi = id_sdi.text if id_sdi is not None else False
+ receipt_dt = receipt_dt.text if receipt_dt is not None \
+ else False
+ message_id = message_id.text if message_id is not None \
+ else False
+ if message_type == 'NS': # 2A. Notifica di Scarto
+ error_list = root.find('ListaErrori').text
+ fatturapa_attachment_out.write({
+ 'state': 'sender_error',
+ 'last_sdi_response': 'SdI ID: {}; '
+ 'Message ID: {}; Receipt date: {}; '
+ 'Error: {}'.format(
+ id_sdi, message_id, receipt_dt, error_list)
+ })
+ elif message_type == 'MC': # 3A. Mancata consegna
+ missed_delivery_note = root.find('Descrizione').text
+ fatturapa_attachment_out.write({
+ 'state': 'recipient_error',
+ 'last_sdi_response': 'SdI ID: {}; '
+ 'Message ID: {}; Receipt date: {}; '
+ 'Missed delivery note: {}'.format(
+ id_sdi, message_id, receipt_dt,
+ missed_delivery_note)
+ })
+ elif message_type == 'RC': # 3B. Ricevuta di Consegna
+ delivery_dt = root.find('DataOraConsegna').text
+ fatturapa_attachment_out.write({
+ 'state': 'validated',
+ 'last_sdi_response': 'SdI ID: {}; '
+ 'Message ID: {}; Receipt date: {}; '
+ 'Delivery date: {}'.format(
+ id_sdi, message_id, receipt_dt, delivery_dt)
+ })
+ elif message_type == 'NE': # 4A. Notifica Esito per PA
+ esito_committente = root.find('EsitoCommittente')
+ if esito_committente is not None:
+ # more than one esito?
+ id_sdi_esito = esito_committente.find(
+ 'IdentificativoSdI')
+ esito = esito_committente.find(
+ 'Esito')
+ if esito is not None:
+ if esito.text == 'EC01':
+ state = 'validated'
+ elif esito.text == 'EC02':
+ state = 'rejected'
+ fatturapa_attachment_out.write({
+ 'state': state,
+ 'last_sdi_response': 'SdI ID: {}; '
+ 'Message ID: {}; Response: {}; '.format(
+ id_sdi, message_id, esito.text)
+ })
+ elif message_type == 'DT': # 5. Decorrenza Termini per PA
+ description = root.find('Descrizione')
+ if description is not None:
+ fatturapa_attachment_out.write({
+ 'state': 'validated',
+ 'last_sdi_response': 'SdI ID: {}; '
+ 'Message ID: {}; Receipt date: {}; '
+ 'Description: {}'.format(
+ id_sdi, message_id, receipt_dt,
+ description.text)
+ })
+ # not implemented - todo
+ elif message_type == 'AT': # 6. Avvenuta Trasmissione per PA
+ description = root.find('Descrizione')
+ if description is not None:
+ fatturapa_attachment_out.write({
+ 'state': 'validated',
+ 'last_sdi_response': 'SdI ID: {}; '
+ 'Message ID: {}; Receipt date: {}; '
+ 'Description: {}'.format(
+ id_sdi, message_id, receipt_dt,
+ description.text)
+ })
+
+ message_dict['res_id'] = fatturapa_attachment_out.id
+ return message_dict
diff --git a/l10n_it_fatturapa_pec/models/mail_thread.py b/l10n_it_fatturapa_pec/models/mail_thread.py
new file mode 100644
index 000000000000..7b4152490df5
--- /dev/null
+++ b/l10n_it_fatturapa_pec/models/mail_thread.py
@@ -0,0 +1,141 @@
+# -*- coding: utf-8 -*-
+# Author(s): Andrea Colangelo (andreacolangelo@openforce.it)
+# Copyright 2018 Openforce Srls Unipersonale (www.openforce.it)
+# Copyright 2018 Sergio Corato (https://efatto.it)
+# Copyright 2018 Lorenzo Battistini
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
+
+import logging
+import re
+import base64
+import zipfile
+import io
+
+from odoo import api, models
+
+_logger = logging.getLogger(__name__)
+
+FATTURAPA_IN_REGEX = "^[A-Z]{2}[a-zA-Z0-9]{11,16}_[a-zA-Z0-9]{,5}.(xml|zip)"
+RESPONSE_MAIL_REGEX = '[A-Z]{2}[a-zA-Z0-9]{11,16}_[a-zA-Z0-9]{,5}_MT_' \
+ '[a-zA-Z0-9]{,3}'
+
+
+class MailThread(models.AbstractModel):
+ _inherit = 'mail.thread'
+
+ @api.model
+ def message_route(self, message, message_dict, model=None, thread_id=None,
+ custom_values=None):
+ if any("@pec.fatturapa.it" in x for x in [
+ message.get('Reply-To', ''),
+ message.get('From', ''),
+ message.get('Return-Path', '')]
+ ):
+ _logger.info("Processing FatturaPA PEC with Message-Id: "
+ "{}".format(message.get('Message-Id')))
+
+ fatturapa_regex = re.compile(FATTURAPA_IN_REGEX)
+ fatturapa_attachments = [x for x in message_dict['attachments']
+ if fatturapa_regex.match(x.fname)]
+ response_regex = re.compile(RESPONSE_MAIL_REGEX)
+ response_attachments = [x for x in message_dict['attachments']
+ if response_regex.match(x.fname)]
+ if response_attachments and fatturapa_attachments:
+ # this is an electronic invoice
+ if len(response_attachments) > 1:
+ _logger.info(
+ 'More than 1 message found in mail of incoming '
+ 'invoice')
+ message_dict['model'] = 'fatturapa.attachment.in'
+ message_dict['record_name'] = message_dict['subject']
+ message_dict['res_id'] = 0
+ attachment_ids = self._message_post_process_attachments(
+ message_dict['attachments'], [], message_dict)
+ for attachment in self.env['ir.attachment'].browse(
+ [att_id for model, att_id in attachment_ids]):
+ if fatturapa_regex.match(attachment.name):
+ self.create_fatturapa_attachment_in(attachment)
+
+ message_dict['attachment_ids'] = attachment_ids
+ del message_dict['attachments']
+ del message_dict['cc']
+ del message_dict['from']
+ del message_dict['to']
+
+ # model and res_id are only needed by
+ # _message_post_process_attachments: we don't attach to
+ del message_dict['model']
+ del message_dict['res_id']
+
+ # message_create_from_mail_mail to avoid to notify message
+ # (see mail.message.create)
+ self.env['mail.message'].with_context(
+ message_create_from_mail_mail=True).create(message_dict)
+ _logger.info('Routing FatturaPA PEC E-Mail with Message-Id: {}'
+ .format(message.get('Message-Id')))
+ return []
+
+ else:
+ # this is an SDI notification
+ message_dict = self.env['fatturapa.attachment.out']\
+ .parse_pec_response(message_dict)
+
+ message_dict['record_name'] = message_dict['subject']
+ attachment_ids = self._message_post_process_attachments(
+ message_dict['attachments'], [], message_dict)
+ message_dict['attachment_ids'] = attachment_ids
+ del message_dict['attachments']
+ del message_dict['cc']
+ del message_dict['from']
+ del message_dict['to']
+
+ # message_create_from_mail_mail to avoid to notify message
+ # (see mail.message.create)
+ self.env['mail.message'].with_context(
+ message_create_from_mail_mail=True).create(message_dict)
+ _logger.info('Routing FatturaPA PEC E-Mail with Message-Id: {}'
+ .format(message.get('Message-Id')))
+ return []
+
+ elif self._context.get('fetchmail_server_id', False):
+ fetchmail_server_id = self.env['fetchmail.server'].browse(
+ self._context['fetchmail_server_id'])
+ if fetchmail_server_id.is_fatturapa_pec:
+ # todo send email for non-routable pec mail
+ return []
+
+ return super(MailThread, self).message_route(
+ message, message_dict, model=model, thread_id=thread_id,
+ custom_values=custom_values)
+
+ def create_fatturapa_attachment_in(self, attachment):
+ decoded = base64.b64decode(attachment.datas)
+ fatturapa_regex = re.compile(FATTURAPA_IN_REGEX)
+ fatturapa_attachment_in = self.env['fatturapa.attachment.in']
+ if attachment.mimetype == 'application/zip':
+ with zipfile.ZipFile(io.BytesIO(decoded)) as zf:
+ for file_name in zf.namelist():
+ inv_file = zf.open(file_name)
+ if fatturapa_regex.match(file_name):
+ # check if this invoice is already
+ # in other fatturapa.attachment.in
+ fatturapa_atts = fatturapa_attachment_in.search([
+ ('name', '=', file_name)])
+ if fatturapa_atts:
+ _logger.info("In invoice %s already processed"
+ % fatturapa_atts.mapped('name'))
+ else:
+ fatturapa_attachment_in.create({
+ 'name': file_name,
+ 'datas_fname': file_name,
+ 'datas': base64.encodestring(inv_file.read())})
+ else:
+ fatturapa_atts = fatturapa_attachment_in.search(
+ [('name', '=', attachment.name)])
+ if fatturapa_atts:
+ _logger.info(
+ "Invoice xml already processed in %s"
+ % fatturapa_atts.mapped('name'))
+ else:
+ fatturapa_attachment_in.create({
+ 'ir_attachment_id': attachment.id})
diff --git a/l10n_it_fatturapa_pec/readme/CONFIGURE.rst b/l10n_it_fatturapa_pec/readme/CONFIGURE.rst
new file mode 100644
index 000000000000..e57ec1281819
--- /dev/null
+++ b/l10n_it_fatturapa_pec/readme/CONFIGURE.rst
@@ -0,0 +1 @@
+See `l10n_it_sdi_channel` module
diff --git a/l10n_it_fatturapa_pec/readme/CONTRIBUTORS.rst b/l10n_it_fatturapa_pec/readme/CONTRIBUTORS.rst
new file mode 100644
index 000000000000..7f63b79cc053
--- /dev/null
+++ b/l10n_it_fatturapa_pec/readme/CONTRIBUTORS.rst
@@ -0,0 +1,3 @@
+* Andrea Colangelo
+* Sergio Corato
+* Lorenzo Battistini
diff --git a/l10n_it_fatturapa_pec/readme/DESCRIPTION.rst b/l10n_it_fatturapa_pec/readme/DESCRIPTION.rst
new file mode 100644
index 000000000000..aaab749107ef
--- /dev/null
+++ b/l10n_it_fatturapa_pec/readme/DESCRIPTION.rst
@@ -0,0 +1,5 @@
+This module allows you to send and receive electronic invoice XML file version 1.2
+http://www.fatturapa.gov.it/export/fatturazione/en/sdi.htm
+via PEC
+
+Notifications from SDI are parsed and transmission state is tracked.
diff --git a/l10n_it_fatturapa_pec/readme/USAGE.rst b/l10n_it_fatturapa_pec/readme/USAGE.rst
new file mode 100644
index 000000000000..51a873129961
--- /dev/null
+++ b/l10n_it_fatturapa_pec/readme/USAGE.rst
@@ -0,0 +1,3 @@
+In electronic invoice out attachment you can click "Send Via PEC" button.
+
+Supplier electronic invoices are automatically created, fetched from PEC mailbox.
diff --git a/l10n_it_fatturapa_pec/static/description/icon.png b/l10n_it_fatturapa_pec/static/description/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..1f07394c3b7990a313c758a4aaf6eab53e23e072
GIT binary patch
literal 4829
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
r8aiT|hVCWM^FKV(3jG&l)t9W+$TKay
+
+
+
+
+
+Italian Localization - FatturaPA - Emission - PEC Support
+
+
+
+
+
Italian Localization - FatturaPA - Emission - PEC Support
+
+
+
+
This module allows you to send and receive electronic invoice XML file version 1.2
+http://www.fatturapa.gov.it/export/fatturazione/en/sdi.htm
+via PEC
+
Notifications from SDI are parsed and transmission state is tracked.
+
Table of contents
+
+
+
+
See l10n_it_sdi_channel module
+
+
+
+
In electronic invoice out attachment you can click “Send Via PEC” button.
+
Supplier electronic invoices are automatically created, fetched from PEC mailbox.
+
+
+
+
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 smashing it by providing a detailed and welcomed
+feedback.
+
Do not contact contributors directly about support or help with technical issues.
+
+
+
+
+
+
+- Openforce Srls Unipersonale
+
+
+
+
+
+
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.
+
+
+
+
+
diff --git a/l10n_it_fatturapa_pec/views/account.xml b/l10n_it_fatturapa_pec/views/account.xml
new file mode 100644
index 000000000000..7a377a1b2ec0
--- /dev/null
+++ b/l10n_it_fatturapa_pec/views/account.xml
@@ -0,0 +1,41 @@
+
+
+
+ view.invoice.fatturapa.out.pec.tree
+ account.invoice
+
+
+
+
+
+
+
+
+
+ view.invoice.fatturapa.out.pec.form
+ account.invoice
+
+
+
+
+
+
+
+
+
+ view.account.invoice.fatturapa.out.pec.filter
+ account.invoice
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/l10n_it_fatturapa_pec/views/fatturapa_attachment_out.xml b/l10n_it_fatturapa_pec/views/fatturapa_attachment_out.xml
new file mode 100644
index 000000000000..afd840d8825d
--- /dev/null
+++ b/l10n_it_fatturapa_pec/views/fatturapa_attachment_out.xml
@@ -0,0 +1,44 @@
+
+
+
+
+ fatturapa.attachment.out.form
+ fatturapa.attachment.out
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ view_fatturapa_out_attachment_tree_state
+ fatturapa.attachment.out
+
+
+
+
+
+
+
+
+ view_fatturapa_out_attachment_search_state
+ fatturapa.attachment.out
+
+
+
+
+
+
+
+
+
From ce4eb1266957ff473bfa9c5e332a4024bac53226 Mon Sep 17 00:00:00 2001
From: sergio
Date: Mon, 12 Nov 2018 23:53:21 +0100
Subject: [PATCH 02/65] [FIX] ensure one
[FIX] hide domain
---
l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py b/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py
index 206f6861f0c7..5a3ff3bf6606 100644
--- a/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py
+++ b/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py
@@ -33,7 +33,7 @@ class FatturaPAAttachmentOut(models.Model):
@api.multi
def send_via_pec(self):
-
+ self.ensure_one()
mail_message = self.env['mail.message'].create({
'model': self._name,
'res_id': self.id,
From 88cdd23f67e426ae56da238e696c5172165f9701 Mon Sep 17 00:00:00 2001
From: eLBati
Date: Tue, 13 Nov 2018 15:12:09 +0100
Subject: [PATCH 03/65] IMP README exceptions sending email Avoid to delete
sent files Check duplicated files Send several files Reset to ready button
Sending and delivery date Handling ACCETTAZIONE and CONSEGNA IMP 'link to
existing invoice' wizard FIX invoice views within attachment view IMP
attachments views IMP l10n_it_fatturapa_out export: allow multiple export ,
group by partner ALLOW to use newline char in invoice line description check
sequence without date ranges Extract correcttle messages from NS
---
l10n_it_fatturapa_pec/__init__.py | 3 +-
l10n_it_fatturapa_pec/__manifest__.py | 5 +-
l10n_it_fatturapa_pec/models/__init__.py | 2 +-
l10n_it_fatturapa_pec/models/account.py | 2 +-
.../models/fatturapa_attachment_out.py | 167 +++++++++++-------
l10n_it_fatturapa_pec/models/mail_thread.py | 47 +++--
.../views/fatturapa_attachment_out.xml | 22 +++
l10n_it_fatturapa_pec/wizard/__init__.py | 4 +
l10n_it_fatturapa_pec/wizard/send_pec.py | 16 ++
.../wizard/send_pec_view.xml | 30 ++++
10 files changed, 223 insertions(+), 75 deletions(-)
create mode 100644 l10n_it_fatturapa_pec/wizard/__init__.py
create mode 100644 l10n_it_fatturapa_pec/wizard/send_pec.py
create mode 100644 l10n_it_fatturapa_pec/wizard/send_pec_view.xml
diff --git a/l10n_it_fatturapa_pec/__init__.py b/l10n_it_fatturapa_pec/__init__.py
index b44d765940f6..76ad875773a0 100644
--- a/l10n_it_fatturapa_pec/__init__.py
+++ b/l10n_it_fatturapa_pec/__init__.py
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
-# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
+# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
from . import models
+from . import wizard
diff --git a/l10n_it_fatturapa_pec/__manifest__.py b/l10n_it_fatturapa_pec/__manifest__.py
index a7fe939942d6..b8c56b377c8a 100644
--- a/l10n_it_fatturapa_pec/__manifest__.py
+++ b/l10n_it_fatturapa_pec/__manifest__.py
@@ -3,10 +3,10 @@
# Copyright 2018 Openforce Srls Unipersonale (www.openforce.it)
# Copyright 2018 Sergio Corato (https://efatto.it)
# Copyright 2018 Lorenzo Battistini
-# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
+# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
{
'name': 'Italian Localization - FatturaPA - Emission - PEC Support',
- 'version': '10.0.1.0.0',
+ 'version': '10.0.1.1.0',
'category': 'Localization/Italy',
'summary': 'Send electronic invoices via PEC',
'author': 'Openforce Srls Unipersonale, Odoo Community Association (OCA)',
@@ -21,6 +21,7 @@
'data': [
'views/account.xml',
'views/fatturapa_attachment_out.xml',
+ 'wizard/send_pec_view.xml',
],
'installable': True
}
diff --git a/l10n_it_fatturapa_pec/models/__init__.py b/l10n_it_fatturapa_pec/models/__init__.py
index f3079e86bf08..2299b9b3bda3 100644
--- a/l10n_it_fatturapa_pec/models/__init__.py
+++ b/l10n_it_fatturapa_pec/models/__init__.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
+# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
from . import account
from . import fatturapa_attachment_out
diff --git a/l10n_it_fatturapa_pec/models/account.py b/l10n_it_fatturapa_pec/models/account.py
index 428f3790088e..a378021c5848 100644
--- a/l10n_it_fatturapa_pec/models/account.py
+++ b/l10n_it_fatturapa_pec/models/account.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# Author(s): Andrea Colangelo (andreacolangelo@openforce.it)
# Copyright © 2018 Openforce Srls Unipersonale (www.openforce.it)
-# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
+# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
from odoo import api, fields, models
diff --git a/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py b/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py
index 5a3ff3bf6606..5b270e57f90f 100644
--- a/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py
+++ b/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py
@@ -1,14 +1,18 @@
# -*- coding: utf-8 -*-
# Author(s): Andrea Colangelo (andreacolangelo@openforce.it)
-# Copyright © 2018 Openforce Srls Unipersonale (www.openforce.it)
-# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
+# Copyright 2018 Openforce Srls Unipersonale (www.openforce.it)
+# Copyright 2018 Sergio Corato (https://efatto.it)
+# Copyright 2018 Lorenzo Battistini
+# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
import logging
import re
from lxml import etree
-from odoo import api, fields, models
+from odoo import api, fields, models, _
+from odoo.exceptions import UserError
+from odoo.addons.base.ir.ir_mail_server import MailDeliveryException
_logger = logging.getLogger(__name__)
@@ -21,67 +25,89 @@ class FatturaPAAttachmentOut(models.Model):
state = fields.Selection([('ready', 'Ready to Send'),
('sent', 'Sent'),
- ('validated', 'Delivered'),
('sender_error', 'Sender Error'),
('recipient_error', 'Recipient Error'),
- ('rejected', 'Rejected (PA)')],
+ ('rejected', 'Rejected (PA)'),
+ ('validated', 'Delivered'),
+ ],
string='State',
default='ready',)
last_sdi_response = fields.Text(
- string='Last Response from Exchange System', default='No response yet')
+ string='Last Response from Exchange System', default='No response yet',
+ readonly=True)
+ sending_date = fields.Datetime("Sent date", readonly=True)
+ delivered_date = fields.Datetime("Delivered date", readonly=True)
+ sending_user = fields.Many2one("res.users", "Sending user", readonly=True)
+
+ @api.multi
+ def reset_to_ready(self):
+ for att in self:
+ if att.state != 'sender_error':
+ raise UserError(_("Yo can only reset 'sender error' files"))
+ att.state = 'ready'
@api.multi
def send_via_pec(self):
- self.ensure_one()
- mail_message = self.env['mail.message'].create({
- 'model': self._name,
- 'res_id': self.id,
- 'subject': self.name,
- 'body': 'XML file for FatturaPA {} sent to Exchange System to the'
- ' email address {}.'
- .format(
- self.name,
- self.env.user.company_id.email_exchange_system),
- 'attachment_ids': [(6, 0, self.ir_attachment_id.ids)],
- 'email_from': self.env.user.company_id.email_from_for_fatturaPA,
- 'mail_server_id': self.env.user.company_id.sdi_channel_id.
- pec_server_id.id,
- })
-
- mail = self.env['mail.mail'].create({
- 'mail_message_id': mail_message.id,
- 'body_html': mail_message.body,
- 'email_to': self.env.user.company_id.email_exchange_system,
- })
-
- if mail:
- config_parameter = self.env['ir.config_parameter'].sudo()
- bounce_alias = config_parameter.get_param("mail.bounce.alias")
- catchall_domain = config_parameter.get_param("mail.catchall.domain")
- catchall_alias = config_parameter.get_param("mail.catchall.alias")
- # temporary disable email parameters incompatible with PEC
- if bounce_alias:
- config_parameter.set_param('mail.bounce.alias', False)
- if catchall_domain:
- config_parameter.set_param('mail.catchall.domain', False)
- if catchall_alias:
- config_parameter.set_param('mail.catchall.alias', False)
-
- res = mail.send(raise_exception=True)
-
- if bounce_alias:
- config_parameter.set_param(
- 'mail.bounce.alias', bounce_alias)
- if catchall_domain:
- config_parameter.set_param(
- 'mail.catchall.domain', catchall_domain)
- if catchall_alias:
- config_parameter.set_param(
- 'mail.catchall.alias', catchall_alias)
-
- if res:
- self.state = 'sent'
+ states = self.mapped('state')
+ if set(states) != set(['ready']):
+ raise UserError(_("You can only send 'ready to send' files"))
+ for att in self:
+ mail_message = self.env['mail.message'].create({
+ 'model': self._name,
+ 'res_id': att.id,
+ 'subject': att.name,
+ 'body': 'XML file for FatturaPA {} sent to Exchange System to '
+ 'the email address {}.'
+ .format(
+ att.name,
+ self.env.user.company_id.email_exchange_system),
+ 'attachment_ids': [(6, 0, att.ir_attachment_id.ids)],
+ 'email_from': (
+ self.env.user.company_id.email_from_for_fatturaPA),
+ 'mail_server_id': self.env.user.company_id.sdi_channel_id.
+ pec_server_id.id,
+ })
+
+ mail = self.env['mail.mail'].create({
+ 'mail_message_id': mail_message.id,
+ 'email_to': self.env.user.company_id.email_exchange_system,
+ })
+
+ if mail:
+ config_parameter = self.env['ir.config_parameter'].sudo()
+ bounce_alias = config_parameter.get_param(
+ "mail.bounce.alias")
+ catchall_domain = config_parameter.get_param(
+ "mail.catchall.domain")
+ catchall_alias = config_parameter.get_param(
+ "mail.catchall.alias")
+ # temporary disable email parameters incompatible with PEC
+ if bounce_alias:
+ config_parameter.set_param('mail.bounce.alias', False)
+ if catchall_domain:
+ config_parameter.set_param('mail.catchall.domain', False)
+ if catchall_alias:
+ config_parameter.set_param('mail.catchall.alias', False)
+
+ try:
+ mail.send(raise_exception=True)
+ att.state = 'sent'
+ att.sending_date = fields.Datetime.now()
+ att.sending_user = self.env.user.id
+ except MailDeliveryException as e:
+ att.state = 'sender_error'
+ mail.body = e[1]
+
+ if bounce_alias:
+ config_parameter.set_param(
+ 'mail.bounce.alias', bounce_alias)
+ if catchall_domain:
+ config_parameter.set_param(
+ 'mail.catchall.domain', catchall_domain)
+ if catchall_alias:
+ config_parameter.set_param(
+ 'mail.catchall.alias', catchall_alias)
@api.multi
def parse_pec_response(self, message_dict):
@@ -132,13 +158,23 @@ def parse_pec_response(self, message_dict):
message_id = message_id.text if message_id is not None \
else False
if message_type == 'NS': # 2A. Notifica di Scarto
- error_list = root.find('ListaErrori').text
+ error_list = root.find('ListaErrori')
+ error_str = ''
+ for error in error_list:
+ error_str += "\n[%s] %s %s" % (
+ error.find('Codice').text if error.find(
+ 'Codice') is not None else '',
+ error.find('Descrizione').text if error.find(
+ 'Descrizione') is not None else '',
+ error.find('Suggerimento').text if error.find(
+ 'Suggerimento') is not None else ''
+ )
fatturapa_attachment_out.write({
'state': 'sender_error',
'last_sdi_response': 'SdI ID: {}; '
'Message ID: {}; Receipt date: {}; '
'Error: {}'.format(
- id_sdi, message_id, receipt_dt, error_list)
+ id_sdi, message_id, receipt_dt, error_str)
})
elif message_type == 'MC': # 3A. Mancata consegna
missed_delivery_note = root.find('Descrizione').text
@@ -154,6 +190,7 @@ def parse_pec_response(self, message_dict):
delivery_dt = root.find('DataOraConsegna').text
fatturapa_attachment_out.write({
'state': 'validated',
+ 'delivered_date': fields.Datetime.now(),
'last_sdi_response': 'SdI ID: {}; '
'Message ID: {}; Receipt date: {}; '
'Delivery date: {}'.format(
@@ -195,12 +232,22 @@ def parse_pec_response(self, message_dict):
if description is not None:
fatturapa_attachment_out.write({
'state': 'validated',
- 'last_sdi_response': 'SdI ID: {}; '
- 'Message ID: {}; Receipt date: {}; '
- 'Description: {}'.format(
+ 'last_sdi_response': (
+ 'SdI ID: {}; Message ID: {}; Receipt date: {};'
+ ' Description: {}'
+ ).format(
id_sdi, message_id, receipt_dt,
description.text)
})
message_dict['res_id'] = fatturapa_attachment_out.id
return message_dict
+
+ @api.multi
+ def unlink(self):
+ for att in self:
+ if att.state != 'ready':
+ raise UserError(_(
+ "You can only delete 'ready to send' files"
+ ))
+ return super(FatturaPAAttachmentOut, self).unlink()
diff --git a/l10n_it_fatturapa_pec/models/mail_thread.py b/l10n_it_fatturapa_pec/models/mail_thread.py
index 7b4152490df5..4e0d4e33e624 100644
--- a/l10n_it_fatturapa_pec/models/mail_thread.py
+++ b/l10n_it_fatturapa_pec/models/mail_thread.py
@@ -3,7 +3,7 @@
# Copyright 2018 Openforce Srls Unipersonale (www.openforce.it)
# Copyright 2018 Sergio Corato (https://efatto.it)
# Copyright 2018 Lorenzo Battistini
-# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
+# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
import logging
import re
@@ -23,6 +23,12 @@
class MailThread(models.AbstractModel):
_inherit = 'mail.thread'
+ def clean_message_dict(self, message_dict):
+ del message_dict['attachments']
+ del message_dict['cc']
+ del message_dict['from']
+ del message_dict['to']
+
@api.model
def message_route(self, message, message_dict, model=None, thread_id=None,
custom_values=None):
@@ -57,10 +63,7 @@ def message_route(self, message, message_dict, model=None, thread_id=None,
self.create_fatturapa_attachment_in(attachment)
message_dict['attachment_ids'] = attachment_ids
- del message_dict['attachments']
- del message_dict['cc']
- del message_dict['from']
- del message_dict['to']
+ self.clean_message_dict(message_dict)
# model and res_id are only needed by
# _message_post_process_attachments: we don't attach to
@@ -84,10 +87,7 @@ def message_route(self, message, message_dict, model=None, thread_id=None,
attachment_ids = self._message_post_process_attachments(
message_dict['attachments'], [], message_dict)
message_dict['attachment_ids'] = attachment_ids
- del message_dict['attachments']
- del message_dict['cc']
- del message_dict['from']
- del message_dict['to']
+ self.clean_message_dict(message_dict)
# message_create_from_mail_mail to avoid to notify message
# (see mail.message.create)
@@ -101,13 +101,40 @@ def message_route(self, message, message_dict, model=None, thread_id=None,
fetchmail_server_id = self.env['fetchmail.server'].browse(
self._context['fetchmail_server_id'])
if fetchmail_server_id.is_fatturapa_pec:
- # todo send email for non-routable pec mail
+ att = self.find_attachment_by_subject(message_dict['subject'])
+ if att:
+ message_dict['model'] = 'fatturapa.attachment.out'
+ message_dict['res_id'] = att.id
+ self.clean_message_dict(message_dict)
+ self.env['mail.message'].with_context(
+ message_create_from_mail_mail=True).create(message_dict)
+ else:
+ # todo send email for non-routable pec mail
+ _logger.error('Can\'t route PEC E-Mail with Message-Id: {}'
+ .format(message.get('Message-Id')))
return []
return super(MailThread, self).message_route(
message, message_dict, model=model, thread_id=thread_id,
custom_values=custom_values)
+ def find_attachment_by_subject(self, subject):
+ if 'CONSEGNA: ' in subject:
+ att_name = subject.replace('CONSEGNA: ', '')
+ fatturapa_attachment_out = self.env[
+ 'fatturapa.attachment.out'
+ ].search([('datas_fname', '=', att_name)])
+ if len(fatturapa_attachment_out) == 1:
+ return fatturapa_attachment_out
+ if 'ACCETTAZIONE: ' in subject:
+ att_name = subject.replace('ACCETTAZIONE: ', '')
+ fatturapa_attachment_out = self.env[
+ 'fatturapa.attachment.out'
+ ].search([('datas_fname', '=', att_name)])
+ if len(fatturapa_attachment_out) == 1:
+ return fatturapa_attachment_out
+ return False
+
def create_fatturapa_attachment_in(self, attachment):
decoded = base64.b64decode(attachment.datas)
fatturapa_regex = re.compile(FATTURAPA_IN_REGEX)
diff --git a/l10n_it_fatturapa_pec/views/fatturapa_attachment_out.xml b/l10n_it_fatturapa_pec/views/fatturapa_attachment_out.xml
index afd840d8825d..6dd170e95af1 100644
--- a/l10n_it_fatturapa_pec/views/fatturapa_attachment_out.xml
+++ b/l10n_it_fatturapa_pec/views/fatturapa_attachment_out.xml
@@ -9,6 +9,7 @@
@@ -17,6 +18,20 @@
+
+ {'readonly': [('state', 'not in', ['ready', 'sender_error'])]}
+
+
@@ -27,6 +42,8 @@
+
+
@@ -37,8 +54,13 @@
+
+
+ {'search_default_ready': True}
+
+
diff --git a/l10n_it_fatturapa_pec/wizard/__init__.py b/l10n_it_fatturapa_pec/wizard/__init__.py
new file mode 100644
index 000000000000..f9c2d64483a9
--- /dev/null
+++ b/l10n_it_fatturapa_pec/wizard/__init__.py
@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
+
+from . import send_pec
diff --git a/l10n_it_fatturapa_pec/wizard/send_pec.py b/l10n_it_fatturapa_pec/wizard/send_pec.py
new file mode 100644
index 000000000000..3f4bb9b194e8
--- /dev/null
+++ b/l10n_it_fatturapa_pec/wizard/send_pec.py
@@ -0,0 +1,16 @@
+# -*- coding: utf-8 -*-
+# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
+
+from odoo import models, api
+
+
+class SendPEC(models.TransientModel):
+ _name = 'wizard.fatturapa.send.pec'
+ _description = "Wizard to send multiple e-invoice PEC"
+
+ @api.multi
+ def send_pec(self):
+ if self.env.context.get('active_ids'):
+ attachments = self.env['fatturapa.attachment.out'].browse(
+ self.env.context['active_ids'])
+ attachments.send_via_pec()
diff --git a/l10n_it_fatturapa_pec/wizard/send_pec_view.xml b/l10n_it_fatturapa_pec/wizard/send_pec_view.xml
new file mode 100644
index 000000000000..4c79172baded
--- /dev/null
+++ b/l10n_it_fatturapa_pec/wizard/send_pec_view.xml
@@ -0,0 +1,30 @@
+
+
+
+ wizard_fatturapa_send_pec_view
+ wizard.fatturapa.send.pec
+
+
+
+
+
+
+
From bae907cbd34ac24e0ce94bad72623e663d6263c7 Mon Sep 17 00:00:00 2001
From: sergio
Date: Thu, 15 Nov 2018 11:34:57 +0100
Subject: [PATCH 04/65] [FIX] compute method start with _
[FIX] flake
---
.../i18n/l10n_it_fatturapa_pec.pot | 219 ++++++++++++++++++
l10n_it_fatturapa_pec/models/account.py | 4 +-
.../models/fatturapa_attachment_out.py | 5 +-
l10n_it_fatturapa_pec/models/mail_thread.py | 7 +-
4 files changed, 226 insertions(+), 9 deletions(-)
create mode 100644 l10n_it_fatturapa_pec/i18n/l10n_it_fatturapa_pec.pot
diff --git a/l10n_it_fatturapa_pec/i18n/l10n_it_fatturapa_pec.pot b/l10n_it_fatturapa_pec/i18n/l10n_it_fatturapa_pec.pot
new file mode 100644
index 000000000000..93c9aa3eb0f6
--- /dev/null
+++ b/l10n_it_fatturapa_pec/i18n/l10n_it_fatturapa_pec.pot
@@ -0,0 +1,219 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * l10n_it_fatturapa_pec
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 10.0\n"
+"Report-Msgid-Bugs-To: \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_fatturapa_pec
+#: model:ir.ui.view,arch_db:l10n_it_fatturapa_pec.wizard_fatturapa_send_pec_view
+msgid "Cancel"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_wizard_fatturapa_send_pec_create_uid
+msgid "Created by"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_wizard_fatturapa_send_pec_create_date
+msgid "Created on"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: selection:account.invoice,fatturapa_state:0
+#: selection:fatturapa.attachment.out,state:0
+#: model:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_pec_attachment_form
+msgid "Delivered"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_fatturapa_attachment_out_delivered_date
+msgid "Delivered date"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_wizard_fatturapa_send_pec_display_name
+msgid "Display Name"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_account_invoice_fatturapa_state
+msgid "E-invoice State"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: model:ir.model,name:l10n_it_fatturapa_pec.model_mail_thread
+msgid "Email Thread"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: selection:account.invoice,fatturapa_state:0
+msgid "Error"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: model:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_account_invoice_fatturapa_out_pec_filter
+msgid "Fattura Elettronica Error"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: model:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_account_invoice_fatturapa_out_pec_filter
+msgid "Fattura Elettronica Ready to Send"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: model:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_account_invoice_fatturapa_out_pec_filter
+msgid "Fattura Elettronica State"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: model:ir.model,name:l10n_it_fatturapa_pec.model_fatturapa_attachment_out
+msgid "FatturaPA Export File"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_wizard_fatturapa_send_pec_id
+msgid "ID"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: model:ir.model,name:l10n_it_fatturapa_pec.model_account_invoice
+msgid "Invoice"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_wizard_fatturapa_send_pec___last_update
+msgid "Last Modified on"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_fatturapa_attachment_out_last_sdi_response
+#: model:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_pec_attachment_form
+msgid "Last Response from Exchange System"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_wizard_fatturapa_send_pec_write_uid
+msgid "Last Updated by"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_wizard_fatturapa_send_pec_write_date
+msgid "Last Updated on"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: model:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_attachment_search_state
+msgid "Ready"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: selection:account.invoice,fatturapa_state:0
+#: selection:fatturapa.attachment.out,state:0
+msgid "Ready to Send"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: selection:fatturapa.attachment.out,state:0
+msgid "Recipient Error"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: selection:fatturapa.attachment.out,state:0
+msgid "Rejected (PA)"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: model:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_pec_attachment_form
+msgid "Reset to ready"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: model:ir.ui.view,arch_db:l10n_it_fatturapa_pec.wizard_fatturapa_send_pec_view
+msgid "Selected files will be sent to the Exchange System"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: model:ir.ui.view,arch_db:l10n_it_fatturapa_pec.wizard_fatturapa_send_pec_view
+msgid "Send"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: model:ir.actions.act_window,name:l10n_it_fatturapa_pec.action_wizard_fatturapa_send_pec
+#: model:ir.ui.view,arch_db:l10n_it_fatturapa_pec.wizard_fatturapa_send_pec_view
+msgid "Send Electronic Invoice"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: model:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_pec_attachment_form
+msgid "Send Via PEC"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: selection:fatturapa.attachment.out,state:0
+msgid "Sender Error"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_fatturapa_attachment_out_sending_user
+msgid "Sending user"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: selection:account.invoice,fatturapa_state:0
+#: selection:fatturapa.attachment.out,state:0
+msgid "Sent"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: model:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_pec_attachment_form
+msgid "Sent by"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_fatturapa_attachment_out_sending_date
+msgid "Sent date"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_fatturapa_attachment_out_state
+msgid "State"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: model:ir.model,name:l10n_it_fatturapa_pec.model_wizard_fatturapa_send_pec
+msgid "Wizard to send multiple e-invoice PEC"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:47
+#, python-format
+msgid "Yo can only reset 'sender error' files"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:247
+#, python-format
+msgid "You can only delete 'ready to send' files"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:54
+#, python-format
+msgid "You can only send 'ready to send' files"
+msgstr ""
+
+#. module: l10n_it_fatturapa_pec
+#: model:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_pec_attachment_form
+msgid "on"
+msgstr ""
+
diff --git a/l10n_it_fatturapa_pec/models/account.py b/l10n_it_fatturapa_pec/models/account.py
index a378021c5848..05a4a5bc6a42 100644
--- a/l10n_it_fatturapa_pec/models/account.py
+++ b/l10n_it_fatturapa_pec/models/account.py
@@ -16,13 +16,13 @@ class AccountInvoice(models.Model):
('delivered', 'Delivered'),
('error', 'Error')],
string='E-invoice State',
- compute='compute_fatturapa_state',
+ compute='_compute_fatturapa_state',
store='true',
)
@api.multi
@api.depends('fatturapa_attachment_out_id.state')
- def compute_fatturapa_state(self):
+ def _compute_fatturapa_state(self):
mapping = {
'ready': 'ready',
'sent': 'sent',
diff --git a/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py b/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py
index 5b270e57f90f..f63d4c5f2bb7 100644
--- a/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py
+++ b/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py
@@ -200,10 +200,7 @@ def parse_pec_response(self, message_dict):
esito_committente = root.find('EsitoCommittente')
if esito_committente is not None:
# more than one esito?
- id_sdi_esito = esito_committente.find(
- 'IdentificativoSdI')
- esito = esito_committente.find(
- 'Esito')
+ esito = esito_committente.find('Esito')
if esito is not None:
if esito.text == 'EC01':
state = 'validated'
diff --git a/l10n_it_fatturapa_pec/models/mail_thread.py b/l10n_it_fatturapa_pec/models/mail_thread.py
index 4e0d4e33e624..3d001211e48a 100644
--- a/l10n_it_fatturapa_pec/models/mail_thread.py
+++ b/l10n_it_fatturapa_pec/models/mail_thread.py
@@ -58,7 +58,7 @@ def message_route(self, message, message_dict, model=None, thread_id=None,
attachment_ids = self._message_post_process_attachments(
message_dict['attachments'], [], message_dict)
for attachment in self.env['ir.attachment'].browse(
- [att_id for model, att_id in attachment_ids]):
+ [att_id for m, att_id in attachment_ids]):
if fatturapa_regex.match(attachment.name):
self.create_fatturapa_attachment_in(attachment)
@@ -107,11 +107,12 @@ def message_route(self, message, message_dict, model=None, thread_id=None,
message_dict['res_id'] = att.id
self.clean_message_dict(message_dict)
self.env['mail.message'].with_context(
- message_create_from_mail_mail=True).create(message_dict)
+ message_create_from_mail_mail=True).create(
+ message_dict)
else:
# todo send email for non-routable pec mail
_logger.error('Can\'t route PEC E-Mail with Message-Id: {}'
- .format(message.get('Message-Id')))
+ .format(message.get('Message-Id')))
return []
return super(MailThread, self).message_route(
From a3b6c13b238d34abb63e2067f0680d03fb892fc1 Mon Sep 17 00:00:00 2001
From: eLBati
Date: Sat, 17 Nov 2018 15:22:47 +0100
Subject: [PATCH 05/65] porting l10n_it_fatturapa_pec to 12
---
l10n_it_fatturapa_pec/README.rst | 10 +++++-----
l10n_it_fatturapa_pec/__init__.py | 1 -
l10n_it_fatturapa_pec/__manifest__.py | 4 ++--
l10n_it_fatturapa_pec/models/__init__.py | 1 -
l10n_it_fatturapa_pec/models/account.py | 1 -
.../models/fatturapa_attachment_out.py | 5 ++---
l10n_it_fatturapa_pec/models/mail_thread.py | 1 -
l10n_it_fatturapa_pec/static/description/index.html | 6 +++---
l10n_it_fatturapa_pec/views/account.xml | 2 +-
l10n_it_fatturapa_pec/wizard/__init__.py | 1 -
l10n_it_fatturapa_pec/wizard/send_pec.py | 1 -
l10n_it_fatturapa_pec/wizard/send_pec_view.xml | 2 +-
12 files changed, 14 insertions(+), 21 deletions(-)
diff --git a/l10n_it_fatturapa_pec/README.rst b/l10n_it_fatturapa_pec/README.rst
index a222cf0abfe5..f95aa47d06e5 100644
--- a/l10n_it_fatturapa_pec/README.rst
+++ b/l10n_it_fatturapa_pec/README.rst
@@ -14,13 +14,13 @@ Italian Localization - FatturaPA - Emission - PEC Support
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github
- :target: https://github.com/OCA/l10n-italy/tree/10.0/l10n_it_fatturapa_pec
+ :target: https://github.com/OCA/l10n-italy/tree/12.0/l10n_it_fatturapa_pec
:alt: OCA/l10n-italy
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/l10n-italy-10-0/l10n-italy-10-0-l10n_it_fatturapa_pec
+ :target: https://translation.odoo-community.org/projects/l10n-italy-12-0/l10n-italy-12-0-l10n_it_fatturapa_pec
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
- :target: https://runbot.odoo-community.org/runbot/122/10.0
+ :target: https://runbot.odoo-community.org/runbot/122/12.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -54,7 +54,7 @@ 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 smashing it by providing a detailed and welcomed
-`feedback `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -86,6 +86,6 @@ 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.
+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.
diff --git a/l10n_it_fatturapa_pec/__init__.py b/l10n_it_fatturapa_pec/__init__.py
index 76ad875773a0..12ce5d69dcd8 100644
--- a/l10n_it_fatturapa_pec/__init__.py
+++ b/l10n_it_fatturapa_pec/__init__.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
from . import models
diff --git a/l10n_it_fatturapa_pec/__manifest__.py b/l10n_it_fatturapa_pec/__manifest__.py
index b8c56b377c8a..3a3656afd990 100644
--- a/l10n_it_fatturapa_pec/__manifest__.py
+++ b/l10n_it_fatturapa_pec/__manifest__.py
@@ -1,12 +1,12 @@
-# -*- coding: utf-8 -*-
# Author(s): Andrea Colangelo (andreacolangelo@openforce.it)
# Copyright 2018 Openforce Srls Unipersonale (www.openforce.it)
# Copyright 2018 Sergio Corato (https://efatto.it)
# Copyright 2018 Lorenzo Battistini
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
+
{
'name': 'Italian Localization - FatturaPA - Emission - PEC Support',
- 'version': '10.0.1.1.0',
+ 'version': '12.0.1.1.0',
'category': 'Localization/Italy',
'summary': 'Send electronic invoices via PEC',
'author': 'Openforce Srls Unipersonale, Odoo Community Association (OCA)',
diff --git a/l10n_it_fatturapa_pec/models/__init__.py b/l10n_it_fatturapa_pec/models/__init__.py
index 2299b9b3bda3..c18e6f441c6e 100644
--- a/l10n_it_fatturapa_pec/models/__init__.py
+++ b/l10n_it_fatturapa_pec/models/__init__.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
from . import account
diff --git a/l10n_it_fatturapa_pec/models/account.py b/l10n_it_fatturapa_pec/models/account.py
index 05a4a5bc6a42..01c10b1727b5 100644
--- a/l10n_it_fatturapa_pec/models/account.py
+++ b/l10n_it_fatturapa_pec/models/account.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# Author(s): Andrea Colangelo (andreacolangelo@openforce.it)
# Copyright © 2018 Openforce Srls Unipersonale (www.openforce.it)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
diff --git a/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py b/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py
index f63d4c5f2bb7..e1aae5935813 100644
--- a/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py
+++ b/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# Author(s): Andrea Colangelo (andreacolangelo@openforce.it)
# Copyright 2018 Openforce Srls Unipersonale (www.openforce.it)
# Copyright 2018 Sergio Corato (https://efatto.it)
@@ -12,7 +11,7 @@
from odoo import api, fields, models, _
from odoo.exceptions import UserError
-from odoo.addons.base.ir.ir_mail_server import MailDeliveryException
+from odoo.addons.base.models.ir_mail_server import MailDeliveryException
_logger = logging.getLogger(__name__)
@@ -97,7 +96,7 @@ def send_via_pec(self):
att.sending_user = self.env.user.id
except MailDeliveryException as e:
att.state = 'sender_error'
- mail.body = e[1]
+ mail.body = str(e)
if bounce_alias:
config_parameter.set_param(
diff --git a/l10n_it_fatturapa_pec/models/mail_thread.py b/l10n_it_fatturapa_pec/models/mail_thread.py
index 3d001211e48a..78fe7201e3c9 100644
--- a/l10n_it_fatturapa_pec/models/mail_thread.py
+++ b/l10n_it_fatturapa_pec/models/mail_thread.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# Author(s): Andrea Colangelo (andreacolangelo@openforce.it)
# Copyright 2018 Openforce Srls Unipersonale (www.openforce.it)
# Copyright 2018 Sergio Corato (https://efatto.it)
diff --git a/l10n_it_fatturapa_pec/static/description/index.html b/l10n_it_fatturapa_pec/static/description/index.html
index 7d342f770e85..a33bd896983f 100644
--- a/l10n_it_fatturapa_pec/static/description/index.html
+++ b/l10n_it_fatturapa_pec/static/description/index.html
@@ -367,7 +367,7 @@ Italian Localization - FatturaPA - Emission - PEC Support
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-
+
This module allows you to send and receive electronic invoice XML file version 1.2
http://www.fatturapa.gov.it/export/fatturazione/en/sdi.htm
via PEC
@@ -400,7 +400,7 @@
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 smashing it by providing a detailed and welcomed
-feedback.
+feedback.
Do not contact contributors directly about support or help with technical issues.
@@ -426,7 +426,7 @@
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.
+
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.
diff --git a/l10n_it_fatturapa_pec/views/account.xml b/l10n_it_fatturapa_pec/views/account.xml
index 7a377a1b2ec0..27ae2a42513a 100644
--- a/l10n_it_fatturapa_pec/views/account.xml
+++ b/l10n_it_fatturapa_pec/views/account.xml
@@ -34,7 +34,7 @@
-
+
diff --git a/l10n_it_fatturapa_pec/wizard/__init__.py b/l10n_it_fatturapa_pec/wizard/__init__.py
index f9c2d64483a9..63d026cbdf55 100644
--- a/l10n_it_fatturapa_pec/wizard/__init__.py
+++ b/l10n_it_fatturapa_pec/wizard/__init__.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
from . import send_pec
diff --git a/l10n_it_fatturapa_pec/wizard/send_pec.py b/l10n_it_fatturapa_pec/wizard/send_pec.py
index 3f4bb9b194e8..f196c39aebd6 100644
--- a/l10n_it_fatturapa_pec/wizard/send_pec.py
+++ b/l10n_it_fatturapa_pec/wizard/send_pec.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
from odoo import models, api
diff --git a/l10n_it_fatturapa_pec/wizard/send_pec_view.xml b/l10n_it_fatturapa_pec/wizard/send_pec_view.xml
index 4c79172baded..9bb25c32aed3 100644
--- a/l10n_it_fatturapa_pec/wizard/send_pec_view.xml
+++ b/l10n_it_fatturapa_pec/wizard/send_pec_view.xml
@@ -7,7 +7,7 @@