Browse Source
Merge pull request #1214 from Eficent/10.0-mig-mail_log_messages_to_process
Merge pull request #1214 from Eficent/10.0-mig-mail_log_messages_to_process
[10.0][MIG] mail_log_messages_to_processpull/1215/merge
Jordi Ballester Alomar
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 372 additions and 0 deletions
-
51mail_log_message_to_process/README.rst
-
4mail_log_message_to_process/__init__.py
-
16mail_log_message_to_process/__manifest__.py
-
24mail_log_message_to_process/i18n/ca.po
-
24mail_log_message_to_process/i18n/de.po
-
24mail_log_message_to_process/i18n/es.po
-
24mail_log_message_to_process/i18n/fr.po
-
24mail_log_message_to_process/i18n/it.po
-
24mail_log_message_to_process/i18n/pt_BR.po
-
24mail_log_message_to_process/i18n/pt_PT.po
-
24mail_log_message_to_process/i18n/sl.po
-
24mail_log_message_to_process/i18n/tr.po
-
4mail_log_message_to_process/models/__init__.py
-
81mail_log_message_to_process/models/mail_thread.py
-
BINmail_log_message_to_process/static/description/icon.png
@ -0,0 +1,51 @@ |
|||||
|
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg |
||||
|
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html |
||||
|
:alt: License: AGPL-3 |
||||
|
|
||||
|
=========================== |
||||
|
Mail log message to process |
||||
|
=========================== |
||||
|
|
||||
|
This module allows to log into the server the basic information of emails |
||||
|
that have been fetched from the mail server, before they start to be processed. |
||||
|
|
||||
|
This allows for a better analysis of situations where emails are found to be |
||||
|
missing in Odoo. Can help to better resolve questions of the type 'Was it that |
||||
|
the email was never fetched, or a problem found when it was processed by |
||||
|
Odoo?'. |
||||
|
|
||||
|
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas |
||||
|
:alt: Try me on Runbot |
||||
|
:target: https://runbot.odoo-community.org/runbot/149/10.0 |
||||
|
|
||||
|
Bug Tracker |
||||
|
=========== |
||||
|
|
||||
|
Bugs are tracked on `GitHub Issues |
||||
|
<https://github.com/OCA/server-tools/issues>`_. In case of trouble, please |
||||
|
check there if your issue has already been reported. If you spotted it first, |
||||
|
help us smash it by providing detailed and welcomed feedback. |
||||
|
|
||||
|
|
||||
|
Credits |
||||
|
======= |
||||
|
|
||||
|
Contributors |
||||
|
------------ |
||||
|
|
||||
|
* Jordi Ballester <jordi.ballester@eficent.com> |
||||
|
|
||||
|
Maintainer |
||||
|
---------- |
||||
|
|
||||
|
.. image:: https://odoo-community.org/logo.png |
||||
|
:alt: Odoo Community Association |
||||
|
:target: https://odoo-community.org |
||||
|
|
||||
|
This module is maintained by the OCA. |
||||
|
|
||||
|
OCA, or the Odoo Community Association, is a nonprofit organization whose |
||||
|
mission is to support the collaborative development of Odoo features and |
||||
|
promote its widespread use. |
||||
|
|
||||
|
To contribute to this module, please visit https://odoo-community.org. |
@ -0,0 +1,4 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
from . import models |
@ -0,0 +1,16 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © 2017 Eficent Business and IT Consulting Services S.L. (www.eficent.com) |
||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
{ |
||||
|
'name': 'Mail Log Message to Process', |
||||
|
'version': '10.0.1.0.0', |
||||
|
'category': 'Tools', |
||||
|
'summary': 'Log all messages received, before they start to be processed.', |
||||
|
'author': "Eficent, " |
||||
|
"Odoo Community Association (OCA)", |
||||
|
'license': 'AGPL-3', |
||||
|
'website': 'https://github.com/OCA/server-tools', |
||||
|
'depends': ['mail'], |
||||
|
'installable': True, |
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
# Translation of Odoo Server. |
||||
|
# This file contains the translation of the following modules: |
||||
|
# * mail_log_messages_to_process |
||||
|
# |
||||
|
# Translators: |
||||
|
# Marc Tormo i Bochaca <mtbochaca@gmail.com>, 2017 |
||||
|
msgid "" |
||||
|
msgstr "" |
||||
|
"Project-Id-Version: Odoo Server 9.0c\n" |
||||
|
"Report-Msgid-Bugs-To: \n" |
||||
|
"POT-Creation-Date: 2017-10-21 22:54+0000\n" |
||||
|
"PO-Revision-Date: 2017-10-21 22:54+0000\n" |
||||
|
"Last-Translator: Marc Tormo i Bochaca <mtbochaca@gmail.com>, 2017\n" |
||||
|
"Language-Team: Catalan (https://www.transifex.com/oca/teams/23907/ca/)\n" |
||||
|
"MIME-Version: 1.0\n" |
||||
|
"Content-Type: text/plain; charset=UTF-8\n" |
||||
|
"Content-Transfer-Encoding: \n" |
||||
|
"Language: ca\n" |
||||
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n" |
||||
|
|
||||
|
#. module: mail_log_messages_to_process |
||||
|
#: model:ir.model,name:mail_log_messages_to_process.model_mail_thread |
||||
|
msgid "Email Thread" |
||||
|
msgstr "Tema del Correu electrònic " |
@ -0,0 +1,24 @@ |
|||||
|
# Translation of Odoo Server. |
||||
|
# This file contains the translation of the following modules: |
||||
|
# * mail_log_messages_to_process |
||||
|
# |
||||
|
# Translators: |
||||
|
# OCA Transbot <transbot@odoo-community.org>, 2017 |
||||
|
msgid "" |
||||
|
msgstr "" |
||||
|
"Project-Id-Version: Odoo Server 9.0c\n" |
||||
|
"Report-Msgid-Bugs-To: \n" |
||||
|
"POT-Creation-Date: 2017-10-21 22:54+0000\n" |
||||
|
"PO-Revision-Date: 2017-10-21 22:54+0000\n" |
||||
|
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n" |
||||
|
"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n" |
||||
|
"MIME-Version: 1.0\n" |
||||
|
"Content-Type: text/plain; charset=UTF-8\n" |
||||
|
"Content-Transfer-Encoding: \n" |
||||
|
"Language: de\n" |
||||
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n" |
||||
|
|
||||
|
#. module: mail_log_messages_to_process |
||||
|
#: model:ir.model,name:mail_log_messages_to_process.model_mail_thread |
||||
|
msgid "Email Thread" |
||||
|
msgstr "Email-Thread" |
@ -0,0 +1,24 @@ |
|||||
|
# Translation of Odoo Server. |
||||
|
# This file contains the translation of the following modules: |
||||
|
# * mail_log_messages_to_process |
||||
|
# |
||||
|
# Translators: |
||||
|
# OCA Transbot <transbot@odoo-community.org>, 2017 |
||||
|
msgid "" |
||||
|
msgstr "" |
||||
|
"Project-Id-Version: Odoo Server 9.0c\n" |
||||
|
"Report-Msgid-Bugs-To: \n" |
||||
|
"POT-Creation-Date: 2017-10-21 22:54+0000\n" |
||||
|
"PO-Revision-Date: 2017-10-21 22:54+0000\n" |
||||
|
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n" |
||||
|
"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" |
||||
|
"MIME-Version: 1.0\n" |
||||
|
"Content-Type: text/plain; charset=UTF-8\n" |
||||
|
"Content-Transfer-Encoding: \n" |
||||
|
"Language: es\n" |
||||
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n" |
||||
|
|
||||
|
#. module: mail_log_messages_to_process |
||||
|
#: model:ir.model,name:mail_log_messages_to_process.model_mail_thread |
||||
|
msgid "Email Thread" |
||||
|
msgstr "Hilo correo electrónico" |
@ -0,0 +1,24 @@ |
|||||
|
# Translation of Odoo Server. |
||||
|
# This file contains the translation of the following modules: |
||||
|
# * mail_log_messages_to_process |
||||
|
# |
||||
|
# Translators: |
||||
|
# OCA Transbot <transbot@odoo-community.org>, 2017 |
||||
|
msgid "" |
||||
|
msgstr "" |
||||
|
"Project-Id-Version: Odoo Server 9.0c\n" |
||||
|
"Report-Msgid-Bugs-To: \n" |
||||
|
"POT-Creation-Date: 2017-10-21 22:54+0000\n" |
||||
|
"PO-Revision-Date: 2017-10-21 22:54+0000\n" |
||||
|
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n" |
||||
|
"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" |
||||
|
"MIME-Version: 1.0\n" |
||||
|
"Content-Type: text/plain; charset=UTF-8\n" |
||||
|
"Content-Transfer-Encoding: \n" |
||||
|
"Language: fr\n" |
||||
|
"Plural-Forms: nplurals=2; plural=(n > 1);\n" |
||||
|
|
||||
|
#. module: mail_log_messages_to_process |
||||
|
#: model:ir.model,name:mail_log_messages_to_process.model_mail_thread |
||||
|
msgid "Email Thread" |
||||
|
msgstr "Discussion de courriel" |
@ -0,0 +1,24 @@ |
|||||
|
# Translation of Odoo Server. |
||||
|
# This file contains the translation of the following modules: |
||||
|
# * mail_log_messages_to_process |
||||
|
# |
||||
|
# Translators: |
||||
|
# OCA Transbot <transbot@odoo-community.org>, 2017 |
||||
|
msgid "" |
||||
|
msgstr "" |
||||
|
"Project-Id-Version: Odoo Server 9.0c\n" |
||||
|
"Report-Msgid-Bugs-To: \n" |
||||
|
"POT-Creation-Date: 2017-10-21 22:54+0000\n" |
||||
|
"PO-Revision-Date: 2017-10-21 22:54+0000\n" |
||||
|
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n" |
||||
|
"Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\n" |
||||
|
"MIME-Version: 1.0\n" |
||||
|
"Content-Type: text/plain; charset=UTF-8\n" |
||||
|
"Content-Transfer-Encoding: \n" |
||||
|
"Language: it\n" |
||||
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n" |
||||
|
|
||||
|
#. module: mail_log_messages_to_process |
||||
|
#: model:ir.model,name:mail_log_messages_to_process.model_mail_thread |
||||
|
msgid "Email Thread" |
||||
|
msgstr "Discussione Email" |
@ -0,0 +1,24 @@ |
|||||
|
# Translation of Odoo Server. |
||||
|
# This file contains the translation of the following modules: |
||||
|
# * mail_log_messages_to_process |
||||
|
# |
||||
|
# Translators: |
||||
|
# OCA Transbot <transbot@odoo-community.org>, 2017 |
||||
|
msgid "" |
||||
|
msgstr "" |
||||
|
"Project-Id-Version: Odoo Server 9.0c\n" |
||||
|
"Report-Msgid-Bugs-To: \n" |
||||
|
"POT-Creation-Date: 2017-10-21 22:54+0000\n" |
||||
|
"PO-Revision-Date: 2017-10-21 22:54+0000\n" |
||||
|
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n" |
||||
|
"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/teams/23907/pt_BR/)\n" |
||||
|
"MIME-Version: 1.0\n" |
||||
|
"Content-Type: text/plain; charset=UTF-8\n" |
||||
|
"Content-Transfer-Encoding: \n" |
||||
|
"Language: pt_BR\n" |
||||
|
"Plural-Forms: nplurals=2; plural=(n > 1);\n" |
||||
|
|
||||
|
#. module: mail_log_messages_to_process |
||||
|
#: model:ir.model,name:mail_log_messages_to_process.model_mail_thread |
||||
|
msgid "Email Thread" |
||||
|
msgstr "Processo Email" |
@ -0,0 +1,24 @@ |
|||||
|
# Translation of Odoo Server. |
||||
|
# This file contains the translation of the following modules: |
||||
|
# * mail_log_messages_to_process |
||||
|
# |
||||
|
# Translators: |
||||
|
# OCA Transbot <transbot@odoo-community.org>, 2017 |
||||
|
msgid "" |
||||
|
msgstr "" |
||||
|
"Project-Id-Version: Odoo Server 9.0c\n" |
||||
|
"Report-Msgid-Bugs-To: \n" |
||||
|
"POT-Creation-Date: 2017-10-21 22:54+0000\n" |
||||
|
"PO-Revision-Date: 2017-10-21 22:54+0000\n" |
||||
|
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n" |
||||
|
"Language-Team: Portuguese (Portugal) (https://www.transifex.com/oca/teams/23907/pt_PT/)\n" |
||||
|
"MIME-Version: 1.0\n" |
||||
|
"Content-Type: text/plain; charset=UTF-8\n" |
||||
|
"Content-Transfer-Encoding: \n" |
||||
|
"Language: pt_PT\n" |
||||
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n" |
||||
|
|
||||
|
#. module: mail_log_messages_to_process |
||||
|
#: model:ir.model,name:mail_log_messages_to_process.model_mail_thread |
||||
|
msgid "Email Thread" |
||||
|
msgstr "Tópico de Email" |
@ -0,0 +1,24 @@ |
|||||
|
# Translation of Odoo Server. |
||||
|
# This file contains the translation of the following modules: |
||||
|
# * mail_log_messages_to_process |
||||
|
# |
||||
|
# Translators: |
||||
|
# OCA Transbot <transbot@odoo-community.org>, 2017 |
||||
|
msgid "" |
||||
|
msgstr "" |
||||
|
"Project-Id-Version: Odoo Server 9.0c\n" |
||||
|
"Report-Msgid-Bugs-To: \n" |
||||
|
"POT-Creation-Date: 2017-10-21 22:54+0000\n" |
||||
|
"PO-Revision-Date: 2017-10-21 22:54+0000\n" |
||||
|
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n" |
||||
|
"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" |
||||
|
"MIME-Version: 1.0\n" |
||||
|
"Content-Type: text/plain; charset=UTF-8\n" |
||||
|
"Content-Transfer-Encoding: \n" |
||||
|
"Language: sl\n" |
||||
|
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n" |
||||
|
|
||||
|
#. module: mail_log_messages_to_process |
||||
|
#: model:ir.model,name:mail_log_messages_to_process.model_mail_thread |
||||
|
msgid "Email Thread" |
||||
|
msgstr "E-poštna nit" |
@ -0,0 +1,24 @@ |
|||||
|
# Translation of Odoo Server. |
||||
|
# This file contains the translation of the following modules: |
||||
|
# * mail_log_messages_to_process |
||||
|
# |
||||
|
# Translators: |
||||
|
# OCA Transbot <transbot@odoo-community.org>, 2017 |
||||
|
msgid "" |
||||
|
msgstr "" |
||||
|
"Project-Id-Version: Odoo Server 9.0c\n" |
||||
|
"Report-Msgid-Bugs-To: \n" |
||||
|
"POT-Creation-Date: 2017-10-21 22:54+0000\n" |
||||
|
"PO-Revision-Date: 2017-10-21 22:54+0000\n" |
||||
|
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n" |
||||
|
"Language-Team: Turkish (https://www.transifex.com/oca/teams/23907/tr/)\n" |
||||
|
"MIME-Version: 1.0\n" |
||||
|
"Content-Type: text/plain; charset=UTF-8\n" |
||||
|
"Content-Transfer-Encoding: \n" |
||||
|
"Language: tr\n" |
||||
|
"Plural-Forms: nplurals=2; plural=(n > 1);\n" |
||||
|
|
||||
|
#. module: mail_log_messages_to_process |
||||
|
#: model:ir.model,name:mail_log_messages_to_process.model_mail_thread |
||||
|
msgid "Email Thread" |
||||
|
msgstr "Eposta konuşması" |
@ -0,0 +1,4 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
from . import mail_thread |
@ -0,0 +1,81 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# Copyright 2017-18 Eficent Business and IT Consulting Services S.L. |
||||
|
# (www.eficent.com) |
||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
import email |
||||
|
import xmlrpclib |
||||
|
import logging |
||||
|
from email.message import Message |
||||
|
from odoo import api, models |
||||
|
from odoo.tools import decode_smtp_header as decode |
||||
|
|
||||
|
_logger = logging.getLogger(__name__) |
||||
|
|
||||
|
|
||||
|
class MailThread(models.AbstractModel): |
||||
|
_inherit = 'mail.thread' |
||||
|
|
||||
|
@api.model |
||||
|
def message_parse_basic_data(self, message): |
||||
|
"""Parses a string or email.message.Message representing an RFC-2822 |
||||
|
email, and returns a generic dict holding the message details. |
||||
|
|
||||
|
:param message: the message to parse |
||||
|
:rtype: dict |
||||
|
:return: A dict with the following structure, where each field |
||||
|
may not be present if missing in original message: |
||||
|
{ 'message_id': msg_id, |
||||
|
'subject': subject, |
||||
|
'from': from, |
||||
|
'to': to, |
||||
|
'cc': cc |
||||
|
} |
||||
|
""" |
||||
|
|
||||
|
msg_dict = { |
||||
|
'message_type': 'email', |
||||
|
} |
||||
|
if not isinstance(message, Message): |
||||
|
if isinstance(message, unicode): |
||||
|
# Warning: message_from_string doesn't always work |
||||
|
# correctly on unicode, we must use utf-8 strings here :-( |
||||
|
message = message.encode('utf-8') |
||||
|
message = email.message_from_string(message) |
||||
|
|
||||
|
message_id = message['message-id'] |
||||
|
if not message_id: |
||||
|
message_id = 'None' |
||||
|
msg_dict['message_id'] = message_id |
||||
|
if message.get('Subject'): |
||||
|
msg_dict['subject'] = decode(message.get('Subject')) |
||||
|
|
||||
|
# Envelope fields not stored in mail.message but made available |
||||
|
# for message_new() |
||||
|
msg_dict['from'] = decode(message.get('from')) |
||||
|
msg_dict['to'] = decode(message.get('to')) |
||||
|
msg_dict['cc'] = decode(message.get('cc')) |
||||
|
msg_dict['email_from'] = decode(message.get('from')) |
||||
|
return msg_dict |
||||
|
|
||||
|
@api.model |
||||
|
def message_process(self, model, message, custom_values=None, |
||||
|
save_original=False, strip_attachments=False, |
||||
|
thread_id=None): |
||||
|
|
||||
|
if isinstance(message, xmlrpclib.Binary): |
||||
|
message = str(message.data) |
||||
|
# Warning: message_from_string doesn't always work correctly on |
||||
|
# unicode, we must use utf-8 strings here :-( |
||||
|
if isinstance(message, unicode): |
||||
|
message = message.encode('utf-8') |
||||
|
msg_txt = email.message_from_string(message) |
||||
|
msg = self.message_parse_basic_data(msg_txt) |
||||
|
_logger.info( |
||||
|
'Fetched mail from %s to %s with Message-Id %s', |
||||
|
msg.get('from'), msg.get('to'), msg.get('message_id')) |
||||
|
|
||||
|
return super(MailThread, self).message_process( |
||||
|
model, message, custom_values=custom_values, |
||||
|
save_original=save_original, |
||||
|
strip_attachments=strip_attachments, thread_id=thread_id) |
After Width: 128 | Height: 128 | Size: 9.2 KiB |
Write
Preview
Loading…
Cancel
Save
Reference in new issue