Merge PR #503 into 12.0

Signed-off-by dreispt
pull/522/head
OCA-git-bot 2020-03-10 10:20:01 +00:00
commit 36981524e4
25 changed files with 1033 additions and 0 deletions

View File

@ -0,0 +1,94 @@
==========================
Drag & drop emails to Odoo
==========================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github
:target: https://github.com/OCA/social/tree/12.0/mail_drop_target
:alt: OCA/social
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/social-12-0/social-12-0-mail_drop_target
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/205/12.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
This module was written to allow users to drag&drop emails from their desktop to Odoo.
It supports as well RFC822 .eml files as Outlook .msg (those only if `an extra library <https://github.com/mattgwwalker/msg-extractor>`_ is installed) files.
When the mail is dropped to an odoo record, it will automatically send a notification
of that new message that has been added to all the existing followers. It is possible
to disable this notification.
**Table of contents**
.. contents::
:local:
Usage
=====
To use this module, you need to:
#. save your emails on the desktop / somewhere in the file system
#. drag them to your browser, and drop them on the chatter of the record you want to attach your email to
Known issues / Roadmap
======================
* most mail clients won't allow you to drag mails directly from the mail client, you'll need some plugin for that
* for corporate environments, it might be feasible to support imap URLs and get the mail in question on the server side
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/social/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 <https://github.com/OCA/social/issues/new?body=module:%20mail_drop_target%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
Credits
=======
Authors
~~~~~~~
* Therp BV
Contributors
~~~~~~~~~~~~
* Holger Brunn <hbrunn@therp.nl>
* Enric Tobella <etobella@creublanca.es>
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/social <https://github.com/OCA/social/tree/12.0/mail_drop_target>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -0,0 +1,3 @@
# Copyright 2018 Therp BV <https://therp.nl>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import models

View File

@ -0,0 +1,23 @@
# Copyright 2018 Therp BV <https://therp.nl>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Drag & drop emails to Odoo",
"version": "12.0.1.1.0",
"author": "Therp BV,Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Discuss",
"summary": "Attach emails to Odoo by dragging them from your desktop",
"depends": [
'mail',
'web_drop_target',
],
"external_dependencies": {
"python": [
"extract_msg",
],
},
"data": [
'views/templates.xml',
'views/res_config_settings_views.xml',
],
}

View File

@ -0,0 +1,58 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_drop_target
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.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: mail_drop_target
#: model:ir.ui.view,arch_db:mail_drop_target.res_config_settings_view_form
msgid "Disable Mail Drag&Drop Notification"
msgstr ""
#. module: mail_drop_target
#: model:ir.model.fields,field_description:mail_drop_target.field_res_config_settings_disable_notify_mail_drop_target
msgid "Disable Notification followers on mail dropped to a Thread"
msgstr ""
#. module: mail_drop_target
#: model:ir.model,name:mail_drop_target.model_mail_thread
msgid "Email Thread"
msgstr ""
#. module: mail_drop_target
#: code:addons/mail_drop_target/models/mail_thread.py:53
#, python-format
msgid "Install the msg-extractor library to handle .msg files"
msgstr ""
#. module: mail_drop_target
#: code:addons/mail_drop_target/models/mail_thread.py:42
#, python-format
msgid "This message is already imported."
msgstr ""
#. module: mail_drop_target
#: model:ir.ui.view,arch_db:mail_drop_target.res_config_settings_view_form
msgid "When a user drops an email into an existing thread\n"
" the followers of the thread will not be notified."
msgstr ""
#. module: mail_drop_target
#: model:ir.model.fields,help:mail_drop_target.field_res_config_settings_disable_notify_mail_drop_target
msgid "When this setting is set, when a user drops an email into an existing thread the followers of the thread will not be notified. This sets an ir.config.parameter mail_drop_target.disable_notify"
msgstr ""
#. module: mail_drop_target
#: model:ir.model,name:mail_drop_target.model_res_config_settings
msgid "res.config.settings"
msgstr ""

View File

@ -0,0 +1,5 @@
# Copyright 2018 Therp BV <https://therp.nl>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import mail_message
from . import mail_thread
from . import res_config_settings

View File

