Skip to content

Commit 9dbe1a0

Browse files
etobellaolgamarcocb
authored andcommitted
[IMP] mail_drop_target: Raise a warning when the file has already been imported
1 parent 9126a06 commit 9dbe1a0

File tree

6 files changed

+572
-49
lines changed

6 files changed

+572
-49
lines changed

mail_drop_target/README.rst

+45-23
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,39 @@
1-
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
2-
:target: https://www.gnu.org/licenses/agpl-3.0-standalone.html
3-
:alt: License: AGPL-3
4-
51
==========================
62
Drag & drop emails to Odoo
73
==========================
84

5+
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6+
!! This file is generated by oca-gen-addon-readme !!
7+
!! changes will be overwritten. !!
8+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
9+
10+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
11+
:target: https://odoo-community.org/page/development-status
12+
:alt: Beta
13+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
14+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
15+
:alt: License: AGPL-3
16+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github
17+
:target: https://github.com/OCA/social/tree/11.0/mail_drop_target
18+
:alt: OCA/social
19+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
20+
:target: https://translation.odoo-community.org/projects/social-11-0/social-11-0-mail_drop_target
21+
:alt: Translate me on Weblate
22+
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
23+
:target: https://runbot.odoo-community.org/runbot/205/11.0
24+
:alt: Try me on Runbot
25+
26+
|badge1| |badge2| |badge3| |badge4| |badge5|
27+
928
This module was written to allow users to drag&drop emails from their desktop to Odoo.
1029

1130
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.
1231

32+
**Table of contents**
33+
34+
.. contents::
35+
:local:
36+
1337
Usage
1438
=====
1539

@@ -31,42 +55,40 @@ Known issues / Roadmap
3155
Bug Tracker
3256
===========
3357

34-
Bugs are tracked on `GitHub Issues
35-
<https://github.com/OCA/social/issues>`_. In case of trouble, please
36-
check there if your issue has already been reported. If you spotted it first,
37-
help us smashing it by providing a detailed and welcomed feedback.
58+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/social/issues>`_.
59+
In case of trouble, please check there if your issue has already been reported.
60+
If you spotted it first, help us smashing it by providing a detailed and welcomed
61+
`feedback <https://github.com/OCA/social/issues/new?body=module:%20mail_drop_target%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
62+
63+
Do not contact contributors directly about support or help with technical issues.
3864

3965
Credits
4066
=======
4167

42-
Images
43-
------
44-
45-
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
46-
47-
Libraries
48-
---------
68+
Authors
69+
~~~~~~~
4970

50-
* `msg-extractor <https://github.com/mattgwwalker/msg-extractor>`_
71+
* Therp BV
5172

5273
Contributors
53-
------------
74+
~~~~~~~~~~~~
5475

5576
* Holger Brunn <[email protected]>
77+
* Enric Tobella <[email protected]>
5678

57-
Do not contact contributors directly about help with questions or problems concerning this addon, but use the `community mailing list <mailto:[email protected]>`_ or the `appropriate specialized mailinglist <https://odoo-community.org/groups>`_ for help, and the bug tracker linked in `Bug Tracker`_ above for technical issues.
79+
Maintainers
80+
~~~~~~~~~~~
5881

59-
Maintainer
60-
----------
82+
This module is maintained by the OCA.
6183

6284
.. image:: https://odoo-community.org/logo.png
6385
:alt: Odoo Community Association
6486
:target: https://odoo-community.org
6587

66-
This module is maintained by the OCA.
67-
6888
OCA, or the Odoo Community Association, is a nonprofit organization whose
6989
mission is to support the collaborative development of Odoo features and
7090
promote its widespread use.
7191

72-
To contribute to this module, please visit https://odoo-community.org.
92+
This module is part of the `OCA/social <https://github.com/OCA/social/tree/11.0/mail_drop_target>`_ project on GitHub.
93+
94+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * mail_drop_target
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 11.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"Last-Translator: <>\n"
10+
"Language-Team: \n"
11+
"MIME-Version: 1.0\n"
12+
"Content-Type: text/plain; charset=UTF-8\n"
13+
"Content-Transfer-Encoding: \n"
14+
"Plural-Forms: \n"
15+
16+
#. module: mail_drop_target
17+
#: model:ir.model,name:mail_drop_target.model_mail_thread
18+
msgid "Email Thread"
19+
msgstr ""
20+
21+
#. module: mail_drop_target
22+
#: code:addons/mail_drop_target/models/mail_thread.py:46
23+
#, python-format
24+
msgid "Install the msg-extractor library to handle .msg files"
25+
msgstr ""
26+
27+
#. module: mail_drop_target
28+
#: code:addons/mail_drop_target/models/mail_thread.py:35
29+
#, python-format
30+
msgid "This message is already imported."
31+
msgstr ""
32+

mail_drop_target/models/mail_thread.py

+26-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,30 @@
1111
class MailThread(models.AbstractModel):
1212
_inherit = 'mail.thread'
1313

14+
@api.model
15+
def message_drop(self, model, message, custom_values=None,
16+
save_original=False, strip_attachments=False,
17+
thread_id=None):
18+
result = self.message_process(
19+
model, message, custom_values=custom_values,
20+
save_original=save_original, strip_attachments=strip_attachments,
21+
thread_id=thread_id
22+
)
23+
if not result:
24+
return self.message_drop_existing(
25+
model, message, custom_values=custom_values,
26+
save_original=save_original,
27+
strip_attachments=strip_attachments, thread_id=thread_id
28+
)
29+
return result
30+
31+
@api.model
32+
def message_drop_existing(self, model, message,
33+
custom_values=None, save_original=False,
34+
strip_attachments=False, thread_id=None):
35+
message = _("This message is already imported.")
36+
raise exceptions.Warning(message)
37+
1438
@api.model
1539
def message_process_msg(
1640
self, model, message, custom_values=None, save_original=False,
@@ -28,12 +52,13 @@ def message_process_msg(
2852
message_msg._getStream('__substg1.0_10130102') or message_msg.body,
2953
email_cc=message_msg.cc,
3054
headers={'date': message_msg.date},
55+
message_id=message_msg.message_id,
3156
attachments=[
3257
(attachment.longFilename, attachment.data)
3358
for attachment in message_msg.attachments
3459
],
3560
)
36-
return self.message_process(
61+
return self.message_drop(
3762
model, message_email.as_string(), custom_values=custom_values,
3863
save_original=save_original, strip_attachments=strip_attachments,
3964
thread_id=thread_id,

0 commit comments

Comments
 (0)