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 zcmZ`-cQ_l|7mlK0r}iEdvy_@qdlNf+Myg7cR<(%LsJ*GyUbQJj&1j93*rTe%s8D;S zipJjKm+$%h{@wSv_uS|Fb?-UveeQWroSBIpEfoh9005vh(AS0$t=Yd5c$2s$+}f)q znwyUe^|S%k|Dq66mP+(cdg|MH0|3;F|4tG>b}k#yN#SE)tV1zR!OqCaO)9&d3ji=Y zH_+CwL{4vK`zNjaQsVo-1v8L@W2O4^Z5p;2&DX5Gyfaix6NT1fn_xs1vmKA4Z}9G5*bP>lYs0l_86{-EfemL$wYtEX~XFx(6Qx0z}MQ_X8yQ)<{$_5%>mlWCZ#N>H?O@k12f83Q?X?mNv z#HYs~2E5I{ERY+ui$c)xsv0rr5R?CXO&ad@8pDIJPlO~Gq(q|8in-qU6)4=&IX}i; zt#|h_RI^AQMCQ{ncU4;^2dx;VDD1vPrkZDxBk~4#gBK*5V_Ym!YFkQ&4f6&31~h(;ym$rC=OmP`=DBt?8Ao-ms#nh zMy95W(fr=t-aoKd`jj>MTD^R{w)w(mToO`BIf5PatA7%Iz&VG>AR9T&8 z2yhq&;LfnBY{-Tvm_zT$V3L)wuCg5ZqOJ{aHYXcf+afa&DHRo3^-`G5rqgTy0RzDk zk7HzPO#3O74=9oj1siClfJx~Ol|9T*${Z_2!47+~lGtUo5=+a<4@4@A$&&LKFv!1{ zQU{Set419mRq_6+O0V)Gyc3kM#J9P&=3J6SWOxG$c7I2i7(xof!KghaePbPr%G8a8 zWgUepN_!j_n0p%KPsgqJ<75?_o-B5}z0eOWGbToYsv90}%gl>we2SSboO53xCz;-# zY6?+9%K=4q19=rj{JAc|m(bU=^lw+#)PN&Urz&R`7t$^RJ0-^;RQOX3h=#wH%4dqi zq{Mg94F~~X7*nNiMYt}eb3W)i>wWfK8YgyxtPvz|- z8-c*R@bSDGtq;x3eNveOGvbVW*EB|_+^Q^`P9-c`n&RTK0!(cAE&c@1XAtR2s;Wu# zx7i~jqG@*MS8wRcOto7N4?x4AsX)}EZX}0N3MTDW5m_|wG>PV~x zc#Eyt%|hc;IBns*wB4SGq^%fkzoFkj*W2`|Gj(kq34~2Pt!{ zj`iP0RbtSHUC_9B@|^;I5_5+s!Js2Q3Dy{L_v>};S-3~Nd;K@Vf(y10p4ytkLb$CI_D>NAOk$>2geHq)mdvkW8y1vrE^rg9^Q5O@Fgk=GR*&op| zF34^}-uNHlW0|tcZ`CeOth26g^!^NtKBR-ks(u2SlFFIelI_3^o<5elk>vODdLAs#JHfja?ri2qG96>epj}QA7bzq#5ju96?JoApY zWRplVd3YfJm&{3;yiPdAcG1&^mGPS(htpXRzb%^f@&k^wd{d~03szG-f+#)CcC1fY zLQd#wuD6bCW&JWimPI> z5!v-sgh1foS4mHQ72$m<<>T&2&+d6!E7b$zVu8<0FS;Je6^$J;m?xKdb|+tzFRmZv7(@(O$0Bwq zV`+KY|1w{!OXkINqkhV_o@*(1{i4qRefhQbXYiNrp#}RO!~E%XOY;tk);?#`K9=`_ zA+z<|`C#m=zH1c|y#cX8jRFNpzL4ASQF`JE9W(CG$LXlzUvhMw@+@a99o7c1UQ0J7 zBv%cU>h3>ybS30n%3+>smdVn7f1s@W=wZI!m9G7jVIu!V--w=eE=LLR1O9|;qgQ8n zY6E_MPZ$hJs7_oMZkZ1x_qdLz^`3hiVft4wl!Ypp;}1$8fqwt2vS8qgWO83!aPhap z+P1g&t!dqLu)+eWKp|vHD500T?PRiPZ}wph#OZZ-;^parj9>RFQFK<<=?t=K#$Nx; z63x=?8~R7xnKdUOruX4Xe>dCuewohou8zNQ*k>}_0fqjVcB{qsRi{}%Z|RUHaOL%~ zB{Ek+au1PL7VkHIY0CQq@YHw`xs-}6u@eXS6#lqA^89!~&q?s(efhY7=@U4AWZ#pFa(T^ac&Fot zW^#|>bgF(Sg3c%-rH3-ly=yAg)CDXS>j?uH#BqOtNDNcL$Zp1b20e=tR&VBt;n+%$ z#hy(hfcQGJ_)VYvdF2&f3+AAvd&~3;|LhB`$LS@Ok>Ft_o$%A!2Sb-?A7+?;tbI42 z)4dN$-qwugxmv{(xNKrRgL@H;KU|D_GtBQgZPq^OSu1#bN66T`vSq#Gp`x3_Fo$&N zy>^J<=Qe%Z1Ag%YDS5?r1oF3*dT4?$#Z>(ojSD?@4|U-8R7MAJZ)$3$uB39dQTHZx zUS467fM@)5u22-4W0Wpc7-(c$P@i9fjN_@yTdH$29!pvX*Knv!!1u6JcQg5;f^P_u z<&rLbGk<6?vt+$yLfWOZN3Rd%rr zc($V7pz(yiKE-=O_)$MvGT{ESjoIE4p5OW@S-jULdX{>hZ1`iT_#t|g6I%+Y(0@|E z&NYgLXq%6)8Z$8_TX?PjjaGP_decnl%!ZV-w5Fv<9pU$li9aH1u=kHG)u$TPQ-u-& zAoy6Ss9@K%v*Kvq%M}w(yCMWc{8IG|0Q|a83GRl{4F8?!_MOVo9irQp|0;;mx1ZmO zH?j<68%{^#LXr@8txAQF@8rynp$Xhln|~wn(@Z~*OPcYCz3vMyAwQ$N!2*AZyMYc% zuQW|d)M`dId_Xq!&GAP!J}S6>{8c5Rrk0rYM%Rh*sl-gwP!-qYv{F_dmnuTUeV?3M#yMrV$nOoWdsNmSw zS(8PkmN7!YlSOI8;~O;5VK|O8H){LM4sKRXb4hSrkNiDUf|MP9LI9hS`6o$?LXIJu6S49q>KkY&15rhx(N09=nv|2~SEf@m z;^Ey-nS%$fF&cLkwH2@NFWs)T$jGE`7j~RUa8A{q|DcfaQg;`J z59pB*N>*Otvcs&2I&c{xGzbgtc#1$IYsJtJX>;e!ovm4P>cBu;ThHpT1#p2n3AS{8 z^*sAFh11JRMDvP8RXdPC3aS+IGeFAT-!I`Rv46xTBPvEHlX3gh1iSw1hWv({na080 zuZOmYmR*K-qKQ0#QZZHb1wzouY3qn{y-IkJd}kN!U` r8aiT|hVCWM^FKV(3jG&l)t9W+$TKay + + + + + +Italian Localization - FatturaPA - Emission - PEC Support + + + +
+

Italian Localization - FatturaPA - Emission - PEC Support

+ + +

Beta License: LGPL-3 OCA/l10n-italy Translate me on Weblate Try me on Runbot

+

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

+ +
+

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

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: LGPL-3 OCA/l10n-italy Translate me on Weblate Try me on Runbot

+

Beta License: LGPL-3 OCA/l10n-italy Translate me on Weblate Try me on Runbot

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 @@

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.

@@ -426,7 +426,7 @@

Maintainers

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 @@
-
From a0754efb1e1abb9a36fe1b873a39859b6543171c Mon Sep 17 00:00:00 2001 From: eLBati Date: Tue, 20 Nov 2018 18:27:03 +0100 Subject: [PATCH 06/65] IMP l10n_it_sdi_channel interface ADD mechanism to check SDI PEC address after first sending ADD check valid PEC incoming server IMP attachment out filter --- .../models/fatturapa_attachment_out.py | 14 ++++++++++++++ .../views/fatturapa_attachment_out.xml | 7 +++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py b/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py index e1aae5935813..92fcab6e1ef3 100644 --- a/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py +++ b/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py @@ -46,8 +46,20 @@ def reset_to_ready(self): raise UserError(_("Yo can only reset 'sender error' files")) att.state = 'ready' + @api.model + def _check_fetchmail(self): + server = self.env['fetchmail.server'].search([ + ('is_fatturapa_pec', '=', True), + ('state', '=', 'done') + ]) + if not server: + raise UserError(_( + "No incoming PEC server found. Please configure it.")) + @api.multi def send_via_pec(self): + self._check_fetchmail() + self.env.user.company_id.sdi_channel_id.check_first_pec_sending() states = self.mapped('state') if set(states) != set(['ready']): raise UserError(_("You can only send 'ready to send' files")) @@ -94,6 +106,8 @@ def send_via_pec(self): att.state = 'sent' att.sending_date = fields.Datetime.now() att.sending_user = self.env.user.id + self.env.user.company_id.sdi_channel_id.\ + update_after_first_pec_sending() except MailDeliveryException as e: att.state = 'sender_error' mail.body = str(e) diff --git a/l10n_it_fatturapa_pec/views/fatturapa_attachment_out.xml b/l10n_it_fatturapa_pec/views/fatturapa_attachment_out.xml index 6dd170e95af1..3b0896b9ee63 100644 --- a/l10n_it_fatturapa_pec/views/fatturapa_attachment_out.xml +++ b/l10n_it_fatturapa_pec/views/fatturapa_attachment_out.xml @@ -54,13 +54,16 @@ - + + + + - {'search_default_ready': True} + {'search_default_ready': True, 'search_default_sender_error': True, 'search_default_recipient_error': True, 'search_default_rejected': True, } From 8a06b308c003b6415579a18f101c0304976daf4c Mon Sep 17 00:00:00 2001 From: Lorenzo Battistini Date: Thu, 29 Nov 2018 13:57:42 +0100 Subject: [PATCH 07/65] l10n_it_fatturapa_pec: check possible fetch errors and track them (#682) While sending, check for valid fetchmail server FIX typo 'yo' --- l10n_it_fatturapa_pec/__manifest__.py | 1 + l10n_it_fatturapa_pec/models/__init__.py | 1 + .../models/fatturapa_attachment_out.py | 2 +- l10n_it_fatturapa_pec/models/fetchmail.py | 134 ++++++++++++++++++ .../views/fetchmail_view.xml | 20 +++ 5 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 l10n_it_fatturapa_pec/models/fetchmail.py create mode 100644 l10n_it_fatturapa_pec/views/fetchmail_view.xml diff --git a/l10n_it_fatturapa_pec/__manifest__.py b/l10n_it_fatturapa_pec/__manifest__.py index 3a3656afd990..691265480969 100644 --- a/l10n_it_fatturapa_pec/__manifest__.py +++ b/l10n_it_fatturapa_pec/__manifest__.py @@ -22,6 +22,7 @@ 'views/account.xml', 'views/fatturapa_attachment_out.xml', 'wizard/send_pec_view.xml', + 'views/fetchmail_view.xml', ], 'installable': True } diff --git a/l10n_it_fatturapa_pec/models/__init__.py b/l10n_it_fatturapa_pec/models/__init__.py index c18e6f441c6e..0669881ef328 100644 --- a/l10n_it_fatturapa_pec/models/__init__.py +++ b/l10n_it_fatturapa_pec/models/__init__.py @@ -3,3 +3,4 @@ from . import account from . import fatturapa_attachment_out from . import mail_thread +from . import fetchmail diff --git a/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py b/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py index 92fcab6e1ef3..acc37ea90551 100644 --- a/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py +++ b/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py @@ -43,7 +43,7 @@ class FatturaPAAttachmentOut(models.Model): def reset_to_ready(self): for att in self: if att.state != 'sender_error': - raise UserError(_("Yo can only reset 'sender error' files")) + raise UserError(_("You can only reset 'sender error' files")) att.state = 'ready' @api.model diff --git a/l10n_it_fatturapa_pec/models/fetchmail.py b/l10n_it_fatturapa_pec/models/fetchmail.py new file mode 100644 index 000000000000..40c78d2f0ccb --- /dev/null +++ b/l10n_it_fatturapa_pec/models/fetchmail.py @@ -0,0 +1,134 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Lorenzo Battistini +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). + +import logging +from odoo import models, api, fields + +_logger = logging.getLogger(__name__) +MAX_POP_MESSAGES = 50 + + +class Fetchmail(models.Model): + _inherit = 'fetchmail.server' + last_pec_error_message = fields.Text( + "Last PEC error message", readonly=True) + + @api.multi + def fetch_mail(self): + for server in self: + if not server.is_fatturapa_pec: + super(Fetchmail, server).fetch_mail() + else: + additional_context = { + 'fetchmail_cron_running': True + } + # Setting fetchmail_cron_running to avoid to disable cron while + # cron is running (otherwise it would be done by setting + # server.state = 'draft', + # see _update_cron method) + server = server.with_context(**additional_context) + MailThread = self.env['mail.thread'] + _logger.info( + 'start checking for new e-invoices on %s server %s', + server.type, server.name) + additional_context['fetchmail_server_id'] = server.id + additional_context['server_type'] = server.type + imap_server = None + pop_server = None + if server.type == 'imap': + try: + imap_server = server.connect() + imap_server.select() + result, data = imap_server.search(None, '(UNSEEN)') + for num in data[0].split(): + result, data = imap_server.fetch(num, '(RFC822)') + imap_server.store(num, '-FLAGS', '\\Seen') + try: + MailThread.with_context( + **additional_context + ).message_process( + server.object_id.model, data[0][1], + save_original=server.original, + strip_attachments=(not server.attach) + ) + # if message is processed without exceptions + server.last_pec_error_message = '' + except Exception as e: + _logger.info( + 'Failed to process mail from %s server ' + '%s. Resetting server status', + server.type, server.name, exc_info=True + ) + # Here is where we need to intervene. + # Setting to draft prevents new e-invoices to + # be sent via PEC + server.state = 'draft' + server.last_pec_error_message = str(e) + break + imap_server.store(num, '+FLAGS', '\\Seen') + # We need to commit because message is processed: + # Possible next exceptions, out of try, should not + # rollback processed messages + self._cr.commit() + except Exception as e: + _logger.info( + "General failure when trying to fetch mail from " + "%s server %s.", + server.type, server.name, exc_info=True) + server.state = 'draft' + server.last_pec_error_message = str(e) + finally: + if imap_server: + imap_server.close() + imap_server.logout() + elif server.type == 'pop': + try: + while True: + pop_server = server.connect() + (num_messages, total_size) = pop_server.stat() + pop_server.list() + for num in range( + 1, min(MAX_POP_MESSAGES, num_messages) + 1 + ): + (header, messages, octets) = pop_server.retr( + num) + message = '\n'.join(messages) + try: + MailThread.with_context( + **additional_context + ).message_process( + server.object_id.model, message, + save_original=server.original, + strip_attachments=(not server.attach) + ) + pop_server.dele(num) + # See the comments in the IMAP part + server.last_pec_error_message = '' + except Exception as e: + _logger.info( + 'Failed to process mail from %s server' + '%s. Resetting server status', + server.type, server.name, exc_info=True + ) + # See the comments in the IMAP part + server.state = 'draft' + server.last_pec_error_message = str(e) + break + self._cr.commit() + if num_messages < MAX_POP_MESSAGES: + break + pop_server.quit() + except Exception as e: + _logger.info( + "General failure when trying to fetch mail from %s" + " server %s.", + server.type, server.name, exc_info=True) + # See the comments in the IMAP part + server.state = 'draft' + server.last_pec_error_message = str(e) + finally: + if pop_server: + pop_server.quit() + server.write({'date': fields.Datetime.now()}) + return True diff --git a/l10n_it_fatturapa_pec/views/fetchmail_view.xml b/l10n_it_fatturapa_pec/views/fetchmail_view.xml new file mode 100644 index 000000000000..9e03f1ba33f5 --- /dev/null +++ b/l10n_it_fatturapa_pec/views/fetchmail_view.xml @@ -0,0 +1,20 @@ + + + + + view_email_server_form_e_invoice + fetchmail.server + + + + + + + + + + {'invisible': [('is_fatturapa_pec', '=', True)]} + + + + From 084ad9c5876fcfc9fb5cbff341e40ac4b62c0f56 Mon Sep 17 00:00:00 2001 From: Sergio Zanchetta Date: Sat, 1 Dec 2018 17:50:00 +0100 Subject: [PATCH 08/65] [IMP] l10n_it_fatturapa_pec revamp manifest and README [FIX] l10n_it_fatturapa_pec translation source strings [IMP] l10n_it_sdi_channel revamp README and manifest (#692) [FIX] l10n_it_sdi_channel FatturaPA/translation source strings [IMP] l10n_it_sdi_channel set ITA name and summary [IMP] fatturapa modules, set ITA name and summary (#694) [FIX] l10n_it_fatturapa_in typos in source translation strings --- l10n_it_fatturapa_pec/README.rst | 41 ++++++++++++++++--- l10n_it_fatturapa_pec/__manifest__.py | 8 ++-- .../models/fatturapa_attachment_out.py | 12 +++--- l10n_it_fatturapa_pec/models/fetchmail.py | 2 +- l10n_it_fatturapa_pec/readme/CONFIGURE.rst | 8 +++- l10n_it_fatturapa_pec/readme/CONTRIBUTORS.rst | 1 + l10n_it_fatturapa_pec/readme/DESCRIPTION.rst | 20 +++++++-- l10n_it_fatturapa_pec/readme/USAGE.rst | 10 ++++- .../static/description/index.html | 32 +++++++++++---- l10n_it_fatturapa_pec/views/account.xml | 6 +-- 10 files changed, 107 insertions(+), 33 deletions(-) diff --git a/l10n_it_fatturapa_pec/README.rst b/l10n_it_fatturapa_pec/README.rst index f95aa47d06e5..93e2d69da28d 100644 --- a/l10n_it_fatturapa_pec/README.rst +++ b/l10n_it_fatturapa_pec/README.rst @@ -1,5 +1,5 @@ ========================================================= -Italian Localization - FatturaPA - Emission - PEC Support +Italian Localization - Fattura Elettronica - Supporto PEC ========================================================= .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -25,11 +25,25 @@ Italian Localization - FatturaPA - Emission - PEC Support |badge1| |badge2| |badge3| |badge4| |badge5| -This module allows you to send and receive electronic invoice XML file version 1.2 +**Italiano** + +Questo modulo consente di inviare e ricevere i file XML della fattura elettronica versione 1.2 + +http://www.fatturapa.gov.it/export/fatturazione/en/sdi.htm + +via PEC. + +Analizza le notifiche provenienti dallo SdI e monitora lo stato della trasmissione. + +**English** + +This module allows you to send and receive electronic invoice/bill XML files 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. +via PEC. + +Notifications from ES are parsed and transmission state is tracked. **Table of contents** @@ -39,14 +53,28 @@ Notifications from SDI are parsed and transmission state is tracked. Configuration ============= -See `l10n_it_sdi_channel` module +**Italiano** + +Consultare il modulo `l10n_it_sdi_channel`. + +**English** + +See `l10n_it_sdi_channel` module. Usage ===== +**Italiano** + +Nell'allegato fattura elettronica in uscita fare clic sul pulsante "Invia con PEC". + +Le fatture elettroniche fornitore vengono create in modo automatico, prelevate dalla casella PEC. + +**English** + In electronic invoice out attachment you can click "Send Via PEC" button. -Supplier electronic invoices are automatically created, fetched from PEC mailbox. +Supplier electronic bills are automatically created, fetched from PEC mailbox. Bug Tracker =========== @@ -72,6 +100,7 @@ Contributors * Andrea Colangelo * Sergio Corato * Lorenzo Battistini +* Sergio Zanchetta Maintainers ~~~~~~~~~~~ diff --git a/l10n_it_fatturapa_pec/__manifest__.py b/l10n_it_fatturapa_pec/__manifest__.py index 691265480969..09de7508c81b 100644 --- a/l10n_it_fatturapa_pec/__manifest__.py +++ b/l10n_it_fatturapa_pec/__manifest__.py @@ -2,15 +2,17 @@ # Copyright 2018 Openforce Srls Unipersonale (www.openforce.it) # Copyright 2018 Sergio Corato (https://efatto.it) # Copyright 2018 Lorenzo Battistini +# Copyright 2018 Sergio Zanchetta (Associazione PNLUG - Gruppo Odoo) # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). { - 'name': 'Italian Localization - FatturaPA - Emission - PEC Support', + 'name': 'Italian Localization - Fattura Elettronica - Supporto PEC', 'version': '12.0.1.1.0', 'category': 'Localization/Italy', - 'summary': 'Send electronic invoices via PEC', + 'summary': 'Invio fatture elettroniche tramite PEC', 'author': 'Openforce Srls Unipersonale, Odoo Community Association (OCA)', - 'website': 'https://github.com/OCA/l10n-italy', + 'website': 'https://github.com/OCA/l10n-italy/tree/10.0/' + 'l10n_it_fatturapa_pec', 'license': 'LGPL-3', 'depends': [ 'fetchmail', diff --git a/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py b/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py index acc37ea90551..e356703180fe 100644 --- a/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py +++ b/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py @@ -35,15 +35,15 @@ class FatturaPAAttachmentOut(models.Model): last_sdi_response = fields.Text( 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) + 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(_("You can only reset 'sender error' files")) + raise UserError(_("You can only reset 'sender error' files.")) att.state = 'ready' @api.model @@ -62,7 +62,7 @@ def send_via_pec(self): self.env.user.company_id.sdi_channel_id.check_first_pec_sending() states = self.mapped('state') if set(states) != set(['ready']): - raise UserError(_("You can only send 'ready to send' files")) + raise UserError(_("You can only send 'ready to send' files.")) for att in self: mail_message = self.env['mail.message'].create({ 'model': self._name, @@ -258,6 +258,6 @@ def unlink(self): for att in self: if att.state != 'ready': raise UserError(_( - "You can only delete 'ready to send' files" + "You can only delete 'ready to send' files." )) return super(FatturaPAAttachmentOut, self).unlink() diff --git a/l10n_it_fatturapa_pec/models/fetchmail.py b/l10n_it_fatturapa_pec/models/fetchmail.py index 40c78d2f0ccb..a8db7916d7cf 100644 --- a/l10n_it_fatturapa_pec/models/fetchmail.py +++ b/l10n_it_fatturapa_pec/models/fetchmail.py @@ -12,7 +12,7 @@ class Fetchmail(models.Model): _inherit = 'fetchmail.server' last_pec_error_message = fields.Text( - "Last PEC error message", readonly=True) + "Last PEC Error Message", readonly=True) @api.multi def fetch_mail(self): diff --git a/l10n_it_fatturapa_pec/readme/CONFIGURE.rst b/l10n_it_fatturapa_pec/readme/CONFIGURE.rst index e57ec1281819..ca85c7d9ae1d 100644 --- a/l10n_it_fatturapa_pec/readme/CONFIGURE.rst +++ b/l10n_it_fatturapa_pec/readme/CONFIGURE.rst @@ -1 +1,7 @@ -See `l10n_it_sdi_channel` module +**Italiano** + +Consultare il modulo `l10n_it_sdi_channel`. + +**English** + +See `l10n_it_sdi_channel` module. diff --git a/l10n_it_fatturapa_pec/readme/CONTRIBUTORS.rst b/l10n_it_fatturapa_pec/readme/CONTRIBUTORS.rst index 7f63b79cc053..1f704e5a8bce 100644 --- a/l10n_it_fatturapa_pec/readme/CONTRIBUTORS.rst +++ b/l10n_it_fatturapa_pec/readme/CONTRIBUTORS.rst @@ -1,3 +1,4 @@ * Andrea Colangelo * Sergio Corato * Lorenzo Battistini +* Sergio Zanchetta diff --git a/l10n_it_fatturapa_pec/readme/DESCRIPTION.rst b/l10n_it_fatturapa_pec/readme/DESCRIPTION.rst index aaab749107ef..c9a192f88591 100644 --- a/l10n_it_fatturapa_pec/readme/DESCRIPTION.rst +++ b/l10n_it_fatturapa_pec/readme/DESCRIPTION.rst @@ -1,5 +1,19 @@ -This module allows you to send and receive electronic invoice XML file version 1.2 +**Italiano** + +Questo modulo consente di inviare e ricevere i file XML della fattura elettronica versione 1.2 + http://www.fatturapa.gov.it/export/fatturazione/en/sdi.htm -via PEC -Notifications from SDI are parsed and transmission state is tracked. +via PEC. + +Analizza le notifiche provenienti dallo SdI e monitora lo stato della trasmissione. + +**English** + +This module allows you to send and receive electronic invoice/bill XML files version 1.2 + +http://www.fatturapa.gov.it/export/fatturazione/en/sdi.htm + +via PEC. + +Notifications from ES 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 index 51a873129961..addde6cfe16b 100644 --- a/l10n_it_fatturapa_pec/readme/USAGE.rst +++ b/l10n_it_fatturapa_pec/readme/USAGE.rst @@ -1,3 +1,11 @@ +**Italiano** + +Nell'allegato fattura elettronica in uscita fare clic sul pulsante "Invia con PEC". + +Le fatture elettroniche fornitore vengono create in modo automatico, prelevate dalla casella PEC. + +**English** + In electronic invoice out attachment you can click "Send Via PEC" button. -Supplier electronic invoices are automatically created, fetched from PEC mailbox. +Supplier electronic bills are automatically created, fetched from PEC mailbox. diff --git a/l10n_it_fatturapa_pec/static/description/index.html b/l10n_it_fatturapa_pec/static/description/index.html index a33bd896983f..3b4082ec3894 100644 --- a/l10n_it_fatturapa_pec/static/description/index.html +++ b/l10n_it_fatturapa_pec/static/description/index.html @@ -4,7 +4,7 @@ -Italian Localization - FatturaPA - Emission - PEC Support +Italian Localization - Fattura Elettronica - Supporto PEC -
-

Italian Localization - FatturaPA - Emission - PEC Support

+
+

Italian Localization - Fattura Elettronica - Supporto PEC

Beta License: LGPL-3 OCA/l10n-italy Translate me on Weblate Try me on Runbot

-

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.

+

Italiano

+

Questo modulo consente di inviare e ricevere i file XML della fattura elettronica versione 1.2

+

http://www.fatturapa.gov.it/export/fatturazione/en/sdi.htm

+

via PEC.

+

Analizza le notifiche provenienti dallo SdI e monitora lo stato della trasmissione.

+

English

+

This module allows you to send and receive electronic invoice/bill XML files version 1.2

+

http://www.fatturapa.gov.it/export/fatturazione/en/sdi.htm

+

via PEC.

+

Notifications from ES are parsed and transmission state is tracked.

Table of contents

    @@ -388,12 +394,19 @@

    Italian Localization - FatturaPA - Emission - PEC Support

Configuration

-

See l10n_it_sdi_channel module

+

Italiano

+

Consultare il modulo l10n_it_sdi_channel.

+

English

+

See l10n_it_sdi_channel module.

Usage

+

Italiano

+

Nell’allegato fattura elettronica in uscita fare clic sul pulsante “Invia con PEC”.

+

Le fatture elettroniche fornitore vengono create in modo automatico, prelevate dalla casella PEC.

+

English

In electronic invoice out attachment you can click “Send Via PEC” button.

-

Supplier electronic invoices are automatically created, fetched from PEC mailbox.

+

Supplier electronic bills are automatically created, fetched from PEC mailbox.

Bug Tracker

@@ -417,6 +430,7 @@

Contributors

  • Andrea Colangelo <andreacolangelo@openforce.it>
  • Sergio Corato <info@efatto.it>
  • Lorenzo Battistini <https://github.com/eLBati>
  • +
  • Sergio Zanchetta <https://github.com/primes2h>
  • diff --git a/l10n_it_fatturapa_pec/views/account.xml b/l10n_it_fatturapa_pec/views/account.xml index 27ae2a42513a..993fd7f90ed5 100644 --- a/l10n_it_fatturapa_pec/views/account.xml +++ b/l10n_it_fatturapa_pec/views/account.xml @@ -29,12 +29,12 @@ - - + + - + From d02c950c154cd9e2297b6976f237d9f521187b20 Mon Sep 17 00:00:00 2001 From: Lorenzo Battistini Date: Thu, 6 Dec 2018 10:27:09 +0100 Subject: [PATCH 09/65] Set reply_to and Return-Path to build explicitly email message, without using mail.catchall parameters anyway, using always 'email_from_for_fatturaPA' (#695) FIX missing body_html --- .../i18n/l10n_it_fatturapa_pec.pot | 118 ++++++++++-------- .../models/fatturapa_attachment_out.py | 32 ++--- 2 files changed, 76 insertions(+), 74 deletions(-) diff --git a/l10n_it_fatturapa_pec/i18n/l10n_it_fatturapa_pec.pot b/l10n_it_fatturapa_pec/i18n/l10n_it_fatturapa_pec.pot index 93c9aa3eb0f6..84a81363d001 100644 --- a/l10n_it_fatturapa_pec/i18n/l10n_it_fatturapa_pec.pot +++ b/l10n_it_fatturapa_pec/i18n/l10n_it_fatturapa_pec.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 10.0\n" +"Project-Id-Version: Odoo Server 12.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: <>\n" "Language-Team: \n" @@ -14,158 +14,178 @@ msgstr "" "Plural-Forms: \n" #. module: l10n_it_fatturapa_pec -#: model:ir.ui.view,arch_db:l10n_it_fatturapa_pec.wizard_fatturapa_send_pec_view +#: model_terms: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 +#: 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 +#: 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 +#: model_terms: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" +#: 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 +#: 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" +#: model:ir.model,name:l10n_it_fatturapa_pec.model_fatturapa_attachment_out +msgid "E-invoice Export File" msgstr "" #. module: l10n_it_fatturapa_pec -#: model:ir.model,name:l10n_it_fatturapa_pec.model_mail_thread -msgid "Email Thread" +#: 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 -#: selection:account.invoice,fatturapa_state:0 -msgid "Error" +#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_account_invoice_fatturapa_out_pec_filter +msgid "Electronic Invoice 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" +#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_account_invoice_fatturapa_out_pec_filter +msgid "Electronic Invoice 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 Ready to Send" +#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_account_invoice_fatturapa_out_pec_filter +msgid "Electronic Invoice State" 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" +#: model:ir.model,name:l10n_it_fatturapa_pec.model_mail_thread +msgid "Email Thread" msgstr "" #. module: l10n_it_fatturapa_pec -#: model:ir.model,name:l10n_it_fatturapa_pec.model_fatturapa_attachment_out -msgid "FatturaPA Export File" +#: selection:account.invoice,fatturapa_state:0 +msgid "Error" msgstr "" #. module: l10n_it_fatturapa_pec -#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_wizard_fatturapa_send_pec_id +#: 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_fetchmail_server +msgid "Incoming Mail Server" +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 +#: 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 +#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_fetchmail_server__last_pec_error_message +msgid "Last PEC Error Message" +msgstr "" + +#. module: l10n_it_fatturapa_pec +#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_fatturapa_attachment_out__last_sdi_response +#: model_terms: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 +#: 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 +#: 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" +#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_email_server_form_e_invoice +msgid "Last error message" +msgstr "" + +#. module: l10n_it_fatturapa_pec +#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:56 +#, python-format +msgid "No incoming PEC server found. Please configure it." msgstr "" #. module: l10n_it_fatturapa_pec #: selection:account.invoice,fatturapa_state:0 #: selection:fatturapa.attachment.out,state:0 +#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_attachment_search_state msgid "Ready to Send" msgstr "" #. module: l10n_it_fatturapa_pec #: selection:fatturapa.attachment.out,state:0 +#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_attachment_search_state msgid "Recipient Error" msgstr "" #. module: l10n_it_fatturapa_pec #: selection:fatturapa.attachment.out,state:0 +#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_attachment_search_state 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 +#: model_terms: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 +#: model_terms: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 +#: model_terms: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 +#: model_terms: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 +#: model_terms: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 +#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_attachment_search_state 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" +#: 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 @@ -175,17 +195,17 @@ 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" +#: 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_sending_date -msgid "Sent date" +#: model_terms: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_state +#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_fatturapa_attachment_out__state msgid "State" msgstr "" @@ -195,25 +215,25 @@ 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 +#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:242 #, python-format -msgid "Yo can only reset 'sender error' files" +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:247 +#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:46 #, python-format -msgid "You can only delete 'ready to send' files" +msgid "You can only reset 'sender error' files." msgstr "" #. module: l10n_it_fatturapa_pec -#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:54 +#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:65 #, python-format -msgid "You can only send 'ready to send' files" +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 +#: model_terms: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/fatturapa_attachment_out.py b/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py index e356703180fe..119512248b7b 100644 --- a/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py +++ b/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py @@ -76,31 +76,23 @@ def send_via_pec(self): 'attachment_ids': [(6, 0, att.ir_attachment_id.ids)], 'email_from': ( self.env.user.company_id.email_from_for_fatturaPA), + 'reply_to': ( + 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, + 'headers': { + 'Return-Path': + self.env.user.company_id.email_from_for_fatturaPA + } }) 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' @@ -112,16 +104,6 @@ def send_via_pec(self): att.state = 'sender_error' mail.body = str(e) - 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): message_dict['model'] = self._name From 62043c62f2d56f7514bfc9f2feb8b5fc72f6fbef Mon Sep 17 00:00:00 2001 From: eLBati Date: Sun, 9 Dec 2018 16:22:23 +0100 Subject: [PATCH 10/65] ADD l10n_it_fatturapa_pec/i18n/it.po --- l10n_it_fatturapa_pec/i18n/it.po | 242 +++++++++++++++++++++++++++++++ 1 file changed, 242 insertions(+) create mode 100644 l10n_it_fatturapa_pec/i18n/it.po diff --git a/l10n_it_fatturapa_pec/i18n/it.po b/l10n_it_fatturapa_pec/i18n/it.po new file mode 100644 index 000000000000..808c1faccb66 --- /dev/null +++ b/l10n_it_fatturapa_pec/i18n/it.po @@ -0,0 +1,242 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_it_fatturapa_pec +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" +"X-Generator: Poedit 1.8.7.1\n" +"Last-Translator: \n" +"Language: it_IT\n" + +#. module: l10n_it_fatturapa_pec +#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.wizard_fatturapa_send_pec_view +msgid "Cancel" +msgstr "Annulla" + +#. 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_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_pec_attachment_form +msgid "Delivered" +msgstr "Consegnata" + +#. 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 "Data consegna" + +#. 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 "Nome visualizzato" + +#. module: l10n_it_fatturapa_pec +#: model:ir.model,name:l10n_it_fatturapa_pec.model_fatturapa_attachment_out +msgid "E-invoice Export File" +msgstr "File esportato e-fattura" + +#. 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 "Stato e-fattura" + +#. module: l10n_it_fatturapa_pec +#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_account_invoice_fatturapa_out_pec_filter +msgid "Electronic Invoice Error" +msgstr "Errore fattura elettronica" + +#. module: l10n_it_fatturapa_pec +#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_account_invoice_fatturapa_out_pec_filter +msgid "Electronic Invoice Ready to Send" +msgstr "Fattura elettronica pronta per l'invio" + +#. module: l10n_it_fatturapa_pec +#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_account_invoice_fatturapa_out_pec_filter +msgid "Electronic Invoice State" +msgstr "Stato fattura elettronica" + +#. 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 "Errore" + +#. 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_fetchmail_server +msgid "Incoming Mail Server" +msgstr "Server email in ingresso" + +#. module: l10n_it_fatturapa_pec +#: model:ir.model,name:l10n_it_fatturapa_pec.model_account_invoice +msgid "Invoice" +msgstr "Fattura" + +#. 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_fetchmail_server__last_pec_error_message +msgid "Last PEC Error Message" +msgstr "Ultimo messaggio di errore PEC" + +#. module: l10n_it_fatturapa_pec +#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_fatturapa_attachment_out__last_sdi_response +#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_pec_attachment_form +msgid "Last Response from Exchange System" +msgstr "Ultima risposta dal sistema di interscambio" + +#. 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_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_email_server_form_e_invoice +msgid "Last error message" +msgstr "Ultimo messaggio di errore" + +#. module: l10n_it_fatturapa_pec +#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:56 +#, python-format +msgid "No incoming PEC server found. Please configure it." +msgstr "Nessun server PEC in ingresso trovato. Prego configurarlo." + +#. module: l10n_it_fatturapa_pec +#: selection:account.invoice,fatturapa_state:0 +#: selection:fatturapa.attachment.out,state:0 +#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_attachment_search_state +msgid "Ready to Send" +msgstr "Pronta per l'invio" + +#. module: l10n_it_fatturapa_pec +#: selection:fatturapa.attachment.out,state:0 +#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_attachment_search_state +msgid "Recipient Error" +msgstr "Errore destinatario" + +#. module: l10n_it_fatturapa_pec +#: selection:fatturapa.attachment.out,state:0 +#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_attachment_search_state +msgid "Rejected (PA)" +msgstr "Rifiutato (PA)" + +#. module: l10n_it_fatturapa_pec +#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_pec_attachment_form +msgid "Reset to ready" +msgstr "Pronta per l'incio" + +#. module: l10n_it_fatturapa_pec +#: model_terms: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 "I file selezionati verranno inviati al sistema di interscambio" + +#. module: l10n_it_fatturapa_pec +#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.wizard_fatturapa_send_pec_view +msgid "Send" +msgstr "Invia" + +#. module: l10n_it_fatturapa_pec +#: model:ir.actions.act_window,name:l10n_it_fatturapa_pec.action_wizard_fatturapa_send_pec +#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.wizard_fatturapa_send_pec_view +msgid "Send Electronic Invoice" +msgstr "Invia fattura elettronica" + +#. module: l10n_it_fatturapa_pec +#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_pec_attachment_form +msgid "Send Via PEC" +msgstr "Invia via PEC" + +#. module: l10n_it_fatturapa_pec +#: selection:fatturapa.attachment.out,state:0 +#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_attachment_search_state +msgid "Sender Error" +msgstr "Errore trasmittente" + +#. 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 "Utente trasmittente" + +#. module: l10n_it_fatturapa_pec +#: selection:account.invoice,fatturapa_state:0 +#: selection:fatturapa.attachment.out,state:0 +msgid "Sent" +msgstr "Inviata" + +#. 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 "Data invio" + +#. module: l10n_it_fatturapa_pec +#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_pec_attachment_form +msgid "Sent by" +msgstr "Inviato da" + +#. module: l10n_it_fatturapa_pec +#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_fatturapa_attachment_out__state +msgid "State" +msgstr "Stato" + +#. 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 "Procedura per inviare PEC multiple" + +#. module: l10n_it_fatturapa_pec +#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:242 +#, python-format +msgid "You can only delete 'ready to send' files." +msgstr "E' solamente possibile eliminare file 'pronti per l'invio'." + +#. module: l10n_it_fatturapa_pec +#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:46 +#, python-format +msgid "You can only reset 'sender error' files." +msgstr "E' solamente possibile reimpostare file in 'errore trasmittente'." + +#. module: l10n_it_fatturapa_pec +#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:65 +#, python-format +msgid "You can only send 'ready to send' files." +msgstr "E' solamente possibile inviare file 'pronti per l'invio'." + +#. module: l10n_it_fatturapa_pec +#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_pec_attachment_form +msgid "on" +msgstr "" From ec277fc6e712114a9e0adef0d6cdf607bdc93691 Mon Sep 17 00:00:00 2001 From: Sergio Zanchetta Date: Wed, 12 Dec 2018 18:17:35 +0100 Subject: [PATCH 11/65] [FIX] fatturapa titles using italian guidelines (#718) --- l10n_it_fatturapa_pec/README.rst | 2 +- l10n_it_fatturapa_pec/__manifest__.py | 2 +- l10n_it_fatturapa_pec/static/description/index.html | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/l10n_it_fatturapa_pec/README.rst b/l10n_it_fatturapa_pec/README.rst index 93e2d69da28d..68194139d431 100644 --- a/l10n_it_fatturapa_pec/README.rst +++ b/l10n_it_fatturapa_pec/README.rst @@ -1,5 +1,5 @@ ========================================================= -Italian Localization - Fattura Elettronica - Supporto PEC +Italian Localization - Fattura elettronica - Supporto PEC ========================================================= .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/l10n_it_fatturapa_pec/__manifest__.py b/l10n_it_fatturapa_pec/__manifest__.py index 09de7508c81b..6c4781ad06c4 100644 --- a/l10n_it_fatturapa_pec/__manifest__.py +++ b/l10n_it_fatturapa_pec/__manifest__.py @@ -6,7 +6,7 @@ # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). { - 'name': 'Italian Localization - Fattura Elettronica - Supporto PEC', + 'name': 'Italian Localization - Fattura elettronica - Supporto PEC', 'version': '12.0.1.1.0', 'category': 'Localization/Italy', 'summary': 'Invio fatture elettroniche tramite PEC', diff --git a/l10n_it_fatturapa_pec/static/description/index.html b/l10n_it_fatturapa_pec/static/description/index.html index 3b4082ec3894..17f011f5ae65 100644 --- a/l10n_it_fatturapa_pec/static/description/index.html +++ b/l10n_it_fatturapa_pec/static/description/index.html @@ -4,7 +4,7 @@ -Italian Localization - Fattura Elettronica - Supporto PEC +Italian Localization - Fattura elettronica - Supporto PEC -
    -

    Italian Localization - Fattura elettronica - Supporto PEC

    +
    +

    ITA - Fattura elettronica - Supporto PEC

    -

    Beta License: LGPL-3 OCA/l10n-italy Translate me on Weblate Try me on Runbot

    +

    Beta License: AGPL-3 OCA/l10n-italy Translate me on Weblate Try me on Runbot

    Italiano

    Questo modulo consente di inviare e ricevere i file XML della fattura elettronica versione 1.2

    http://www.fatturapa.gov.it/export/fatturazione/en/sdi.htm

    diff --git a/l10n_it_fatturapa_pec/wizard/__init__.py b/l10n_it_fatturapa_pec/wizard/__init__.py index 63d026cbdf55..cc6229db7d17 100644 --- a/l10n_it_fatturapa_pec/wizard/__init__.py +++ b/l10n_it_fatturapa_pec/wizard/__init__.py @@ -1,3 +1,2 @@ -# 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 f196c39aebd6..744d36dd4ee5 100644 --- a/l10n_it_fatturapa_pec/wizard/send_pec.py +++ b/l10n_it_fatturapa_pec/wizard/send_pec.py @@ -1,4 +1,3 @@ -# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). from odoo import models, api From 6f80316ba9f9048d6b95f5f3ef7e56983400d871 Mon Sep 17 00:00:00 2001 From: SimoRubi Date: Fri, 18 Sep 2020 15:55:58 +0200 Subject: [PATCH 48/65] [FIX] l10n_it_fatturapa_in: Mute parsing exception when reading data from broken XML test --- .../tests/test_e_invoice_response.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/l10n_it_fatturapa_pec/tests/test_e_invoice_response.py b/l10n_it_fatturapa_pec/tests/test_e_invoice_response.py index ecde762cdec2..57c77d0d8131 100644 --- a/l10n_it_fatturapa_pec/tests/test_e_invoice_response.py +++ b/l10n_it_fatturapa_pec/tests/test_e_invoice_response.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Copyright 2018 Simone Rubino - Agile Business Group # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - +from odoo.tools import mute_logger from .e_invoice_common import EInvoiceCommon from odoo.modules import get_module_resource from odoo.fields import Datetime @@ -127,10 +127,15 @@ def test_process_response_INVIO_broken_XML(self): instance.stat.return_value = (1, 1) instance.retr.return_value = ('', [incoming_mail], '') - self.PEC_server.fetch_mail() + with mute_logger( + 'odoo.addons.l10n_it_fatturapa_pec.models.fetchmail'): + self.PEC_server.fetch_mail() - error_mails_nbr = outbound_mail_model.search_count(error_mail_domain) - self.assertEqual(error_mails_nbr, 1) + error_mails = outbound_mail_model.search(error_mail_domain) + self.assertEqual(len(error_mails), 1) + xml_error = 'unbound prefix' + self.assertIn(xml_error, error_mails.body_html) + self.assertIn(xml_error, self.PEC_server.last_pec_error_message) def test_process_response_MC(self): """Receiving a 'Mancata consegna' sets the state of the From 3cca9cc55a8ab11b3ea31e8e62d847980eef0f40 Mon Sep 17 00:00:00 2001 From: Roberto Fichera Date: Wed, 18 Dec 2019 19:51:20 +0100 Subject: [PATCH 49/65] =?UTF-8?q?[10.0][l10n=5Fit=5Ffatturapa=5Fout]=20Agg?= =?UTF-8?q?iunge=20la=20possibilit=C3=A0=20di=20specificare=20per=20client?= =?UTF-8?q?e=20quante=20fatture=20si=20vogliono=20inserire=20in=20un=20fil?= =?UTF-8?q?e=20xml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [10.0][l10n_it_fatturapa_pec] Permettere di rigenerare il file xml per le fatture elettroniche in stato di errore [10.0][l10n_it_fatturapa_out] Refactory del metodo di generazione delle fatture elettroniche, supporto per rigenerare gli xml e limite di fatture da inserire nel file xml generato --- l10n_it_fatturapa_pec/__manifest__.py | 4 +- l10n_it_fatturapa_pec/views/account.xml | 20 ++++- l10n_it_fatturapa_pec/wizard/__init__.py | 1 + .../wizard/wizard_export_fatturapa.py | 79 +++++++++++++++++++ .../wizard/wizard_export_fatturapa_view.xml | 18 +++++ 5 files changed, 118 insertions(+), 4 deletions(-) create mode 100644 l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa.py create mode 100644 l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa_view.xml diff --git a/l10n_it_fatturapa_pec/__manifest__.py b/l10n_it_fatturapa_pec/__manifest__.py index d4c841584610..88100bb2ebca 100644 --- a/l10n_it_fatturapa_pec/__manifest__.py +++ b/l10n_it_fatturapa_pec/__manifest__.py @@ -3,6 +3,7 @@ # Copyright 2018-2019 Sergio Corato (https://efatto.it) # Copyright 2018-2019 Lorenzo Battistini # Copyright 2018 Sergio Zanchetta (Associazione PNLUG - Gruppo Odoo) +# Copyright 2019 Roberto Fichera (https://levelprime.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { @@ -22,9 +23,10 @@ ], 'data': [ 'security/groups.xml', - 'views/account.xml', 'views/fatturapa_attachment_out.xml', 'wizard/send_pec_view.xml', + 'wizard/wizard_export_fatturapa_view.xml', + 'views/account.xml', 'views/fetchmail_view.xml', 'security/ir.model.access.csv', 'data/fetchmail_data.xml', diff --git a/l10n_it_fatturapa_pec/views/account.xml b/l10n_it_fatturapa_pec/views/account.xml index 993fd7f90ed5..6ce653a06cbd 100644 --- a/l10n_it_fatturapa_pec/views/account.xml +++ b/l10n_it_fatturapa_pec/views/account.xml @@ -1,9 +1,17 @@ + + + view.invoice.fatturapa.out.pec.tree account.invoice - + @@ -14,18 +22,23 @@ view.invoice.fatturapa.out.pec.form account.invoice - + + view.account.invoice.fatturapa.out.pec.filter account.invoice - + @@ -38,4 +51,5 @@ + diff --git a/l10n_it_fatturapa_pec/wizard/__init__.py b/l10n_it_fatturapa_pec/wizard/__init__.py index cc6229db7d17..ec8ceddeffdc 100644 --- a/l10n_it_fatturapa_pec/wizard/__init__.py +++ b/l10n_it_fatturapa_pec/wizard/__init__.py @@ -1,2 +1,3 @@ from . import send_pec +from . import wizard_export_fatturapa diff --git a/l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa.py b/l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa.py new file mode 100644 index 000000000000..ee1a57ef308c --- /dev/null +++ b/l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa.py @@ -0,0 +1,79 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 Roberto Fichera - Level Prime Srl +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +import base64 +import logging + +from odoo import models, _ +from odoo.exceptions import ValidationError + +from odoo.addons.l10n_it_fatturapa_out.wizard.wizard_export_fatturapa import ( + fatturapaBDS +) + +_logger = logging.getLogger(__name__) + + +class WizardExportFatturapa(models.TransientModel): + _inherit = "wizard.export.fatturapa" + + def updateAttachment(self, attach, fatturapa): + attach_str = fatturapa.toxml( + encoding="UTF-8", + bds=fatturapaBDS, + ) + fatturapaBDS.reset() + attach.write({ + 'datas': base64.encodestring(attach_str), + }) + + def exportFatturaPARegenerate(self): + invoice_obj = self.env['account.invoice'] + attachments = self.env['fatturapa.attachment.out'] + # Browse active invoice + active_id = invoice_obj.browse(self._context.get('active_id')) + + if not active_id: + raise ValidationError( + _('The method can be called with a valid active_id')) + + # Search all the invoices belonging the same xml file + invoice_ids = invoice_obj.search( + [('fatturapa_attachment_out_id', '=', + active_id.fatturapa_attachment_out_id.id)]).ids + + attach = active_id.fatturapa_attachment_out_id + if not attach: + raise ValidationError( + _("The invoice cannot be regenerated because doesn't have a " + "e-invoice attachment associated to it")) + + partner = active_id.partner_id + company = self.env.user.company_id + context_partner = self.env.context.copy() + context_partner.update({'lang': partner.lang}) + + fatturapa, number = self.exportInvoiceXML( + company, partner, invoice_ids, attach=attach, + context=context_partner) + + self.updateAttachment(attach, fatturapa) + + attachments += attach + + action = { + 'view_type': 'form', + 'name': "Re-Export Electronic Invoice", + 'res_model': 'fatturapa.attachment.out', + 'type': 'ir.actions.act_window', + } + + if len(attachments) == 1: + action['view_mode'] = 'form' + action['res_id'] = attachments[0].id + else: + action['view_mode'] = 'tree,form' + action['domain'] = [('id', 'in', attachments.ids)] + + return action diff --git a/l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa_view.xml b/l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa_view.xml new file mode 100644 index 000000000000..ef3a0b3b831c --- /dev/null +++ b/l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa_view.xml @@ -0,0 +1,18 @@ + + + + Export Electronic Invoice Regenerate + wizard.export.fatturapa + primary + + + + 1 + + +
    diff --git a/l10n_it_fatturapa_pec/tests/test_e_invoice_send.py b/l10n_it_fatturapa_pec/tests/test_e_invoice_send.py index 110e8cdf4949..7f8d4f7a6042 100644 --- a/l10n_it_fatturapa_pec/tests/test_e_invoice_send.py +++ b/l10n_it_fatturapa_pec/tests/test_e_invoice_send.py @@ -4,6 +4,7 @@ from odoo.exceptions import UserError from .e_invoice_common import EInvoiceCommon +from odoo.tools import mute_logger class TestEInvoiceSend(EInvoiceCommon): @@ -20,6 +21,7 @@ def test_send_check_fetchmail(self): with self.assertRaises(UserError): e_invoice.send_via_pec() + @mute_logger("odoo.addons.mail.models.mail_mail") def test_sender_error(self): """Sending e-invoice without configuring email_from_for_fatturaPA fails to send the email""" From 7e97dc47c7bd69b690f6ce7b3b909cb104bef01c Mon Sep 17 00:00:00 2001 From: Sergio Zanchetta Date: Wed, 3 Feb 2021 10:02:02 +0000 Subject: [PATCH 54/65] Translated using Weblate (Italian) Currently translated at 100.0% (63 of 63 strings) Translation: l10n-italy-12.0/l10n-italy-12.0-l10n_it_fatturapa_pec Translate-URL: https://translation.odoo-community.org/projects/l10n-italy-12-0/l10n-italy-12-0-l10n_it_fatturapa_pec/it/ --- l10n_it_fatturapa_pec/i18n/it.po | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/l10n_it_fatturapa_pec/i18n/it.po b/l10n_it_fatturapa_pec/i18n/it.po index 154e514f65a7..de70dcf1e317 100644 --- a/l10n_it_fatturapa_pec/i18n/it.po +++ b/l10n_it_fatturapa_pec/i18n/it.po @@ -7,15 +7,15 @@ msgstr "" "Project-Id-Version: Odoo Server 12.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2020-07-20 06:19+0000\n" -"Last-Translator: Lorenzo Battistini \n" +"PO-Revision-Date: 2021-02-03 12:44+0000\n" +"Last-Translator: Sergio Zanchetta \n" "Language-Team: \n" "Language: it\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 3.10\n" +"X-Generator: Weblate 4.3.2\n" #. module: l10n_it_fatturapa_pec #: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_account_config_settings_ftpa_pec @@ -142,7 +142,7 @@ msgstr "Errore" #. module: l10n_it_fatturapa_pec #: model:ir.model,name:l10n_it_fatturapa_pec.model_wizard_export_fatturapa msgid "Export E-invoice" -msgstr "" +msgstr "Esporta e-fattura" #. module: l10n_it_fatturapa_pec #: code:addons/l10n_it_fatturapa_pec/models/fetchmail.py:180 @@ -241,17 +241,17 @@ msgstr "" #. module: l10n_it_fatturapa_pec #: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.wizard_export_fatturapa_form_view_regenerate msgid "Re-Export" -msgstr "" +msgstr "Riesporta" #. module: l10n_it_fatturapa_pec #: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_invoice_fatturapa_out_pec_form msgid "Re-Export E-invoice" -msgstr "" +msgstr "Riesporta e-fattura" #. module: l10n_it_fatturapa_pec #: model:ir.actions.act_window,name:l10n_it_fatturapa_pec.action_wizard_export_fatturapa_regenerate msgid "Re-Export Electronic Invoice" -msgstr "" +msgstr "Riesporta fattura elettronica" #. module: l10n_it_fatturapa_pec #: selection:account.invoice,fatturapa_state:0 @@ -331,12 +331,14 @@ msgid "" "The invoice cannot be regenerated because doesn't have a e-invoice " "attachment associated to it" msgstr "" +"La fattura non può essere rigenerata, non possiede un allegato e-fattura " +"associato" #. module: l10n_it_fatturapa_pec #: code:addons/l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa.py:39 #, python-format msgid "The method can be called with a valid active_id" -msgstr "" +msgstr "Il metodo può essere chiamato con un active_id valido" #. module: l10n_it_fatturapa_pec #: model:ir.model.fields,help:l10n_it_fatturapa_pec.field_res_company__e_invoice_user_id From 9cc0cb31ecc4543d886a7b594e639af63c7067ed Mon Sep 17 00:00:00 2001 From: eLBati Date: Fri, 5 Feb 2021 07:14:36 +0100 Subject: [PATCH 55/65] Allow to cancel (and re-generate) invoice when e-invoice is in error state --- l10n_it_fatturapa_pec/__manifest__.py | 2 +- l10n_it_fatturapa_pec/i18n/it.po | 4 ++-- .../i18n/l10n_it_fatturapa_pec.pot | 4 ++-- l10n_it_fatturapa_pec/models/account.py | 10 ++++++++++ .../tests/test_e_invoice_send.py | 18 ++++++++++++++++-- .../wizard/wizard_export_fatturapa.py | 1 + 6 files changed, 32 insertions(+), 7 deletions(-) diff --git a/l10n_it_fatturapa_pec/__manifest__.py b/l10n_it_fatturapa_pec/__manifest__.py index f8e4725c9a68..fb175d2c93b6 100644 --- a/l10n_it_fatturapa_pec/__manifest__.py +++ b/l10n_it_fatturapa_pec/__manifest__.py @@ -8,7 +8,7 @@ { 'name': 'ITA - Fattura elettronica - Supporto PEC', - 'version': '12.0.1.8.0', + 'version': '12.0.1.9.0', 'category': 'Localization/Italy', 'summary': 'Invio fatture elettroniche tramite PEC', 'author': 'Openforce Srls Unipersonale, Odoo Community Association (OCA)', diff --git a/l10n_it_fatturapa_pec/i18n/it.po b/l10n_it_fatturapa_pec/i18n/it.po index de70dcf1e317..5ec7736b30dd 100644 --- a/l10n_it_fatturapa_pec/i18n/it.po +++ b/l10n_it_fatturapa_pec/i18n/it.po @@ -325,7 +325,7 @@ msgid "State" msgstr "Stato" #. module: l10n_it_fatturapa_pec -#: code:addons/l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa.py:49 +#: code:addons/l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa.py:50 #, python-format msgid "" "The invoice cannot be regenerated because doesn't have a e-invoice " @@ -335,7 +335,7 @@ msgstr "" "associato" #. module: l10n_it_fatturapa_pec -#: code:addons/l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa.py:39 +#: code:addons/l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa.py:40 #, python-format msgid "The method can be called with a valid active_id" msgstr "Il metodo può essere chiamato con un active_id valido" diff --git a/l10n_it_fatturapa_pec/i18n/l10n_it_fatturapa_pec.pot b/l10n_it_fatturapa_pec/i18n/l10n_it_fatturapa_pec.pot index b9d479dd3aef..def57ff10e2f 100644 --- a/l10n_it_fatturapa_pec/i18n/l10n_it_fatturapa_pec.pot +++ b/l10n_it_fatturapa_pec/i18n/l10n_it_fatturapa_pec.pot @@ -308,13 +308,13 @@ msgid "State" msgstr "" #. module: l10n_it_fatturapa_pec -#: code:addons/l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa.py:49 +#: code:addons/l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa.py:50 #, python-format msgid "The invoice cannot be regenerated because doesn't have a e-invoice attachment associated to it" msgstr "" #. module: l10n_it_fatturapa_pec -#: code:addons/l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa.py:39 +#: code:addons/l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa.py:40 #, python-format msgid "The method can be called with a valid active_id" msgstr "" diff --git a/l10n_it_fatturapa_pec/models/account.py b/l10n_it_fatturapa_pec/models/account.py index c971893d5dd8..d3db6a413d5b 100644 --- a/l10n_it_fatturapa_pec/models/account.py +++ b/l10n_it_fatturapa_pec/models/account.py @@ -36,3 +36,13 @@ def _compute_fatturapa_state(self): for record in self: record.fatturapa_state = fatturapa_attachment_state_mapping.get( record.fatturapa_attachment_out_id.state) + + @api.multi + def action_invoice_cancel(self): + for invoice in self: + if invoice.fatturapa_state == "error": + res = super(AccountInvoice, invoice.with_context( + skip_e_invoice_cancel_check=True)).action_invoice_cancel() + else: + res = super(AccountInvoice, invoice).action_invoice_cancel() + return res diff --git a/l10n_it_fatturapa_pec/tests/test_e_invoice_send.py b/l10n_it_fatturapa_pec/tests/test_e_invoice_send.py index 7f8d4f7a6042..588168a1310b 100644 --- a/l10n_it_fatturapa_pec/tests/test_e_invoice_send.py +++ b/l10n_it_fatturapa_pec/tests/test_e_invoice_send.py @@ -92,11 +92,25 @@ def test_resend_after_regenerate(self): # Set the e_invoice to error e_invoice.state = 'sender_error' - # We can reset e-invoice whose state is 'sender_error' - e_invoice.reset_to_ready() + wizard.with_context(active_id=invoice.id).\ + exportFatturaPARegenerate() + self.assertEqual(e_invoice.state, "ready") + + with self.assertRaises(UserError): + invoice.action_invoice_cancel() + + e_invoice.state = 'sender_error' + invoice.journal_id.update_posted = True + invoice.action_invoice_cancel() + invoice.refresh() + invoice.action_invoice_draft() + invoice.refresh() + invoice.action_invoice_open() + invoice.refresh() action = wizard.with_context(active_id=invoice.id).\ exportFatturaPARegenerate() + e_invoice = self.env[action['res_model']].browse(action['res_id']) # set SDI address after first sending diff --git a/l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa.py b/l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa.py index ee1a57ef308c..8182da8d623a 100644 --- a/l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa.py +++ b/l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa.py @@ -26,6 +26,7 @@ def updateAttachment(self, attach, fatturapa): fatturapaBDS.reset() attach.write({ 'datas': base64.encodestring(attach_str), + 'state': 'ready', }) def exportFatturaPARegenerate(self): From 5051064ec85f007a93992519bf71e32063159b92 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Thu, 18 Feb 2021 16:37:09 +0100 Subject: [PATCH 56/65] move state from fatturapa_pec to fatturapa_out --- l10n_it_fatturapa_pec/__manifest__.py | 2 +- l10n_it_fatturapa_pec/i18n/it.po | 39 ++++++------------- .../i18n/l10n_it_fatturapa_pec.pot | 30 ++------------ .../models/fatturapa_attachment_out.py | 29 -------------- l10n_it_fatturapa_pec/tests/__init__.py | 1 - .../tests/test_e_invoice_common.py | 18 --------- .../views/fatturapa_attachment_out.xml | 5 +-- 7 files changed, 17 insertions(+), 107 deletions(-) delete mode 100644 l10n_it_fatturapa_pec/tests/test_e_invoice_common.py diff --git a/l10n_it_fatturapa_pec/__manifest__.py b/l10n_it_fatturapa_pec/__manifest__.py index fb175d2c93b6..d642232f786a 100644 --- a/l10n_it_fatturapa_pec/__manifest__.py +++ b/l10n_it_fatturapa_pec/__manifest__.py @@ -8,7 +8,7 @@ { 'name': 'ITA - Fattura elettronica - Supporto PEC', - 'version': '12.0.1.9.0', + 'version': '12.0.1.9.1', 'category': 'Localization/Italy', 'summary': 'Invio fatture elettroniche tramite PEC', 'author': 'Openforce Srls Unipersonale, Odoo Community Association (OCA)', diff --git a/l10n_it_fatturapa_pec/i18n/it.po b/l10n_it_fatturapa_pec/i18n/it.po index 5ec7736b30dd..58f575c7bea0 100644 --- a/l10n_it_fatturapa_pec/i18n/it.po +++ b/l10n_it_fatturapa_pec/i18n/it.po @@ -32,7 +32,6 @@ msgstr "" #. module: l10n_it_fatturapa_pec #: selection:account.invoice,fatturapa_state:0 -#: selection:fatturapa.attachment.out,state:0 msgid "Accepted" msgstr "Accettato" @@ -83,7 +82,6 @@ msgstr "Utente predefinito usato nelle fatture elettroniche fornitore" #. module: l10n_it_fatturapa_pec #: selection:account.invoice,fatturapa_state:0 -#: selection:fatturapa.attachment.out,state:0 #: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_pec_attachment_form msgid "Delivered" msgstr "Consegnato" @@ -151,7 +149,7 @@ msgid "Fetchmail PEC server [%s] error" msgstr "Errore fetchmail server PEC [%s]" #. module: l10n_it_fatturapa_pec -#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:72 +#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:52 #, python-format msgid "File content and file name are mandatory" msgstr "Il contenuto e il nome del file sono obbligatori" @@ -203,13 +201,12 @@ msgid "Last error message" msgstr "Ultimo messaggio di errore" #. module: l10n_it_fatturapa_pec -#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:58 +#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:38 #, python-format msgid "No incoming PEC server found. Please configure it." msgstr "Nessun server PEC in ingresso trovato, configurarne uno." #. module: l10n_it_fatturapa_pec -#: selection:fatturapa.attachment.out,state:0 #: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_attachment_search_state msgid "Not delivered" msgstr "Non consegnato" @@ -255,13 +252,11 @@ msgstr "Riesporta fattura elettronica" #. module: l10n_it_fatturapa_pec #: selection:account.invoice,fatturapa_state:0 -#: selection:fatturapa.attachment.out,state:0 #: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_attachment_search_state msgid "Ready to Send" msgstr "Pronto per l'invio" #. module: l10n_it_fatturapa_pec -#: selection:fatturapa.attachment.out,state:0 #: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_attachment_search_state msgid "Rejected (PA)" msgstr "Rifiutato (PA)" @@ -293,7 +288,6 @@ msgid "Send Via PEC" msgstr "Invia con PEC" #. module: l10n_it_fatturapa_pec -#: selection:fatturapa.attachment.out,state:0 #: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_attachment_search_state msgid "Sender Error" msgstr "Errore trasmittente" @@ -305,7 +299,6 @@ msgstr "Utente trasmittente" #. module: l10n_it_fatturapa_pec #: selection:account.invoice,fatturapa_state:0 -#: selection:fatturapa.attachment.out,state:0 msgid "Sent" msgstr "Inviato" @@ -319,11 +312,6 @@ msgstr "Data invio" msgid "Sent by" msgstr "Inviato da" -#. module: l10n_it_fatturapa_pec -#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_fatturapa_attachment_out__state -msgid "State" -msgstr "Stato" - #. module: l10n_it_fatturapa_pec #: code:addons/l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa.py:50 #, python-format @@ -353,19 +341,7 @@ msgid "Wizard to send multiple e-invoice PEC" msgstr "Procedura per inviare PEC e-fattura multiple" #. module: l10n_it_fatturapa_pec -#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:248 -#, python-format -msgid "You can only delete files in 'Ready to Send' state." -msgstr "È possibile eliminare solo file con stato «Pronto per l'invio»." - -#. module: l10n_it_fatturapa_pec -#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:47 -#, python-format -msgid "You can only reset files in 'Sender Error' state." -msgstr "È possibile reimpostare solo file con stato «Errore trasmittente»." - -#. module: l10n_it_fatturapa_pec -#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:68 +#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:48 #, python-format msgid "You can only send files in 'Ready to Send' state." msgstr "È possibile inviare solo file con stato «Pronto per l'invio»." @@ -375,6 +351,15 @@ msgstr "È possibile inviare solo file con stato «Pronto per l'invio»." msgid "on" msgstr "il" +#~ msgid "State" +#~ msgstr "Stato" + +#~ msgid "You can only delete files in 'Ready to Send' state." +#~ msgstr "È possibile eliminare solo file con stato «Pronto per l'invio»." + +#~ msgid "You can only reset files in 'Sender Error' state." +#~ msgstr "È possibile reimpostare solo file con stato «Errore trasmittente»." + #~ msgid "PEC message [%s] not processed" #~ msgstr "Messaggio PEC [%s] non elaborato" diff --git a/l10n_it_fatturapa_pec/i18n/l10n_it_fatturapa_pec.pot b/l10n_it_fatturapa_pec/i18n/l10n_it_fatturapa_pec.pot index def57ff10e2f..8255ad84ced9 100644 --- a/l10n_it_fatturapa_pec/i18n/l10n_it_fatturapa_pec.pot +++ b/l10n_it_fatturapa_pec/i18n/l10n_it_fatturapa_pec.pot @@ -21,7 +21,6 @@ msgstr "" #. module: l10n_it_fatturapa_pec #: selection:account.invoice,fatturapa_state:0 -#: selection:fatturapa.attachment.out,state:0 msgid "Accepted" msgstr "" @@ -72,7 +71,6 @@ msgstr "" #. module: l10n_it_fatturapa_pec #: selection:account.invoice,fatturapa_state:0 -#: selection:fatturapa.attachment.out,state:0 #: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_pec_attachment_form msgid "Delivered" msgstr "" @@ -140,7 +138,7 @@ msgid "Fetchmail PEC server [%s] error" msgstr "" #. module: l10n_it_fatturapa_pec -#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:72 +#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:52 #, python-format msgid "File content and file name are mandatory" msgstr "" @@ -192,13 +190,12 @@ msgid "Last error message" msgstr "" #. module: l10n_it_fatturapa_pec -#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:58 +#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:38 #, python-format msgid "No incoming PEC server found. Please configure it." msgstr "" #. module: l10n_it_fatturapa_pec -#: selection:fatturapa.attachment.out,state:0 #: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_attachment_search_state msgid "Not delivered" msgstr "" @@ -238,13 +235,11 @@ msgstr "" #. module: l10n_it_fatturapa_pec #: selection:account.invoice,fatturapa_state:0 -#: selection:fatturapa.attachment.out,state:0 #: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_attachment_search_state msgid "Ready to Send" msgstr "" #. module: l10n_it_fatturapa_pec -#: selection:fatturapa.attachment.out,state:0 #: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_attachment_search_state msgid "Rejected (PA)" msgstr "" @@ -276,7 +271,6 @@ msgid "Send Via PEC" msgstr "" #. module: l10n_it_fatturapa_pec -#: selection:fatturapa.attachment.out,state:0 #: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_attachment_search_state msgid "Sender Error" msgstr "" @@ -288,7 +282,6 @@ msgstr "" #. module: l10n_it_fatturapa_pec #: selection:account.invoice,fatturapa_state:0 -#: selection:fatturapa.attachment.out,state:0 msgid "Sent" msgstr "" @@ -302,11 +295,6 @@ msgstr "" msgid "Sent by" 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 #: code:addons/l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa.py:50 #, python-format @@ -331,19 +319,7 @@ 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:248 -#, python-format -msgid "You can only delete files in 'Ready to Send' state." -msgstr "" - -#. module: l10n_it_fatturapa_pec -#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:47 -#, python-format -msgid "You can only reset files in 'Sender Error' state." -msgstr "" - -#. module: l10n_it_fatturapa_pec -#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:68 +#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:48 #, python-format msgid "You can only send files in 'Ready to Send' state." msgstr "" diff --git a/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py b/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py index e1cf2d69979b..e18979774e6b 100644 --- a/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py +++ b/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py @@ -21,17 +21,6 @@ class FatturaPAAttachmentOut(models.Model): _inherit = 'fatturapa.attachment.out' - state = fields.Selection([('ready', 'Ready to Send'), - ('sent', 'Sent'), - ('sender_error', 'Sender Error'), - ('recipient_error', 'Not delivered'), - ('rejected', 'Rejected (PA)'), - ('validated', 'Delivered'), - ('accepted', 'Accepted'), - ], - string='State', - default='ready', track_visibility='onchange') - last_sdi_response = fields.Text( string='Last Response from Exchange System', default='No response yet', readonly=True) @@ -39,15 +28,6 @@ class FatturaPAAttachmentOut(models.Model): 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( - _("You can only reset files in 'Sender Error' state.") - ) - att.state = 'ready' - @api.model def _check_fetchmail(self): server = self.env['fetchmail.server'].search([ @@ -240,12 +220,3 @@ def parse_pec_response(self, message_dict): 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 files in 'Ready to Send' state." - )) - return super(FatturaPAAttachmentOut, self).unlink() diff --git a/l10n_it_fatturapa_pec/tests/__init__.py b/l10n_it_fatturapa_pec/tests/__init__.py index b5374f134bae..60d8d4f91696 100644 --- a/l10n_it_fatturapa_pec/tests/__init__.py +++ b/l10n_it_fatturapa_pec/tests/__init__.py @@ -2,6 +2,5 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from . import e_invoice_common -from . import test_e_invoice_common from . import test_e_invoice_response from . import test_e_invoice_send diff --git a/l10n_it_fatturapa_pec/tests/test_e_invoice_common.py b/l10n_it_fatturapa_pec/tests/test_e_invoice_common.py deleted file mode 100644 index c6d4abebd104..000000000000 --- a/l10n_it_fatturapa_pec/tests/test_e_invoice_common.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2018 Simone Rubino - Agile Business Group -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from odoo.addons.l10n_it_fatturapa_pec.tests.e_invoice_common \ - import EInvoiceCommon - - -class TestEInvoiceCommon(EInvoiceCommon): - - def setUp(self): - super(TestEInvoiceCommon, self).setUp() - - def test_unlink(self): - """Deleting ready invoice""" - e_invoice = self._create_e_invoice() - e_invoice.unlink() - self.assertFalse(e_invoice.exists()) diff --git a/l10n_it_fatturapa_pec/views/fatturapa_attachment_out.xml b/l10n_it_fatturapa_pec/views/fatturapa_attachment_out.xml index 64d5cef2c9d6..e5e268a4e978 100644 --- a/l10n_it_fatturapa_pec/views/fatturapa_attachment_out.xml +++ b/l10n_it_fatturapa_pec/views/fatturapa_attachment_out.xml @@ -6,12 +6,9 @@ fatturapa.attachment.out - -
    +
    From 3b2af8e6c3f4425be5fb36f94c4aac51ec06743f Mon Sep 17 00:00:00 2001 From: Giovanni Date: Thu, 25 Feb 2021 20:35:00 +0100 Subject: [PATCH 57/65] [12.0][IMP] move all state related code from fatturapa_pec to fatturapa_out --- l10n_it_fatturapa_pec/README.rst | 1 + l10n_it_fatturapa_pec/__manifest__.py | 4 +- l10n_it_fatturapa_pec/i18n/it.po | 178 +++++++----------- .../i18n/l10n_it_fatturapa_pec.pot | 110 +---------- l10n_it_fatturapa_pec/models/__init__.py | 1 - l10n_it_fatturapa_pec/models/account.py | 48 ----- .../models/fatturapa_attachment_out.py | 2 - l10n_it_fatturapa_pec/readme/CONTRIBUTORS.rst | 1 + .../static/description/index.html | 1 + l10n_it_fatturapa_pec/views/account.xml | 55 ------ .../views/fatturapa_attachment_out.xml | 33 ---- l10n_it_fatturapa_pec/wizard/__init__.py | 1 - .../wizard/wizard_export_fatturapa.py | 80 -------- .../wizard/wizard_export_fatturapa_view.xml | 18 -- 14 files changed, 74 insertions(+), 459 deletions(-) delete mode 100644 l10n_it_fatturapa_pec/models/account.py delete mode 100644 l10n_it_fatturapa_pec/views/account.xml delete mode 100644 l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa.py delete mode 100644 l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa_view.xml diff --git a/l10n_it_fatturapa_pec/README.rst b/l10n_it_fatturapa_pec/README.rst index 92aaa39eac71..31bde0297cc2 100644 --- a/l10n_it_fatturapa_pec/README.rst +++ b/l10n_it_fatturapa_pec/README.rst @@ -117,6 +117,7 @@ Contributors * Sergio Corato * Lorenzo Battistini * Sergio Zanchetta +* Giovanni Serra * `Tecnativa `_: diff --git a/l10n_it_fatturapa_pec/__manifest__.py b/l10n_it_fatturapa_pec/__manifest__.py index d642232f786a..d3948f87c06e 100644 --- a/l10n_it_fatturapa_pec/__manifest__.py +++ b/l10n_it_fatturapa_pec/__manifest__.py @@ -8,7 +8,7 @@ { 'name': 'ITA - Fattura elettronica - Supporto PEC', - 'version': '12.0.1.9.1', + 'version': '12.0.1.9.2', 'category': 'Localization/Italy', 'summary': 'Invio fatture elettroniche tramite PEC', 'author': 'Openforce Srls Unipersonale, Odoo Community Association (OCA)', @@ -25,8 +25,6 @@ 'security/groups.xml', 'views/fatturapa_attachment_out.xml', 'wizard/send_pec_view.xml', - 'wizard/wizard_export_fatturapa_view.xml', - 'views/account.xml', 'views/fetchmail_view.xml', 'security/ir.model.access.csv', 'data/fetchmail_data.xml', diff --git a/l10n_it_fatturapa_pec/i18n/it.po b/l10n_it_fatturapa_pec/i18n/it.po index 58f575c7bea0..4cd39281d222 100644 --- a/l10n_it_fatturapa_pec/i18n/it.po +++ b/l10n_it_fatturapa_pec/i18n/it.po @@ -30,11 +30,6 @@ msgstr "" "valori impostati qui sono specifici per azienda.\" aria-label=\"Values set " "here are company-specific.\"/>" -#. module: l10n_it_fatturapa_pec -#: selection:account.invoice,fatturapa_state:0 -msgid "Accepted" -msgstr "Accettato" - #. module: l10n_it_fatturapa_pec #: model:res.groups,name:l10n_it_fatturapa_pec.group_force_e_inv_export_state msgid "Allow to force e-invoice export state" @@ -81,16 +76,10 @@ msgid "Default user used in electronic supplier bills" msgstr "Utente predefinito usato nelle fatture elettroniche fornitore" #. module: l10n_it_fatturapa_pec -#: selection:account.invoice,fatturapa_state:0 #: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_pec_attachment_form msgid "Delivered" msgstr "Consegnato" -#. 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 "Data consegna" - #. 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" @@ -107,41 +96,11 @@ msgstr "Creatore e-fattura" msgid "E-invoice Export File" msgstr "File e-fattura esportato" -#. 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 "Stato e-fattura" - -#. module: l10n_it_fatturapa_pec -#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_account_invoice_fatturapa_out_pec_filter -msgid "Electronic Invoice Error" -msgstr "Errore fattura elettronica" - -#. module: l10n_it_fatturapa_pec -#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_account_invoice_fatturapa_out_pec_filter -msgid "Electronic Invoice Ready to Send" -msgstr "Fattura elettronica pronta per l'invio" - -#. module: l10n_it_fatturapa_pec -#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_account_invoice_fatturapa_out_pec_filter -msgid "Electronic Invoice State" -msgstr "Stato fattura elettronica" - #. module: l10n_it_fatturapa_pec #: model:ir.model,name:l10n_it_fatturapa_pec.model_mail_thread msgid "Email Thread" msgstr "Discussione e-mail" -#. module: l10n_it_fatturapa_pec -#: selection:account.invoice,fatturapa_state:0 -msgid "Error" -msgstr "Errore" - -#. module: l10n_it_fatturapa_pec -#: model:ir.model,name:l10n_it_fatturapa_pec.model_wizard_export_fatturapa -msgid "Export E-invoice" -msgstr "Esporta e-fattura" - #. module: l10n_it_fatturapa_pec #: code:addons/l10n_it_fatturapa_pec/models/fetchmail.py:180 #, python-format @@ -149,7 +108,7 @@ msgid "Fetchmail PEC server [%s] error" msgstr "Errore fetchmail server PEC [%s]" #. module: l10n_it_fatturapa_pec -#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:52 +#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:50 #, python-format msgid "File content and file name are mandatory" msgstr "Il contenuto e il nome del file sono obbligatori" @@ -164,11 +123,6 @@ msgstr "ID" msgid "Incoming Mail Server" msgstr "Server di posta in arrivo" -#. module: l10n_it_fatturapa_pec -#: model:ir.model,name:l10n_it_fatturapa_pec.model_account_invoice -msgid "Invoice" -msgstr "Fattura" - #. 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" @@ -201,16 +155,11 @@ msgid "Last error message" msgstr "Ultimo messaggio di errore" #. module: l10n_it_fatturapa_pec -#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:38 +#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:36 #, python-format msgid "No incoming PEC server found. Please configure it." msgstr "Nessun server PEC in ingresso trovato, configurarne uno." -#. module: l10n_it_fatturapa_pec -#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_attachment_search_state -msgid "Not delivered" -msgstr "Non consegnato" - #. module: l10n_it_fatturapa_pec #: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_fetchmail_server__pec_error_count msgid "PEC error count" @@ -235,32 +184,6 @@ msgid "PEC server %s has been reset.Last error message is '%s'" msgstr "" "Il server PEC %s è stato reimpostato. L'ultimo messaggio di errore è '%s'" -#. module: l10n_it_fatturapa_pec -#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.wizard_export_fatturapa_form_view_regenerate -msgid "Re-Export" -msgstr "Riesporta" - -#. module: l10n_it_fatturapa_pec -#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_invoice_fatturapa_out_pec_form -msgid "Re-Export E-invoice" -msgstr "Riesporta e-fattura" - -#. module: l10n_it_fatturapa_pec -#: model:ir.actions.act_window,name:l10n_it_fatturapa_pec.action_wizard_export_fatturapa_regenerate -msgid "Re-Export Electronic Invoice" -msgstr "Riesporta fattura elettronica" - -#. module: l10n_it_fatturapa_pec -#: selection:account.invoice,fatturapa_state:0 -#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_attachment_search_state -msgid "Ready to Send" -msgstr "Pronto per l'invio" - -#. module: l10n_it_fatturapa_pec -#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_attachment_search_state -msgid "Rejected (PA)" -msgstr "Rifiutato (PA)" - #. module: l10n_it_fatturapa_pec #: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_pec_attachment_form msgid "Reset to ready" @@ -287,47 +210,16 @@ msgstr "Invia fattura elettronica" msgid "Send Via PEC" msgstr "Invia con PEC" -#. module: l10n_it_fatturapa_pec -#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_attachment_search_state -msgid "Sender Error" -msgstr "Errore trasmittente" - #. 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 "Utente trasmittente" -#. module: l10n_it_fatturapa_pec -#: selection:account.invoice,fatturapa_state:0 -msgid "Sent" -msgstr "Inviato" - -#. 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 "Data invio" - #. module: l10n_it_fatturapa_pec #: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_pec_attachment_form msgid "Sent by" msgstr "Inviato da" -#. module: l10n_it_fatturapa_pec -#: code:addons/l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa.py:50 -#, python-format -msgid "" -"The invoice cannot be regenerated because doesn't have a e-invoice " -"attachment associated to it" -msgstr "" -"La fattura non può essere rigenerata, non possiede un allegato e-fattura " -"associato" - -#. module: l10n_it_fatturapa_pec -#: code:addons/l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa.py:40 -#, python-format -msgid "The method can be called with a valid active_id" -msgstr "Il metodo può essere chiamato con un active_id valido" - #. module: l10n_it_fatturapa_pec #: model:ir.model.fields,help:l10n_it_fatturapa_pec.field_res_company__e_invoice_user_id #: model:ir.model.fields,help:l10n_it_fatturapa_pec.field_res_config_settings__e_invoice_user_id @@ -341,7 +233,7 @@ msgid "Wizard to send multiple e-invoice PEC" msgstr "Procedura per inviare PEC e-fattura multiple" #. module: l10n_it_fatturapa_pec -#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:48 +#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:46 #, python-format msgid "You can only send files in 'Ready to Send' state." msgstr "È possibile inviare solo file con stato «Pronto per l'invio»." @@ -351,6 +243,70 @@ msgstr "È possibile inviare solo file con stato «Pronto per l'invio»." msgid "on" msgstr "il" +#~ msgid "Accepted" +#~ msgstr "Accettato" + +#~ msgid "Delivered Date" +#~ msgstr "Data consegna" + +#~ msgid "E-invoice State" +#~ msgstr "Stato e-fattura" + +#~ msgid "Electronic Invoice Error" +#~ msgstr "Errore fattura elettronica" + +#~ msgid "Electronic Invoice Ready to Send" +#~ msgstr "Fattura elettronica pronta per l'invio" + +#~ msgid "Electronic Invoice State" +#~ msgstr "Stato fattura elettronica" + +#~ msgid "Error" +#~ msgstr "Errore" + +#~ msgid "Export E-invoice" +#~ msgstr "Esporta e-fattura" + +#~ msgid "Invoice" +#~ msgstr "Fattura" + +#~ msgid "Not delivered" +#~ msgstr "Non consegnato" + +#~ msgid "Re-Export" +#~ msgstr "Riesporta" + +#~ msgid "Re-Export E-invoice" +#~ msgstr "Riesporta e-fattura" + +#~ msgid "Re-Export Electronic Invoice" +#~ msgstr "Riesporta fattura elettronica" + +#~ msgid "Ready to Send" +#~ msgstr "Pronto per l'invio" + +#~ msgid "Rejected (PA)" +#~ msgstr "Rifiutato (PA)" + +#~ msgid "Sender Error" +#~ msgstr "Errore trasmittente" + +#~ msgid "Sent" +#~ msgstr "Inviato" + +#~ msgid "Sent Date" +#~ msgstr "Data invio" + +#~ msgid "" +#~ "The invoice cannot be regenerated because doesn't have a e-invoice " +#~ "attachment associated to it" +#~ msgstr "" +#~ "La fattura non può essere rigenerata, non possiede un allegato e-fattura " +#~ "associato" + +#~ msgid "The method can be called with a valid active_id" +#~ msgstr "Il metodo può essere chiamato con un active_id valido" + #~ msgid "State" #~ msgstr "Stato" diff --git a/l10n_it_fatturapa_pec/i18n/l10n_it_fatturapa_pec.pot b/l10n_it_fatturapa_pec/i18n/l10n_it_fatturapa_pec.pot index 8255ad84ced9..2044c2140e4b 100644 --- a/l10n_it_fatturapa_pec/i18n/l10n_it_fatturapa_pec.pot +++ b/l10n_it_fatturapa_pec/i18n/l10n_it_fatturapa_pec.pot @@ -19,11 +19,6 @@ msgid "Supplier Bills\n" " " msgstr "" -#. module: l10n_it_fatturapa_pec -#: selection:account.invoice,fatturapa_state:0 -msgid "Accepted" -msgstr "" - #. module: l10n_it_fatturapa_pec #: model:res.groups,name:l10n_it_fatturapa_pec.group_force_e_inv_export_state msgid "Allow to force e-invoice export state" @@ -70,16 +65,10 @@ msgid "Default user used in electronic supplier bills" msgstr "" #. module: l10n_it_fatturapa_pec -#: selection:account.invoice,fatturapa_state:0 #: model_terms: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" @@ -96,41 +85,11 @@ msgstr "" msgid "E-invoice Export File" 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_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_account_invoice_fatturapa_out_pec_filter -msgid "Electronic Invoice Error" -msgstr "" - -#. module: l10n_it_fatturapa_pec -#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_account_invoice_fatturapa_out_pec_filter -msgid "Electronic Invoice Ready to Send" -msgstr "" - -#. module: l10n_it_fatturapa_pec -#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_account_invoice_fatturapa_out_pec_filter -msgid "Electronic 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.model,name:l10n_it_fatturapa_pec.model_wizard_export_fatturapa -msgid "Export E-invoice" -msgstr "" - #. module: l10n_it_fatturapa_pec #: code:addons/l10n_it_fatturapa_pec/models/fetchmail.py:180 #, python-format @@ -138,7 +97,7 @@ msgid "Fetchmail PEC server [%s] error" msgstr "" #. module: l10n_it_fatturapa_pec -#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:52 +#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:50 #, python-format msgid "File content and file name are mandatory" msgstr "" @@ -153,11 +112,6 @@ msgstr "" msgid "Incoming Mail Server" 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" @@ -190,16 +144,11 @@ msgid "Last error message" msgstr "" #. module: l10n_it_fatturapa_pec -#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:38 +#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:36 #, python-format msgid "No incoming PEC server found. Please configure it." msgstr "" -#. module: l10n_it_fatturapa_pec -#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_attachment_search_state -msgid "Not delivered" -msgstr "" - #. module: l10n_it_fatturapa_pec #: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_fetchmail_server__pec_error_count msgid "PEC error count" @@ -218,32 +167,6 @@ msgstr "" msgid "PEC server %s has been reset.Last error message is '%s'" msgstr "" -#. module: l10n_it_fatturapa_pec -#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.wizard_export_fatturapa_form_view_regenerate -msgid "Re-Export" -msgstr "" - -#. module: l10n_it_fatturapa_pec -#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_invoice_fatturapa_out_pec_form -msgid "Re-Export E-invoice" -msgstr "" - -#. module: l10n_it_fatturapa_pec -#: model:ir.actions.act_window,name:l10n_it_fatturapa_pec.action_wizard_export_fatturapa_regenerate -msgid "Re-Export Electronic Invoice" -msgstr "" - -#. module: l10n_it_fatturapa_pec -#: selection:account.invoice,fatturapa_state:0 -#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_attachment_search_state -msgid "Ready to Send" -msgstr "" - -#. module: l10n_it_fatturapa_pec -#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_attachment_search_state -msgid "Rejected (PA)" -msgstr "" - #. module: l10n_it_fatturapa_pec #: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_pec_attachment_form msgid "Reset to ready" @@ -270,43 +193,16 @@ msgstr "" msgid "Send Via PEC" msgstr "" -#. module: l10n_it_fatturapa_pec -#: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_attachment_search_state -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 -msgid "Sent" -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_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_fatturapa_out_pec_attachment_form msgid "Sent by" msgstr "" -#. module: l10n_it_fatturapa_pec -#: code:addons/l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa.py:50 -#, python-format -msgid "The invoice cannot be regenerated because doesn't have a e-invoice attachment associated to it" -msgstr "" - -#. module: l10n_it_fatturapa_pec -#: code:addons/l10n_it_fatturapa_pec/wizard/wizard_export_fatturapa.py:40 -#, python-format -msgid "The method can be called with a valid active_id" -msgstr "" - #. module: l10n_it_fatturapa_pec #: model:ir.model.fields,help:l10n_it_fatturapa_pec.field_res_company__e_invoice_user_id #: model:ir.model.fields,help:l10n_it_fatturapa_pec.field_res_config_settings__e_invoice_user_id @@ -319,7 +215,7 @@ 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:48 +#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:46 #, python-format msgid "You can only send files in 'Ready to Send' state." msgstr "" diff --git a/l10n_it_fatturapa_pec/models/__init__.py b/l10n_it_fatturapa_pec/models/__init__.py index 28ae5d1667e5..98bfb9953ebc 100644 --- a/l10n_it_fatturapa_pec/models/__init__.py +++ b/l10n_it_fatturapa_pec/models/__init__.py @@ -1,5 +1,4 @@ -from . import account from . import fatturapa_attachment_out from . import mail_thread from . import fetchmail diff --git a/l10n_it_fatturapa_pec/models/account.py b/l10n_it_fatturapa_pec/models/account.py deleted file mode 100644 index d3db6a413d5b..000000000000 --- a/l10n_it_fatturapa_pec/models/account.py +++ /dev/null @@ -1,48 +0,0 @@ -# Author(s): Andrea Colangelo (andreacolangelo@openforce.it) -# Copyright © 2018 Openforce Srls Unipersonale (www.openforce.it) -# Copyright 2019 Lorenzo Battistini - - -from odoo import api, fields, models - -fatturapa_attachment_state_mapping = { - 'ready': 'ready', - 'sent': 'sent', - 'validated': 'delivered', - 'sender_error': 'error', - 'recipient_error': 'accepted', - 'accepted': 'accepted', - 'rejected': 'error' -} - - -class AccountInvoice(models.Model): - _inherit = 'account.invoice' - - fatturapa_state = fields.Selection( - [('ready', 'Ready to Send'), - ('sent', 'Sent'), - ('delivered', 'Delivered'), - ('accepted', 'Accepted'), - ('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): - for record in self: - record.fatturapa_state = fatturapa_attachment_state_mapping.get( - record.fatturapa_attachment_out_id.state) - - @api.multi - def action_invoice_cancel(self): - for invoice in self: - if invoice.fatturapa_state == "error": - res = super(AccountInvoice, invoice.with_context( - skip_e_invoice_cancel_check=True)).action_invoice_cancel() - else: - res = super(AccountInvoice, invoice).action_invoice_cancel() - return res diff --git a/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py b/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py index e18979774e6b..0df68417982c 100644 --- a/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py +++ b/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py @@ -24,8 +24,6 @@ class FatturaPAAttachmentOut(models.Model): last_sdi_response = fields.Text( 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.model diff --git a/l10n_it_fatturapa_pec/readme/CONTRIBUTORS.rst b/l10n_it_fatturapa_pec/readme/CONTRIBUTORS.rst index 1df2580dbce1..852bb97ecac4 100644 --- a/l10n_it_fatturapa_pec/readme/CONTRIBUTORS.rst +++ b/l10n_it_fatturapa_pec/readme/CONTRIBUTORS.rst @@ -2,6 +2,7 @@ * Sergio Corato * Lorenzo Battistini * Sergio Zanchetta +* Giovanni Serra * `Tecnativa `_: diff --git a/l10n_it_fatturapa_pec/static/description/index.html b/l10n_it_fatturapa_pec/static/description/index.html index 2efe8eeb991b..0289079b0bad 100644 --- a/l10n_it_fatturapa_pec/static/description/index.html +++ b/l10n_it_fatturapa_pec/static/description/index.html @@ -439,6 +439,7 @@

    Contributors

  • Sergio Corato <info@efatto.it>
  • Lorenzo Battistini <https://github.com/eLBati>
  • Sergio Zanchetta <https://github.com/primes2h>
  • +
  • Giovanni Serra <giovanni@gslab.it>
  • Tecnativa:
    • Víctor Martínez
    diff --git a/l10n_it_fatturapa_pec/views/account.xml b/l10n_it_fatturapa_pec/views/account.xml deleted file mode 100644 index f0f90f3ef8d9..000000000000 --- a/l10n_it_fatturapa_pec/views/account.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - 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 index e5e268a4e978..a1a7f03d8702 100644 --- a/l10n_it_fatturapa_pec/views/fatturapa_attachment_out.xml +++ b/l10n_it_fatturapa_pec/views/fatturapa_attachment_out.xml @@ -15,9 +15,6 @@ - - {'readonly': [('state', 'not in', ['ready', 'sender_error'])]} -
  • - + From 337e25ffeb8b5413c1046c8b14c40574a6544516 Mon Sep 17 00:00:00 2001 From: Borruso Date: Fri, 15 Oct 2021 18:22:09 +0200 Subject: [PATCH 59/65] [MIG] l10n_it_fatturapa_pec: Migration to 14.0 Co-authored-by: SimoRubi Co-authored-by: fredzamoabg --- l10n_it_fatturapa_pec/README.rst | 10 +- l10n_it_fatturapa_pec/__manifest__.py | 4 +- .../i18n/l10n_it_fatturapa_pec.pot | 42 +++- .../models/fatturapa_attachment_out.py | 235 ++++++++++-------- l10n_it_fatturapa_pec/models/fetchmail.py | 163 ++++++------ l10n_it_fatturapa_pec/models/mail_thread.py | 22 +- .../security/ir.model.access.csv | 1 + .../static/description/index.html | 6 +- ...CATA_ Invio File 7339338 (broken XML).txt} | 0 ...POSTA CERTIFICATA_ Invio File 7339338.txt} | 0 .../tests/e_invoice_common.py | 36 ++- .../tests/test_e_invoice_response.py | 28 ++- .../tests/test_e_invoice_send.py | 22 +- .../views/fatturapa_attachment_out.xml | 4 +- l10n_it_fatturapa_pec/wizard/send_pec.py | 3 +- .../wizard/send_pec_view.xml | 23 +- 16 files changed, 342 insertions(+), 257 deletions(-) rename l10n_it_fatturapa_pec/tests/data/{POSTA CERTIFICATA: Invio File 7339338 (broken XML).txt => POSTA CERTIFICATA_ Invio File 7339338 (broken XML).txt} (100%) rename l10n_it_fatturapa_pec/tests/data/{POSTA CERTIFICATA: Invio File 7339338.txt => POSTA CERTIFICATA_ Invio File 7339338.txt} (100%) diff --git a/l10n_it_fatturapa_pec/README.rst b/l10n_it_fatturapa_pec/README.rst index 31bde0297cc2..a2a5e1ffa38e 100644 --- a/l10n_it_fatturapa_pec/README.rst +++ b/l10n_it_fatturapa_pec/README.rst @@ -14,13 +14,13 @@ ITA - Fattura elettronica - Supporto PEC :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github - :target: https://github.com/OCA/l10n-italy/tree/12.0/l10n_it_fatturapa_pec + :target: https://github.com/OCA/l10n-italy/tree/14.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-12-0/l10n-italy-12-0-l10n_it_fatturapa_pec + :target: https://translation.odoo-community.org/projects/l10n-italy-14-0/l10n-italy-14-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/12.0 + :target: https://runbot.odoo-community.org/runbot/122/14.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -98,7 +98,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. @@ -136,6 +136,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/__manifest__.py b/l10n_it_fatturapa_pec/__manifest__.py index 365c2b208bb7..be888f288c59 100644 --- a/l10n_it_fatturapa_pec/__manifest__.py +++ b/l10n_it_fatturapa_pec/__manifest__.py @@ -8,11 +8,11 @@ { "name": "ITA - Fattura elettronica - Supporto PEC", - "version": "12.0.1.9.2", + "version": "14.0.1.0.0", "category": "Localization/Italy", "summary": "Invio fatture elettroniche tramite PEC", "author": "Openforce Srls Unipersonale, Odoo Community Association (OCA)", - "website": "https://github.com/OCA/l10n-italy" "l10n_it_fatturapa_pec", + "website": "https://github.com/OCA/l10n-italy", "license": "AGPL-3", "depends": [ "fetchmail", diff --git a/l10n_it_fatturapa_pec/i18n/l10n_it_fatturapa_pec.pot b/l10n_it_fatturapa_pec/i18n/l10n_it_fatturapa_pec.pot index 2044c2140e4b..7810224eecac 100644 --- a/l10n_it_fatturapa_pec/i18n/l10n_it_fatturapa_pec.pot +++ b/l10n_it_fatturapa_pec/i18n/l10n_it_fatturapa_pec.pot @@ -1,12 +1,12 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * l10n_it_fatturapa_pec +# * l10n_it_fatturapa_pec # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" +"Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" -"Last-Translator: <>\n" +"Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -15,7 +15,8 @@ msgstr "" #. module: l10n_it_fatturapa_pec #: model_terms:ir.ui.view,arch_db:l10n_it_fatturapa_pec.view_account_config_settings_ftpa_pec -msgid "Supplier Bills\n" +msgid "" +"Supplier Bills\n" " " msgstr "" @@ -70,6 +71,11 @@ msgid "Delivered" msgstr "" #. module: l10n_it_fatturapa_pec +#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_fatturapa_attachment_out__display_name +#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_fetchmail_server__display_name +#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_mail_thread__display_name +#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_res_company__display_name +#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_res_config_settings__display_name #: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_wizard_fatturapa_send_pec__display_name msgid "Display Name" msgstr "" @@ -91,18 +97,23 @@ msgid "Email Thread" msgstr "" #. module: l10n_it_fatturapa_pec -#: code:addons/l10n_it_fatturapa_pec/models/fetchmail.py:180 +#: code:addons/l10n_it_fatturapa_pec/models/fetchmail.py:0 #, python-format msgid "Fetchmail PEC server [%s] error" msgstr "" #. module: l10n_it_fatturapa_pec -#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:50 +#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:0 #, python-format msgid "File content and file name are mandatory" msgstr "" #. module: l10n_it_fatturapa_pec +#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_fatturapa_attachment_out__id +#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_fetchmail_server__id +#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_mail_thread__id +#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_res_company__id +#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_res_config_settings__id #: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_wizard_fatturapa_send_pec__id msgid "ID" msgstr "" @@ -113,6 +124,11 @@ msgid "Incoming Mail Server" msgstr "" #. module: l10n_it_fatturapa_pec +#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_fatturapa_attachment_out____last_update +#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_fetchmail_server____last_update +#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_mail_thread____last_update +#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_res_company____last_update +#: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_res_config_settings____last_update #: model:ir.model.fields,field_description:l10n_it_fatturapa_pec.field_wizard_fatturapa_send_pec____last_update msgid "Last Modified on" msgstr "" @@ -144,7 +160,7 @@ msgid "Last error message" msgstr "" #. module: l10n_it_fatturapa_pec -#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:36 +#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:0 #, python-format msgid "No incoming PEC server found. Please configure it." msgstr "" @@ -155,16 +171,17 @@ msgid "PEC error count" msgstr "" #. module: l10n_it_fatturapa_pec -#: code:addons/l10n_it_fatturapa_pec/models/mail_thread.py:68 +#: code:addons/l10n_it_fatturapa_pec/models/mail_thread.py:0 #, python-format -msgid "PEC message \"%s\" has been read but not processed, as not related to an e-invoice.\n" +msgid "" +"PEC message \"%s\" has been read but not processed, as not related to an e-invoice.\n" "Please check PEC mailbox %s, at server %s, with user %s." msgstr "" #. module: l10n_it_fatturapa_pec -#: code:addons/l10n_it_fatturapa_pec/models/fetchmail.py:161 +#: code:addons/l10n_it_fatturapa_pec/models/fetchmail.py:0 #, python-format -msgid "PEC server %s has been reset.Last error message is '%s'" +msgid "PEC server %s has been reset. Last error message is '%s'" msgstr "" #. module: l10n_it_fatturapa_pec @@ -215,7 +232,7 @@ 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:46 +#: code:addons/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py:0 #, python-format msgid "You can only send files in 'Ready to Send' state." msgstr "" @@ -224,4 +241,3 @@ msgstr "" #: model_terms: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/fatturapa_attachment_out.py b/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py index cced3ad78eaa..9e790f3c8e25 100644 --- a/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py +++ b/l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py @@ -38,15 +38,14 @@ def _check_fetchmail(self): if not server: raise UserError(_("No incoming PEC server found. Please configure it.")) - @api.multi def send_via_pec(self): self._check_fetchmail() - self.env.user.company_id.sdi_channel_id.check_first_pec_sending() + self.env.company.sdi_channel_id.check_first_pec_sending() states = self.mapped("state") if set(states) != {"ready"}: raise UserError(_("You can only send files in 'Ready to Send' state.")) for att in self: - if not att.datas or not att.datas_fname: + if not att.datas or not att.name: raise UserError(_("File content and file name are mandatory")) mail_message = self.env["mail.message"].create( { @@ -55,12 +54,12 @@ def send_via_pec(self): "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 + att.name, self.env.company.email_exchange_system ), "attachment_ids": [(6, 0, att.ir_attachment_id.ids)], - "email_from": (self.env.user.company_id.email_from_for_fatturaPA), - "reply_to": (self.env.user.company_id.email_from_for_fatturaPA), - "mail_server_id": self.env.user.company_id.sdi_channel_id.pec_server_id.id, + "email_from": self.env.company.email_from_for_fatturaPA, + "reply_to": self.env.company.email_from_for_fatturaPA, + "mail_server_id": self.env.company.sdi_channel_id.pec_server_id.id, } ) @@ -68,9 +67,9 @@ def send_via_pec(self): { "mail_message_id": mail_message.id, "body_html": mail_message.body, - "email_to": self.env.user.company_id.email_exchange_system, + "email_to": self.env.company.email_exchange_system, "headers": { - "Return-Path": self.env.user.company_id.email_from_for_fatturaPA + "Return-Path": self.env.company.email_from_for_fatturaPA }, } ) @@ -81,12 +80,116 @@ def send_via_pec(self): att.state = "sent" att.sending_date = fields.Datetime.now() att.sending_user = self.env.user.id - self.env.user.company_id.sdi_channel_id.update_after_first_pec_sending() + self.env.company.sdi_channel_id.update_after_first_pec_sending() except MailDeliveryException as e: att.state = "sender_error" mail.body = str(e) - @api.multi + def _message_type_ns( + self, root, id_sdi, message_id, receipt_dt, fatturapa_attachment_out + ): + 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_str), + } + ) + + def _message_type_mc( + self, root, id_sdi, message_id, receipt_dt, fatturapa_attachment_out + ): + 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 + ), + } + ) + + def _message_type_rc( + self, root, id_sdi, message_id, receipt_dt, fatturapa_attachment_out + ): + 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(id_sdi, message_id, receipt_dt, delivery_dt), + } + ) + + def _message_type_ne(self, root, id_sdi, message_id, fatturapa_attachment_out): + esito_committente = root.find("EsitoCommittente") + if esito_committente is not None: + # more than one esito? + esito = esito_committente.find("Esito") + state = "" + if esito is not None: + if esito.text == "EC01": + state = "accepted" + 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 + ), + } + ) + + def _message_type_dt( + self, root, id_sdi, message_id, receipt_dt, fatturapa_attachment_out + ): + 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 + ), + } + ) + + def _message_type_at( + self, root, id_sdi, message_id, receipt_dt, fatturapa_attachment_out + ): + description = root.find("Descrizione") + if description is not None: + fatturapa_attachment_out.write( + { + "state": "accepted", + "last_sdi_response": ( + "SdI ID: {}; Message ID: {}; Receipt date: {};" + " Description: {}" + ).format(id_sdi, message_id, receipt_dt, description.text), + } + ) + def parse_pec_response(self, message_dict): message_dict["model"] = self._name message_dict["res_id"] = 0 @@ -102,19 +205,19 @@ def parse_pec_response(self, message_dict): continue root = etree.fromstring(attachment.content) file_name = root.find("NomeFile") - fatturapa_attachment_out = False + fatturapa_attachment_out = self.env["fatturapa.attachment.out"] 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", "")), + ("name", "=", file_name), + ("name", "=", file_name.replace(".p7m", "")), ] ) if len(fatturapa_attachment_out) > 1: - _logger.info("More than 1 out invoice found for incoming" "message") + _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 @@ -133,102 +236,30 @@ def parse_pec_response(self, message_dict): 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") - 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_str - ), - } + self._message_type_ns( + root, id_sdi, message_id, receipt_dt, fatturapa_attachment_out ) 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 - ), - } + self._message_type_mc( + root, id_sdi, message_id, receipt_dt, fatturapa_attachment_out ) elif message_type == "RC": # 3B. Ricevuta di Consegna - 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( - id_sdi, message_id, receipt_dt, delivery_dt - ), - } + self._message_type_rc( + root, id_sdi, message_id, receipt_dt, fatturapa_attachment_out ) elif message_type == "NE": # 4A. Notifica Esito per PA - esito_committente = root.find("EsitoCommittente") - if esito_committente is not None: - # more than one esito? - esito = esito_committente.find("Esito") - if esito is not None: - if esito.text == "EC01": - state = "accepted" - 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 - ), - } - ) + self._message_type_ne( + root, id_sdi, message_id, fatturapa_attachment_out + ) 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 - ), - } - ) + self._message_type_dt( + root, id_sdi, message_id, receipt_dt, fatturapa_attachment_out + ) # 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": "accepted", - "last_sdi_response": ( - "SdI ID: {}; Message ID: {}; Receipt date: {};" - " Description: {}" - ).format( - id_sdi, message_id, receipt_dt, description.text - ), - } - ) + self._message_type_at( + root, id_sdi, message_id, receipt_dt, fatturapa_attachment_out + ) message_dict["res_id"] = fatturapa_attachment_out.id return message_dict diff --git a/l10n_it_fatturapa_pec/models/fetchmail.py b/l10n_it_fatturapa_pec/models/fetchmail.py index 2beeff962654..3859a397183b 100644 --- a/l10n_it_fatturapa_pec/models/fetchmail.py +++ b/l10n_it_fatturapa_pec/models/fetchmail.py @@ -2,7 +2,7 @@ import logging -from odoo import _, api, fields, models +from odoo import _, fields, models _logger = logging.getLogger(__name__) MAX_POP_MESSAGES = 50 @@ -24,7 +24,77 @@ def _default_e_inv_notify_partner_ids(self): default=_default_e_inv_notify_partner_ids, ) - @api.multi + def fetch_mail_server_type_imap( + self, server, MailThread, error_messages, **additional_context + ): + imap_server = None + try: + imap_server = server.connect() + imap_server.select() + result, data = imap_server.search(None, "(UNSEEN)") + for num in data[0].split(): + result, data = imap_server.fetch(num, "(RFC822)") + imap_server.store(num, "-FLAGS", "\\Seen") + try: + MailThread.with_context(**additional_context).message_process( + server.object_id.model, + data[0][1], + save_original=server.original, + strip_attachments=(not server.attach), + ) + # if message is processed without exceptions + server.last_pec_error_message = "" + except Exception as e: + server.manage_pec_failure(e, error_messages) + continue + imap_server.store(num, "+FLAGS", "\\Seen") + # We need to commit because message is processed: + # Possible next exceptions, out of try, should not + # rollback processed messages + self._cr.commit() # pylint: disable=invalid-commit + except Exception as e: + server.manage_pec_failure(e, error_messages) + finally: + if imap_server: + imap_server.close() + imap_server.logout() + + def fetch_mail_server_type_pop( + self, server, MailThread, error_messages, **additional_context + ): + pop_server = None + try: + while True: + pop_server = server.connect() + (num_messages, total_size) = pop_server.stat() + pop_server.list() + for num in range(1, min(MAX_POP_MESSAGES, num_messages) + 1): + (header, messages, octets) = pop_server.retr(num) + message = "\n".join(messages) + try: + MailThread.with_context(**additional_context).message_process( + server.object_id.model, + message, + save_original=server.original, + strip_attachments=(not server.attach), + ) + pop_server.dele(num) + # See the comments in the IMAP part + server.last_pec_error_message = "" + except Exception as e: + server.manage_pec_failure(e, error_messages) + continue + # pylint: disable=invalid-commit + self._cr.commit() + if num_messages < MAX_POP_MESSAGES: + break + pop_server.quit() + except Exception as e: + server.manage_pec_failure(e, error_messages) + finally: + if pop_server: + pop_server.quit() + def fetch_mail(self): for server in self: if not server.is_fatturapa_pec: @@ -39,83 +109,20 @@ def fetch_mail(self): MailThread = self.env["mail.thread"] _logger.info( "start checking for new e-invoices on %s server %s", - server.type, + server.server_type, server.name, ) additional_context["fetchmail_server_id"] = server.id - additional_context["server_type"] = server.type - imap_server = None - pop_server = None + additional_context["server_type"] = server.server_type error_messages = list() - if server.type == "imap": - try: - imap_server = server.connect() - imap_server.select() - result, data = imap_server.search(None, "(UNSEEN)") - for num in data[0].split(): - result, data = imap_server.fetch(num, "(RFC822)") - imap_server.store(num, "-FLAGS", "\\Seen") - try: - MailThread.with_context( - **additional_context - ).message_process( - server.object_id.model, - data[0][1], - save_original=server.original, - strip_attachments=(not server.attach), - ) - # if message is processed without exceptions - server.last_pec_error_message = "" - except Exception as e: - server.manage_pec_failure(e, error_messages) - continue - imap_server.store(num, "+FLAGS", "\\Seen") - # We need to commit because message is processed: - # Possible next exceptions, out of try, should not - # rollback processed messages - self._cr.commit() # pylint: disable=invalid-commit - except Exception as e: - server.manage_pec_failure(e, error_messages) - finally: - if imap_server: - imap_server.close() - imap_server.logout() - elif server.type == "pop": - try: - while True: - pop_server = server.connect() - (num_messages, total_size) = pop_server.stat() - pop_server.list() - for num in range( - 1, min(MAX_POP_MESSAGES, num_messages) + 1 - ): - (header, messages, octets) = pop_server.retr(num) - message = "\n".join(messages) - try: - MailThread.with_context( - **additional_context - ).message_process( - server.object_id.model, - message, - save_original=server.original, - strip_attachments=(not server.attach), - ) - pop_server.dele(num) - # See the comments in the IMAP part - server.last_pec_error_message = "" - except Exception as e: - server.manage_pec_failure(e, error_messages) - continue - # pylint: disable=invalid-commit - self._cr.commit() - if num_messages < MAX_POP_MESSAGES: - break - pop_server.quit() - except Exception as e: - server.manage_pec_failure(e, error_messages) - finally: - if pop_server: - pop_server.quit() + if server.server_type == "imap": + server.fetch_mail_server_type_imap( + server, MailThread, error_messages, **additional_context + ) + elif server.server_type == "pop": + server.fetch_mail_server_type_pop( + server, MailThread, error_messages, **additional_context + ) if error_messages: server.notify_or_log(error_messages) server.pec_error_count += 1 @@ -135,13 +142,12 @@ def fetch_mail(self): server.write({"date": fields.Datetime.now()}) return True - @api.multi def manage_pec_failure(self, exception, error_messages): self.ensure_one() _logger.info( "Failure when fetching emails " "using {serv_type} server {serv_name}.".format( - serv_type=self.type, serv_name=self.name + serv_type=self.server_type, serv_name=self.name ), exc_info=True, ) @@ -160,11 +166,10 @@ def manage_pec_failure(self, exception, error_messages): def notify_about_server_reset(self): self.ensure_one() self.notify_or_log( - _("PEC server %s has been reset." "Last error message is '%s'") + _("PEC server %s has been reset. Last error message is '%s'") % (self.name, self.last_pec_error_message) ) - @api.multi def notify_or_log(self, message): """ Send an email to partners in diff --git a/l10n_it_fatturapa_pec/models/mail_thread.py b/l10n_it_fatturapa_pec/models/mail_thread.py index 3fa3f7d62e17..b033d9075d9e 100644 --- a/l10n_it_fatturapa_pec/models/mail_thread.py +++ b/l10n_it_fatturapa_pec/models/mail_thread.py @@ -40,6 +40,13 @@ def clean_message_dict(self, message_dict): del message_dict["cc"] del message_dict["from"] del message_dict["to"] + del message_dict["recipients"] + del message_dict["references"] + del message_dict["in_reply_to"] + del message_dict["bounced_email"] + del message_dict["bounced_partner"] + del message_dict["bounced_msg_id"] + del message_dict["bounced_message"] @api.model def message_route( @@ -121,7 +128,7 @@ def manage_pec_sdi_notification(self, message, message_dict): message_dict["record_name"] = message_dict["subject"] attachment_ids = self._message_post_process_attachments( message_dict["attachments"], [], message_dict - ) + ).get("attachment_ids") message_dict["attachment_ids"] = attachment_ids self.clean_message_dict(message_dict) # message_create_from_mail_mail to avoid to notify message @@ -145,7 +152,7 @@ def manage_pec_fe_attachments(self, message, message_dict, response_attachments) message_dict["res_id"] = 0 attachment_ids = self._message_post_process_attachments( message_dict["attachments"], [], message_dict - ) + ).get("attachment_ids") for attachment in self.env["ir.attachment"].browse( [att_id for m, att_id in attachment_ids] ): @@ -174,7 +181,7 @@ def find_attachment_by_subject(self, subject): if "CONSEGNA: " in subject: att_name = subject.replace("CONSEGNA: ", "") fatturapa_attachment_out = attachment_out_model.search( - [("datas_fname", "=", att_name)] + [("name", "=", att_name)] ) if not fatturapa_attachment_out: fatturapa_attachment_out = attachment_out_model.search( @@ -185,7 +192,7 @@ def find_attachment_by_subject(self, subject): if "ACCETTAZIONE: " in subject: att_name = subject.replace("ACCETTAZIONE: ", "") fatturapa_attachment_out = attachment_out_model.search( - [("datas_fname", "=", att_name)] + [("name", "=", att_name)] ) if not fatturapa_attachment_out: fatturapa_attachment_out = attachment_out_model.search( @@ -219,7 +226,9 @@ def create_fatturapa_attachment_in(self, attachment, message_dict=None): company_id = sdi_chan.company_id.id e_invoice_user_id = sdi_chan.company_id.e_invoice_user_id.id if e_invoice_user_id: - fatturapa_attachment_in = fatturapa_attachment_in.sudo(e_invoice_user_id) + fatturapa_attachment_in = fatturapa_attachment_in.with_user( + e_invoice_user_id + ) if attachment.mimetype == "application/zip": with zipfile.ZipFile(io.BytesIO(decoded)) as zf: for file_name in zf.namelist(): @@ -239,8 +248,7 @@ def create_fatturapa_attachment_in(self, attachment, message_dict=None): fatturapa_attachment_in.create( { "name": file_name, - "datas_fname": file_name, - "datas": base64.encodestring(inv_file.read()), + "datas": base64.encodebytes(inv_file.read()), "company_id": company_id, "e_invoice_received_date": received_date, } diff --git a/l10n_it_fatturapa_pec/security/ir.model.access.csv b/l10n_it_fatturapa_pec/security/ir.model.access.csv index 75c27d7b1b0b..f97c9805957e 100644 --- a/l10n_it_fatturapa_pec/security/ir.model.access.csv +++ b/l10n_it_fatturapa_pec/security/ir.model.access.csv @@ -1,2 +1,3 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_fetchmail_server_invoice,fetchmail_server_invoice,model_fetchmail_server,account.group_account_invoice,1,0,0,0 +access_wizard_fatturapa_send_pec,wizard_fatturapa_send_pec,model_wizard_fatturapa_send_pec,,1,1,1,1 diff --git a/l10n_it_fatturapa_pec/static/description/index.html b/l10n_it_fatturapa_pec/static/description/index.html index 0289079b0bad..b74a5903ca5a 100644 --- a/l10n_it_fatturapa_pec/static/description/index.html +++ b/l10n_it_fatturapa_pec/static/description/index.html @@ -367,7 +367,7 @@

    ITA - Fattura elettronica - Supporto PEC

    !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

    Beta License: AGPL-3 OCA/l10n-italy Translate me on Weblate Try me on Runbot

    +

    Beta License: AGPL-3 OCA/l10n-italy Translate me on Weblate Try me on Runbot

    Italiano

    Questo modulo consente di inviare e ricevere i file XML della fattura elettronica versione 1.2

    http://www.fatturapa.gov.it/export/fatturazione/en/sdi.htm

    @@ -421,7 +421,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.

    @@ -453,7 +453,7 @@

    Maintainers

    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/tests/data/POSTA CERTIFICATA: Invio File 7339338 (broken XML).txt b/l10n_it_fatturapa_pec/tests/data/POSTA CERTIFICATA_ Invio File 7339338 (broken XML).txt similarity index 100% rename from l10n_it_fatturapa_pec/tests/data/POSTA CERTIFICATA: Invio File 7339338 (broken XML).txt rename to l10n_it_fatturapa_pec/tests/data/POSTA CERTIFICATA_ Invio File 7339338 (broken XML).txt diff --git a/l10n_it_fatturapa_pec/tests/data/POSTA CERTIFICATA: Invio File 7339338.txt b/l10n_it_fatturapa_pec/tests/data/POSTA CERTIFICATA_ Invio File 7339338.txt similarity index 100% rename from l10n_it_fatturapa_pec/tests/data/POSTA CERTIFICATA: Invio File 7339338.txt rename to l10n_it_fatturapa_pec/tests/data/POSTA CERTIFICATA_ Invio File 7339338.txt diff --git a/l10n_it_fatturapa_pec/tests/e_invoice_common.py b/l10n_it_fatturapa_pec/tests/e_invoice_common.py index e112edd5102a..b8c62f7f9dd1 100644 --- a/l10n_it_fatturapa_pec/tests/e_invoice_common.py +++ b/l10n_it_fatturapa_pec/tests/e_invoice_common.py @@ -8,8 +8,22 @@ class EInvoiceCommon(FatturaPACommon): def setUp(self): super(EInvoiceCommon, self).setUp() self.account_model = self.env["account.account"] - self.invoice_model = self.env["account.invoice"] + self.invoice_model = self.env["account.move"] self.wizard_model = self.env["wizard.export.fatturapa"] + self.tax_model = self.env["account.tax"] + + self.env.company.vat = "IT06363391001" + self.env.company.fatturapa_art73 = True + self.env.company.partner_id.street = "Via Milano, 1" + self.env.company.partner_id.city = "Roma" + self.env.company.partner_id.state_id = self.env.ref("base.state_us_2").id + self.env.company.partner_id.zip = "00100" + self.env.company.partner_id.phone = "06543534343" + self.env.company.email = "info@yourcompany.example.com" + self.env.company.partner_id.country_id = self.env.ref("base.it").id + self.env.company.fatturapa_fiscal_position_id = self.env.ref( + "l10n_it_fatturapa.fatturapa_RF01" + ).id self.account_receivable_id = self.account_model.create( dict( @@ -29,10 +43,10 @@ def setUp(self): ) self.partner = self.env.ref("l10n_it_fatturapa.res_partner_fatturapa_2") self.product = self.env.ref("product.product_product_5") - self.env.user.company_id.sdi_channel_id = self.env.ref( + self.env.company.sdi_channel_id = self.env.ref( "l10n_it_sdi_channel.sdi_channel_pec" ) - self.env.user.company_id.sdi_channel_id.pec_server_id = self.env[ + self.env.company.sdi_channel_id.pec_server_id = self.env[ "ir.mail_server" ].create( { @@ -43,20 +57,28 @@ def setUp(self): ) def _create_invoice(self): + tax = self.tax_model.create( + { + "name": "Tax 22.0%", + "amount": 22, + "amount_type": "percent", + "type_tax_use": "sale", + } + ) invoice_line_data = { "product_id": self.product.id, "quantity": 1, "price_unit": 1, "account_id": self.account_income_id.id, "name": self.product.name, - "invoice_line_tax_ids": [(6, 0, [self.ref("l10n_it_fatturapa.tax_22")])], + "tax_ids": [(6, 0, [tax.id])], } return self.invoice_model.create( dict( name="Test Invoice", - account_id=self.account_receivable_id.id, invoice_line_ids=[(0, 0, invoice_line_data)], partner_id=self.partner.id, + move_type="out_invoice", ) ) @@ -66,7 +88,7 @@ def _get_export_wizard(self, invoice): def _create_e_invoice(self): invoice = self._create_invoice() - invoice.action_invoice_open() + invoice.action_post() wizard = self._get_export_wizard(invoice) action = wizard.exportFatturaPA() @@ -77,7 +99,7 @@ def _create_fetchmail_pec_server(self): return self.env["fetchmail.server"].create( { "name": "Test PEC server", - "type": "pop", + "server_type": "pop", "is_fatturapa_pec": True, "server": "dummy", "port": 110, diff --git a/l10n_it_fatturapa_pec/tests/test_e_invoice_response.py b/l10n_it_fatturapa_pec/tests/test_e_invoice_response.py index 236f1b66e844..2c0f713385d5 100644 --- a/l10n_it_fatturapa_pec/tests/test_e_invoice_response.py +++ b/l10n_it_fatturapa_pec/tests/test_e_invoice_response.py @@ -1,10 +1,12 @@ # Copyright 2018 Simone Rubino - Agile Business Group # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +import email + import mock from odoo.fields import Datetime from odoo.modules import get_module_resource -from odoo.tools import mute_logger +from odoo.tools import mute_logger, pycompat from .e_invoice_common import EInvoiceCommon @@ -13,7 +15,7 @@ class TestEInvoiceResponse(EInvoiceCommon): def setUp(self): super(TestEInvoiceResponse, self).setUp() self.PEC_server = self._create_fetchmail_pec_server() - self.env.user.company_id.vat = "IT03339130126" + self.env.company.vat = "IT03339130126" self.set_sequences(15, "2018-01-07") self.attach_in_model = self.env["fatturapa.attachment.in"] @@ -91,11 +93,13 @@ def test_process_response_ACCETTAZIONE(self): def test_process_response_INVIO(self): """Receiving a 'Invio File' creates a new e-invoice""" - incoming_mail = self._get_file("POSTA CERTIFICATA: Invio File 7339338.txt") + incoming_mail = self._get_file("POSTA CERTIFICATA_ Invio File 7339338.txt") e_invoices = self.attach_in_model.search([]) - msg_dict = self.env["mail.thread"].message_parse(message=incoming_mail) + msg_dict = self.env["mail.thread"].message_parse( + self.from_string(incoming_mail) + ) self.env["mail.thread"].with_context( fetchmail_server_id=self.PEC_server.id @@ -114,11 +118,15 @@ def test_process_response_INVIO_broken_XML(self): """Receiving a 'Invio File' with a broken XML sends an email to e_inv_notify_partner_ids""" incoming_mail = self._get_file( - "POSTA CERTIFICATA: Invio File 7339338 (broken XML).txt" + "POSTA CERTIFICATA_ Invio File 7339338 (broken XML).txt" + ) + xml_error = ( + "Namespace prefix ns1 on Fattura is not defined, " + "line 1, column 13 (, line 1)" ) outbound_mail_model = self.env["mail.mail"] error_mail_domain = [ - ("body_html", "like", "unbound_prefix"), + ("body_html", "like", xml_error), ("recipient_ids", "in", self.PEC_server.e_inv_notify_partner_ids.ids), ] error_mails_nbr = outbound_mail_model.search_count(error_mail_domain) @@ -134,14 +142,13 @@ def test_process_response_INVIO_broken_XML(self): error_mails = outbound_mail_model.search(error_mail_domain) self.assertEqual(len(error_mails), 1) - xml_error = "unbound prefix" self.assertIn(xml_error, error_mails.body_html) self.assertIn(xml_error, self.PEC_server.last_pec_error_message) def test_process_response_MC(self): """Receiving a 'Mancata consegna' sets the state of the e-invoice to 'recipient_error'""" - self.env.user.company_id.vat = "IT14627831002" + self.env.company.vat = "IT14627831002" self.set_sequences(2621, "2019-01-08") e_invoice = self._create_e_invoice() self.set_e_invoice_file_id(e_invoice, "IT14627831002_02621.xml") @@ -153,3 +160,8 @@ def test_process_response_MC(self): fetchmail_server_id=self.PEC_server.id ).message_process(False, incoming_mail) self.assertEqual(e_invoice.state, "recipient_error") + + def from_string(self, text): + return email.message_from_string( + pycompat.to_text(text), policy=email.policy.SMTP + ) diff --git a/l10n_it_fatturapa_pec/tests/test_e_invoice_send.py b/l10n_it_fatturapa_pec/tests/test_e_invoice_send.py index e071338c1a0e..c2c917942f86 100644 --- a/l10n_it_fatturapa_pec/tests/test_e_invoice_send.py +++ b/l10n_it_fatturapa_pec/tests/test_e_invoice_send.py @@ -27,9 +27,7 @@ def test_sender_error(self): e_invoice = self._create_e_invoice() self._create_fetchmail_pec_server() - self.env.user.company_id.sdi_channel_id.pec_server_id.email_from_for_fatturaPA = ( - False - ) + self.env.company.sdi_channel_id.pec_server_id.email_from_for_fatturaPA = False e_invoice.send_via_pec() self.assertEqual(e_invoice.state, "sender_error") @@ -79,7 +77,7 @@ def test_resend_reset(self): def test_resend_after_regenerate(self): """Re-sending e-invoice raises UserError""" invoice = self._create_invoice() - invoice.action_invoice_open() + invoice.action_post() wizard = self._get_export_wizard(invoice) action = wizard.exportFatturaPA() @@ -95,26 +93,16 @@ def test_resend_after_regenerate(self): wizard.with_context(active_id=invoice.id).exportFatturaPARegenerate() self.assertEqual(e_invoice.state, "ready") - with self.assertRaises(UserError): - invoice.action_invoice_cancel() - e_invoice.state = "sender_error" - invoice.journal_id.update_posted = True - invoice.action_invoice_cancel() - invoice.refresh() - invoice.action_invoice_draft() - invoice.refresh() - invoice.action_invoice_open() - invoice.refresh() + invoice.button_draft() + invoice.action_post() action = wizard.with_context(active_id=invoice.id).exportFatturaPARegenerate() e_invoice = self.env[action["res_model"]].browse(action["res_id"]) # set SDI address after first sending - self.env.user.company_id.sdi_channel_id.email_exchange_system = ( - "sdi01@pec.fatturapa.it" - ) + self.env.company.sdi_channel_id.email_exchange_system = "sdi01@pec.fatturapa.it" # Send it again e_invoice.send_via_pec() self.assertEqual(e_invoice.state, "sent") diff --git a/l10n_it_fatturapa_pec/views/fatturapa_attachment_out.xml b/l10n_it_fatturapa_pec/views/fatturapa_attachment_out.xml index 99df58f78b40..f91870502418 100644 --- a/l10n_it_fatturapa_pec/views/fatturapa_attachment_out.xml +++ b/l10n_it_fatturapa_pec/views/fatturapa_attachment_out.xml @@ -10,14 +10,14 @@ /> -