@ -0,0 +1,18 @@
from odoo import api, models
class MailMessage(models.Model):
_inherit = 'mail.message'
@api.multi
def _notify(
self, record, msg_vals, force_send=False, send_after_commit=True,
model_description=False, mail_auto_delete=True
):
if self.env.context.get('message_create_from_mail_mail', False):
return
return super()._notify(
record, msg_vals, force_send=force_send,
send_after_commit=send_after_commit,
model_description=model_description,
mail_auto_delete=mail_auto_delete)

View File

@ -0,0 +1,72 @@
# Copyright 2018 Therp BV <https://therp.nl>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from base64 import b64decode
try:
from extract_msg import Message
except ImportError:
Message = None
from odoo import _, api, exceptions, models
class MailThread(models.AbstractModel):
_inherit = 'mail.thread'
@api.model
def message_drop(self, model, message, custom_values=None,
save_original=False, strip_attachments=False,
thread_id=None):
disable_notify_mail_drop_target = \
self.env["ir.config_parameter"].sudo().get_param(
"mail_drop_target.disable_notify", default=False)
self_message_process = self
if disable_notify_mail_drop_target:
self_message_process = self_message_process.with_context(
message_create_from_mail_mail=True)
result = self_message_process.message_process(
model, message, custom_values=custom_values,
save_original=save_original, strip_attachments=strip_attachments,
thread_id=thread_id
)
if not result:
return self.message_drop_existing(
model, message, custom_values=custom_values,
save_original=save_original,
strip_attachments=strip_attachments, thread_id=thread_id
)
return result
@api.model
def message_drop_existing(self, model, message,
custom_values=None, save_original=False,
strip_attachments=False, thread_id=None):
message = _("This message is already imported.")
raise exceptions.Warning(message)
@api.model
def message_process_msg(
self, model, message, custom_values=None, save_original=False,
strip_attachments=False, thread_id=None,
):
"""Convert message to RFC2822 and pass to message_process"""
if not Message:
raise exceptions.UserError(
_('Install the msg-extractor library to handle .msg files')
)
message_msg = Message(b64decode(message))
message_email = self.env['ir.mail_server'].build_email(
message_msg.sender, message_msg.to.split(','), message_msg.subject,
# prefer html bodies to text
message_msg._getStream('__substg1.0_10130102') or message_msg.body,
email_cc=message_msg.cc,
headers={'date': message_msg.date},
message_id=message_msg.message_id,
attachments=[
(attachment.longFilename, attachment.data)
for attachment in message_msg.attachments
],
)
return self.message_drop(
model, message_email.as_string(), custom_values=custom_values,
save_original=save_original, strip_attachments=strip_attachments,
thread_id=thread_id,
)

View File

@ -0,0 +1,33 @@
# Copyright 2019 Eficent Business and IT Consulting Services, S.L.
# <https//www.eficent.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
disable_notify_mail_drop_target = fields.Boolean(
'Disable Notification followers on mail dropped to a Thread',
help="When this setting is set, when a user drops an "
"email into an existing thread the followers of the thread will "
"not be notified. This sets an ir.config.parameter "
"mail_drop_target.disable_notify")
@api.model
def get_values(self):
res = super(ResConfigSettings, self).get_values()
disable_notify_mail_drop_target = \
self.env["ir.config_parameter"].get_param(
"mail_drop_target.disable_notify", default=False)
res.update(
disable_notify_mail_drop_target=disable_notify_mail_drop_target,
)
return res
def set_values(self):
super(ResConfigSettings, self).set_values()
self.env['ir.config_parameter'].set_param(
"mail_drop_target.disable_notify",
self.disable_notify_mail_drop_target or '')

View File

@ -0,0 +1,3 @@
To disable the automatic notification to existing followers when you drop an
email to a record, go to *Settings*, activate the developer mode, and then go to
*Settings / General Settings* and set the flag 'Disable Mail Drag&Drop Notification'.

View File

@ -0,0 +1,2 @@
* Holger Brunn <hbrunn@therp.nl>
* Enric Tobella <etobella@creublanca.es>

View File

@ -0,0 +1,7 @@
This module was written to allow users to drag&drop emails from their desktop to Odoo.
It supports as well RFC822 .eml files as Outlook .msg (those only if `an extra library <https://github.com/mattgwwalker/msg-extractor>`_ is installed) files.
When the mail is dropped to an odoo record, it will automatically send a notification
of that new message that has been added to all the existing followers. It is possible
to disable this notification.

View File

@ -0,0 +1,2 @@
* most mail clients won't allow you to drag mails directly from the mail client, you'll need some plugin for that
* for corporate environments, it might be feasible to support imap URLs and get the mail in question on the server side

View File

@ -0,0 +1,4 @@
To use this module, you need to:
#. save your emails on the desktop / somewhere in the file system
#. drag them to your browser, and drop them on the chatter of the record you want to attach your email to

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@ -0,0 +1,441 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.14: http://docutils.sourceforge.net/" />
<title>Drag &amp; drop emails to Odoo</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
.subscript {
vertical-align: sub;
font-size: smaller }
.superscript {
vertical-align: super;
font-size: smaller }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
overflow: hidden;
}
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left, .figure.align-left, object.align-left, table.align-left {
clear: left ;
float: left ;
margin-right: 1em }
img.align-right, .figure.align-right, object.align-right, table.align-right {
clear: right ;
float: right ;
margin-left: 1em }
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left }
.align-center {
clear: both ;
text-align: center }
.align-right {
text-align: right }
/* reset inner alignment in figures */
div.align-right {
text-align: inherit }
/* div.align-center * { */
/* text-align: left } */
.align-top {
vertical-align: top }
.align-middle {
vertical-align: middle }
.align-bottom {
vertical-align: bottom }
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font: inherit }
pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
border: 0px;
border-top: 2px solid;
border-bottom: 2px solid;
border-collapse: collapse;
}
table.docutils.booktabs * {
border: 0px;
}
table.docutils.booktabs th {
border-bottom: thin solid;
text-align: left;
}
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
ul.auto-toc {
list-style-type: none }
</style>
</head>
<body>
<div class="document" id="drag-drop-emails-to-odoo">
<h1 class="title">Drag &amp; drop emails to Odoo</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/social/tree/12.0/mail_drop_target"><img alt="OCA/social" src="https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/social-12-0/social-12-0-mail_drop_target"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/205/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module was written to allow users to drag&amp;drop emails from their desktop to Odoo.</p>
<p>It supports as well RFC822 .eml files as Outlook .msg (those only if <a class="reference external" href="https://github.com/mattgwwalker/msg-extractor">an extra library</a> is installed) files.</p>
<p>When the mail is dropped to an odoo record, it will automatically send a notification
of that new message that has been added to all the existing followers. It is possible
to disable this notification.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#usage" id="id1">Usage</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="id2">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id3">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id4">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id5">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id6">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id7">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#id1">Usage</a></h1>
<p>To use this module, you need to:</p>
<ol class="arabic simple">
<li>save your emails on the desktop / somewhere in the file system</li>
<li>drag them to your browser, and drop them on the chatter of the record you want to attach your email to</li>
</ol>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#id2">Known issues / Roadmap</a></h1>
<ul class="simple">
<li>most mail clients wont allow you to drag mails directly from the mail client, youll need some plugin for that</li>
<li>for corporate environments, it might be feasible to support imap URLs and get the mail in question on the server side</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/social/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/social/issues/new?body=module:%20mail_drop_target%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#id4">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id5">Authors</a></h2>
<ul class="simple">
<li>Therp BV</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id6">Contributors</a></h2>
<ul class="simple">
<li>Holger Brunn &lt;<a class="reference external" href="mailto:hbrunn&#64;therp.nl">hbrunn&#64;therp.nl</a>&gt;</li>
<li>Enric Tobella &lt;<a class="reference external" href="mailto:etobella&#64;creublanca.es">etobella&#64;creublanca.es</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/social/tree/12.0/mail_drop_target">OCA/social</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,3 @@
.o-mail-drag-over {
filter: blur(2px);
}

View File

@ -0,0 +1,77 @@
// -*- coding: utf-8 -*-
// Copyright 2018 Therp BV <https://therp.nl>
// License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
odoo.define('mail_drop_target', function (require) {
"use strict";
var Chatter = require('mail.Chatter');
var web_drop_target = require('web_drop_target');
Chatter.include(web_drop_target.DropTargetMixin);
Chatter.include({
_drop_allowed_types: ['message/rfc822'],
_get_drop_item: function (e) {
var dataTransfer = e.originalEvent.dataTransfer;
if (
dataTransfer.items.length === 1 &&
dataTransfer.items[0].type === '' &&
dataTransfer.items[0].kind === 'file'
) {
// this might be an outlook msg file
return dataTransfer.items[0];
}
return this._super.apply(this, arguments);
},
_handle_drop_items: function (drop_items, e) {
var self = this;
_.each(drop_items, function(item, e) {
return self._handle_file_drop_proxy(item, e);
});
},
_handle_file_drop_proxy: function (item, e) {
var self = this;
var file = item;
if (!file || !(file instanceof Blob)) {
return;
}
var reader = new FileReader();
reader.onloadend = self.proxy(
_.partial(self._handle_file_drop, file, reader, e)
);
reader.onerror = self.proxy('_file_reader_error_handler');
reader.readAsArrayBuffer(file);
},
_handle_file_drop: function (drop_file, reader, e) {
var self = this,
mail_processor = '',
data = '';
if (drop_file.name.endsWith('.msg')) {
mail_processor = 'message_process_msg';
data = base64js.fromByteArray(
new Uint8Array(reader.result)
);
} else {
mail_processor = 'message_drop';
var reader_array = new Uint8Array(reader.result);
data = "";
for (var i = 0; i < reader_array.length; i++) {
data += String.fromCharCode(parseInt(reader_array[i]));
}
}
// TODO: read some config parameter if this should set
// some of the context keys to suppress mail.thread's behavior
return this._rpc({
model:'mail.thread',
method:mail_processor,
args: [this.record.model, data],
kwargs: {
thread_id: this.record.data.id,
},
}).then(function() {
self.trigger_up('reload', {});
});
},
});
});

View File

@ -0,0 +1 @@
from . import test_mail_drop_target

View File

@ -0,0 +1,75 @@
X-MDAV-Result: clean
X-MDAV-Processed: mail3.creublanca.es, Wed, 26 Jun 2019 18:08:19 +0200
Return-path: <etobella@creublanca.es>
Authentication-Results: mail3.creublanca.es;
auth=pass (login) smtp.auth=etobella@creublanca.es
Received: from WorldClient by creublanca.es with ESMTPA id md50020655392.msg;
Wed, 26 Jun 2019 18:08:19 +0200
X-Spam-Processed: mail3.creublanca.es, Wed, 26 Jun 2019 18:08:19 +0200
(not processed: message from trusted or authenticated source)
X-MDArrival-Date: Wed, 26 Jun 2019 18:08:19 +0200
X-Authenticated-Sender: etobella@creublanca.es
X-Rcpt-To: etobella@creublanca.es
X-MDRcpt-To: etobella@creublanca.es
X-Return-Path: prvs=10800b8cdb=etobella@creublanca.es
X-Envelope-From: etobella@creublanca.es
X-MDaemon-Deliver-To: etobella@creublanca.es
Received: by creublanca.es via MDaemon Webmail with HTTP;
Wed, 26 Jun 2019 18:08:16 +0200
Date: Wed, 26 Jun 2019 18:08:16 +0200
From: "Enric Tobella" <etobella@creublanca.es>
To: "Enric Tobella" <etobella@creublanca.es>
Subject: Test
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="0626-1608-16-03-PART_BREAK"
Message-ID: <WC20190626160816.960736@creublanca.es>
X-Mailer: MDaemon Webmail 19.0.2
--0626-1608-16-03-PART_BREAK
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
TEST
Tanto este mensaje como los documentos que, en su caso, lleve como anexos,
pueden contener informacin reservada y/o confidencial, destinada exclusivamente
para el uso del destinatario o la persona responsable de entregarlo al mismo,
estando su uso no autorizado prohibido legalmente.
Su contenido no constituye un compromiso para Creu Blanca (la empresa remitente)
salvo ratificacin escrita por ambas partes. En caso de su recepcin por error,
rogamos nos lo comunique por igual va, se abstenga de realizar copias del mensaje
o documentos adjuntos, remitirlo o facilitarlo a un tercero, y proceda en su defecto,
a su eliminacin.
--0626-1608-16-03-PART_BREAK
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
<html><body>
<div style=3D"font-family: Trebuchet MS; color: rgb(0, 0, 0); font-size: 13=
.3333px; font-weight: 400; font-style: normal;">TEST</div>
<br><br>
<br>
<br>
Tanto este mensaje como los documentos que, en su caso, lleve como anexos, =
<br>
pueden contener informaci=F3n reservada y/o confidencial, destinada exclusi=
vamente <br>
para el uso del destinatario o la persona responsable de entregarlo al mism=
o, <br>
estando su uso no autorizado prohibido legalmente. <br>
Su contenido no constituye un compromiso para Creu Blanca (la empresa remit=
ente) <br>
salvo ratificaci=F3n escrita por ambas partes. En caso de su recepci=F3n po=
r error, <br>
rogamos nos lo comunique por igual v=EDa, se abstenga de realizar copias de=
l mensaje <br>
o documentos adjuntos, remitirlo o facilitarlo a un tercero, y proceda en s=
u defecto, <br>
a su eliminaci=F3n.<br>
</body></html>
--0626-1608-16-03-PART_BREAK--

Binary file not shown.

View File

@ -0,0 +1,73 @@
from odoo.tests.common import TransactionCase
from odoo import exceptions, tools
from mock import patch
import base64
class TestMailDropTarget(TransactionCase):
def setUp(self):
super().setUp()
self.partner = self.env['res.partner'].create({
'name': 'TEST PARTNER'
})
self.partner.message_subscribe(partner_ids=self.partner.ids)
def test_eml(self):
message = tools.file_open(
'sample.eml',
subdir="addons/mail_drop_target/tests"
).read()
comments = len(self.partner.message_ids)
self.partner.message_process(
self.partner._name, message, thread_id=self.partner.id)
self.partner.refresh()
self.assertEqual(comments+1, len(self.partner.message_ids))
with self.assertRaises(exceptions.Warning):
self.partner.message_drop(
self.partner._name, message, thread_id=self.partner.id)
def test_msg(self):
message = base64.b64encode(tools.file_open(
'sample.msg',
mode='rb',
subdir="addons/mail_drop_target/tests"
).read())
comments = len(self.partner.message_ids)
self.partner.message_process_msg(
self.partner._name, message, thread_id=self.partner.id)
self.partner.refresh()
self.assertEqual(comments+1, len(self.partner.message_ids))
msg = self.partner.message_ids.filtered(
lambda m: m.subject == 'Test')
self.assertIsNotNone(msg.needaction_partner_ids)
with self.assertRaises(exceptions.Warning):
self.partner.message_process_msg(
self.partner._name, message, thread_id=self.partner.id)
def test_no_msgextract(self):
with self.assertRaises(exceptions.UserError), patch(
'odoo.addons.mail_drop_target.models.mail_thread.Message',
new=False,
):
self.test_msg()
def test_msg_no_notification(self):
message = base64.b64encode(tools.file_open(
'sample.msg',
mode='rb',
subdir="addons/mail_drop_target/tests"
).read())
settings = self.env['res.config.settings'].create({})
settings.disable_notify_mail_drop_target = True
settings.execute()
comments = len(self.partner.message_ids)
self.partner.message_process_msg(
self.partner._name, message, thread_id=self.partner.id)
self.partner.refresh()
self.assertEqual(comments+1, len(self.partner.message_ids))
msg = self.partner.message_ids.filtered(
lambda m: m.subject == 'Test')
self.assertEqual(len(msg.needaction_partner_ids), 0)
with self.assertRaises(exceptions.Warning):
self.partner.message_process_msg(
self.partner._name, message, thread_id=self.partner.id)

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit.mail</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="mail.res_config_settings_view_form"/>
<field name="arch" type="xml">
<div id="emails" position="inside">
<div class="col-xs-12 col-md-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="disable_notify_mail_drop_target"/>
</div>
<div class="o_setting_right_pane">
<label string="Disable Mail Drag&amp;Drop Notification" for="disable_notify_mail_drop_target"/>
<div class="text-muted">
When a user drops an email into an existing thread
the followers of the thread will not be notified.
</div>
</div>
</div>
</div>
</field>
</record>
</data>
</odoo>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<template id="assets_backend" name="mail_drop_target assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/mail_drop_target/static/src/js/mail_drop_target.js"></script>
<link rel="stylesheet" href="/mail_drop_target/static/src/css/mail_drop_target.css"/>
</xpath>
</template>
</data>
</openerp>

View File

@ -1,2 +1,3 @@
server-tools
reporting-engine
web

View File

@ -1,2 +1,3 @@
# mail_inline_css
premailer
extract-msg