From fe3be81a4de4ae42645be4dd735c38e3d869e7fc Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 12 Mar 2018 13:06:44 +0100 Subject: [PATCH 01/12] [ADD] mail_drop_target PoC --- mail_drop_target/README.rst | 72 ++++++++++++++++++ mail_drop_target/__init__.py | 4 + mail_drop_target/__manifest__.py | 18 +++++ mail_drop_target/models/__init__.py | 4 + mail_drop_target/models/mail_thread.py | 41 ++++++++++ mail_drop_target/static/description/icon.png | Bin 0 -> 9455 bytes .../static/src/css/mail_drop_target.css | 3 + .../static/src/js/mail_drop_target.js | 55 +++++++++++++ mail_drop_target/views/templates.xml | 11 +++ 9 files changed, 208 insertions(+) create mode 100644 mail_drop_target/README.rst create mode 100644 mail_drop_target/__init__.py create mode 100644 mail_drop_target/__manifest__.py create mode 100644 mail_drop_target/models/__init__.py create mode 100644 mail_drop_target/models/mail_thread.py create mode 100644 mail_drop_target/static/description/icon.png create mode 100644 mail_drop_target/static/src/css/mail_drop_target.css create mode 100644 mail_drop_target/static/src/js/mail_drop_target.js create mode 100644 mail_drop_target/views/templates.xml diff --git a/mail_drop_target/README.rst b/mail_drop_target/README.rst new file mode 100644 index 000000000..c6dd98c6e --- /dev/null +++ b/mail_drop_target/README.rst @@ -0,0 +1,72 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: https://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +========================== +Drag & drop emails to Odoo +========================== + +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 `_ is installed) files. + +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 + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/205/10.0 + +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 +`_. 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. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Libraries +--------- + +* `msg-extractor `_ + +Contributors +------------ + +* Holger Brunn + +Do not contact contributors directly about help with questions or problems concerning this addon, but use the `community mailing list `_ or the `appropriate specialized mailinglist `_ for help, and the bug tracker linked in `Bug Tracker`_ above for technical issues. + +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. diff --git a/mail_drop_target/__init__.py b/mail_drop_target/__init__.py new file mode 100644 index 000000000..242234495 --- /dev/null +++ b/mail_drop_target/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Therp BV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from . import models diff --git a/mail_drop_target/__manifest__.py b/mail_drop_target/__manifest__.py new file mode 100644 index 000000000..e36504371 --- /dev/null +++ b/mail_drop_target/__manifest__.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Therp BV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + "name": "Drag & drop emails to Odoo", + "version": "10.0.1.0.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', + ], + "data": [ + 'views/templates.xml', + ], +} diff --git a/mail_drop_target/models/__init__.py b/mail_drop_target/models/__init__.py new file mode 100644 index 000000000..1211df53d --- /dev/null +++ b/mail_drop_target/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Therp BV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from . import mail_thread diff --git a/mail_drop_target/models/mail_thread.py b/mail_drop_target/models/mail_thread.py new file mode 100644 index 000000000..392c3dd4f --- /dev/null +++ b/mail_drop_target/models/mail_thread.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Therp BV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from base64 import b64decode +try: + from ExtractMsg import Message +except ImportError: + Message = None +from odoo import _, api, exceptions, models + + +class MailThread(models.AbstractModel): + _inherit = 'mail.thread' + + @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}, + attachments=[ + (attachment.longFilename, attachment.data) + for attachment in message_msg.attachments + ], + ) + return self.message_process( + model, message_email.as_string(), custom_values=custom_values, + save_original=save_original, strip_attachments=strip_attachments, + thread_id=thread_id, + ) diff --git a/mail_drop_target/static/description/icon.png b/mail_drop_target/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d GIT binary patch literal 9455 zcmW++2RxMjAAjx~&dlBk9S+%}OXg)AGE&Cb*&}d0jUxM@u(PQx^-s)697TX`ehR4?GS^qbkof1cslKgkU)h65qZ9Oc=ml_0temigYLJfnz{IDzUf>bGs4N!v3=Z3jMq&A#7%rM5eQ#dc?k~! zVpnB`o+K7|Al`Q_U;eD$B zfJtP*jH`siUq~{KE)`jP2|#TUEFGRryE2`i0**z#*^6~AI|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X_NhT8*Tj>BTrTTL&!?O+%Rv;b?B??gSzdp?6Uug9{ zd@V08Z$BdI?fpoCS$)t4mg4rT8Q_I}h`0d-vYZ^|dOB*Q^S|xqTV*vIg?@fVFSmMpaw0qtTRbx} z({Pg?#{2`sc9)M5N$*N|4;^t$+QP?#mov zGVC@I*lBVrOU-%2y!7%)fAKjpEFsgQc4{amtiHb95KQEwvf<(3T<9-Zm$xIew#P22 zc2Ix|App^>v6(3L_MCU0d3W##AB0M~3D00EWoKZqsJYT(#@w$Y_H7G22M~ApVFTRHMI_3be)Lkn#0F*V8Pq zc}`Cjy$bE;FJ6H7p=0y#R>`}-m4(0F>%@P|?7fx{=R^uFdISRnZ2W_xQhD{YuR3t< z{6yxu=4~JkeA;|(J6_nv#>Nvs&FuLA&PW^he@t(UwFFE8)|a!R{`E`K`i^ZnyE4$k z;(749Ix|oi$c3QbEJ3b~D_kQsPz~fIUKym($a_7dJ?o+40*OLl^{=&oq$<#Q(yyrp z{J-FAniyAw9tPbe&IhQ|a`DqFTVQGQ&Gq3!C2==4x{6EJwiPZ8zub-iXoUtkJiG{} zPaR&}_fn8_z~(=;5lD-aPWD3z8PZS@AaUiomF!G8I}Mf>e~0g#BelA-5#`cj;O5>N Xviia!U7SGha1wx#SCgwmn*{w2TRX*I literal 0 HcmV?d00001 diff --git a/mail_drop_target/static/src/css/mail_drop_target.css b/mail_drop_target/static/src/css/mail_drop_target.css new file mode 100644 index 000000000..1056f02e9 --- /dev/null +++ b/mail_drop_target/static/src/css/mail_drop_target.css @@ -0,0 +1,3 @@ +.o-mail-drag-over { + filter: blur(2px); +} diff --git a/mail_drop_target/static/src/js/mail_drop_target.js b/mail_drop_target/static/src/js/mail_drop_target.js new file mode 100644 index 000000000..3a8626ec4 --- /dev/null +++ b/mail_drop_target/static/src/js/mail_drop_target.js @@ -0,0 +1,55 @@ +//-*- coding: utf-8 -*- +//Copyright 2018 Therp BV +//License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +odoo.define('mail_drop_target', function(require) +{ + var Chatter = require('mail.Chatter'), + web_drop_target = require('web_drop_target'), + Model = require('web.Model'); + + 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_file_drop: function(drop_file, e) { + var self = this, + mail_processor = '', + data = ''; + if(drop_file.name.endsWith('.msg')) { + mail_processor = 'message_process_msg'; + data = base64js.fromByteArray( + new Uint8Array(e.target.result) + ); + } else { + mail_processor = 'message_process'; + data = String.fromCharCode.apply( + null, new Uint8Array(e.currentTarget.result) + ); + } + // TODO: read some config parameter if this should set + // some of the context keys to suppress mail.thread's behavior + return new Model('mail.thread').call( + mail_processor, + [this.field_manager.dataset.model, data], + { + thread_id: this.field_manager.datarecord.id, + } + ) + .then(function() { + return self.field_manager.reload(); + }); + } + }); +}); diff --git a/mail_drop_target/views/templates.xml b/mail_drop_target/views/templates.xml new file mode 100644 index 000000000..44031fc72 --- /dev/null +++ b/mail_drop_target/views/templates.xml @@ -0,0 +1,11 @@ + + + + + + From e5ded94ef2390d22a0ab80b16321baa295335bf8 Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Tue, 25 Jun 2019 11:17:44 +0200 Subject: [PATCH 02/12] [MIG] mail_drop_target: Migration to 11.0 --- mail_drop_target/__init__.py | 1 - mail_drop_target/__manifest__.py | 8 +- mail_drop_target/models/__init__.py | 1 - mail_drop_target/models/mail_thread.py | 3 +- mail_drop_target/readme/CONTRIBUTORS.rst | 2 + mail_drop_target/readme/DESCRIPTION.rst | 3 + mail_drop_target/readme/ROADMAP.rst | 2 + mail_drop_target/readme/USAGE.rst | 8 ++ .../static/src/js/mail_drop_target.js | 55 +++++++++---- mail_drop_target/tests/__init__.py | 1 + mail_drop_target/tests/sample.eml | 75 ++++++++++++++++++ mail_drop_target/tests/sample.msg | Bin 0 -> 16896 bytes .../tests/test_mail_drop_target.py | 34 ++++++++ 13 files changed, 171 insertions(+), 22 deletions(-) create mode 100644 mail_drop_target/readme/CONTRIBUTORS.rst create mode 100644 mail_drop_target/readme/DESCRIPTION.rst create mode 100644 mail_drop_target/readme/ROADMAP.rst create mode 100644 mail_drop_target/readme/USAGE.rst create mode 100644 mail_drop_target/tests/__init__.py create mode 100644 mail_drop_target/tests/sample.eml create mode 100644 mail_drop_target/tests/sample.msg create mode 100644 mail_drop_target/tests/test_mail_drop_target.py diff --git a/mail_drop_target/__init__.py b/mail_drop_target/__init__.py index 242234495..be8574876 100644 --- a/mail_drop_target/__init__.py +++ b/mail_drop_target/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2018 Therp BV # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import models diff --git a/mail_drop_target/__manifest__.py b/mail_drop_target/__manifest__.py index e36504371..c6140e361 100644 --- a/mail_drop_target/__manifest__.py +++ b/mail_drop_target/__manifest__.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- # Copyright 2018 Therp BV # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { "name": "Drag & drop emails to Odoo", - "version": "10.0.1.0.0", + "version": "11.0.1.0.0", "author": "Therp BV,Odoo Community Association (OCA)", "license": "AGPL-3", "category": "Discuss", @@ -12,6 +11,11 @@ 'mail', 'web_drop_target', ], + "external_dependencies": { + "python": [ + "extract_msg", + ], + }, "data": [ 'views/templates.xml', ], diff --git a/mail_drop_target/models/__init__.py b/mail_drop_target/models/__init__.py index 1211df53d..23c7dbf08 100644 --- a/mail_drop_target/models/__init__.py +++ b/mail_drop_target/models/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2018 Therp BV # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import mail_thread diff --git a/mail_drop_target/models/mail_thread.py b/mail_drop_target/models/mail_thread.py index 392c3dd4f..f85df0627 100644 --- a/mail_drop_target/models/mail_thread.py +++ b/mail_drop_target/models/mail_thread.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- # Copyright 2018 Therp BV # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from base64 import b64decode try: - from ExtractMsg import Message + from extract_msg import Message except ImportError: Message = None from odoo import _, api, exceptions, models diff --git a/mail_drop_target/readme/CONTRIBUTORS.rst b/mail_drop_target/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..3f1842326 --- /dev/null +++ b/mail_drop_target/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Holger Brunn +* Enric Tobella diff --git a/mail_drop_target/readme/DESCRIPTION.rst b/mail_drop_target/readme/DESCRIPTION.rst new file mode 100644 index 000000000..dfd16753e --- /dev/null +++ b/mail_drop_target/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +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 `_ is installed) files. diff --git a/mail_drop_target/readme/ROADMAP.rst b/mail_drop_target/readme/ROADMAP.rst new file mode 100644 index 000000000..6e2dc0854 --- /dev/null +++ b/mail_drop_target/readme/ROADMAP.rst @@ -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 diff --git a/mail_drop_target/readme/USAGE.rst b/mail_drop_target/readme/USAGE.rst new file mode 100644 index 000000000..abc1459eb --- /dev/null +++ b/mail_drop_target/readme/USAGE.rst @@ -0,0 +1,8 @@ +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 + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/205/10.0 diff --git a/mail_drop_target/static/src/js/mail_drop_target.js b/mail_drop_target/static/src/js/mail_drop_target.js index 3a8626ec4..a6d39e5c5 100644 --- a/mail_drop_target/static/src/js/mail_drop_target.js +++ b/mail_drop_target/static/src/js/mail_drop_target.js @@ -4,11 +4,11 @@ odoo.define('mail_drop_target', function(require) { - var Chatter = require('mail.Chatter'), - web_drop_target = require('web_drop_target'), - Model = require('web.Model'); + 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) { @@ -23,32 +23,55 @@ odoo.define('mail_drop_target', function(require) } return this._super.apply(this, arguments); }, - _handle_file_drop: function(drop_file, e) { + + _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')) { + if (drop_file.name.endsWith('.msg')) { mail_processor = 'message_process_msg'; data = base64js.fromByteArray( - new Uint8Array(e.target.result) + new Uint8Array(reader.result) ); } else { mail_processor = 'message_process'; - data = String.fromCharCode.apply( - null, new Uint8Array(e.currentTarget.result) - ); + 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 new Model('mail.thread').call( - mail_processor, - [this.field_manager.dataset.model, data], - { - thread_id: this.field_manager.datarecord.id, + return this._rpc({ + model:'mail.thread', + method:mail_processor, + args: [this.record.model, data], + kwargs: { + thread_id: this.record.data.id, } - ) + }) .then(function() { - return self.field_manager.reload(); + self.trigger_up('reload',{}); }); } }); diff --git a/mail_drop_target/tests/__init__.py b/mail_drop_target/tests/__init__.py new file mode 100644 index 000000000..1dd00d054 --- /dev/null +++ b/mail_drop_target/tests/__init__.py @@ -0,0 +1 @@ +from . import test_mail_drop_target diff --git a/mail_drop_target/tests/sample.eml b/mail_drop_target/tests/sample.eml new file mode 100644 index 000000000..42ffc2caf --- /dev/null +++ b/mail_drop_target/tests/sample.eml @@ -0,0 +1,75 @@ +X-MDAV-Result: clean +X-MDAV-Processed: mail3.creublanca.es, Wed, 26 Jun 2019 18:08:19 +0200 +Return-path: +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" +To: "Enric Tobella" +Subject: Test +MIME-Version: 1.0 +Content-Type: multipart/alternative; boundary="0626-1608-16-03-PART_BREAK" +Message-ID: +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 informacin 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 ratificacin escrita por ambas partes. En caso de su recepcin por error, +rogamos nos lo comunique por igual va, se abstenga de realizar copias del mensaje +o documentos adjuntos, remitirlo o facilitarlo a un tercero, y proceda en su defecto, +a su eliminacin. + +--0626-1608-16-03-PART_BREAK +Content-Type: text/html; charset=iso-8859-1 +Content-Transfer-Encoding: quoted-printable + + +
TEST
+

+
+
+Tanto este mensaje como los documentos que, en su caso, lleve como anexos, = +
+pueden contener informaci=F3n reservada y/o confidencial, destinada exclusi= +vamente
+para el uso del destinatario o la persona responsable de entregarlo al mism= +o,
+estando su uso no autorizado prohibido legalmente.
+Su contenido no constituye un compromiso para Creu Blanca (la empresa remit= +ente)
+salvo ratificaci=F3n escrita por ambas partes. En caso de su recepci=F3n po= +r error,
+rogamos nos lo comunique por igual v=EDa, se abstenga de realizar copias de= +l mensaje
+o documentos adjuntos, remitirlo o facilitarlo a un tercero, y proceda en s= +u defecto,
+a su eliminaci=F3n.
+ + +--0626-1608-16-03-PART_BREAK-- diff --git a/mail_drop_target/tests/sample.msg b/mail_drop_target/tests/sample.msg new file mode 100644 index 0000000000000000000000000000000000000000..0a5ffcd8203e43ab258112d401a89fd138b3d34f GIT binary patch literal 16896 zcmeHO+jCn-8DH5=QzvzLqb+G^wRKxaTHBF)O>F1lI10TaZHV1AfM__9j_ebpbJTN= zoH!vgg|^%Zg+G7?28J0PIt;@LPfY&| zr*n4Cx8MEycK7)7cfY;sFF*d}1Ai48+9RT0d~kh0+}bdn!2P|Zf2R=l;Jy#=!S(Cc zIh+LG_GbGSS>QIQJ^U^mD8xy9vH#ukhG>cr``*Q)cmo9vzZr;pPGMeVSY5TXhkw3d=Uyy zvjwo@rdh{8Da2?Mlt{%#-+_IoWvjMT{m+RJ*#Cr>7cb)Otm0Dz=UB`@qde|hCB>lF zC7N;1K+XUdlq|w;LCq)w+rzAJ$lP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+w?PS}W z|F|{(TR_W}KmBA5Dx344u;#y`3;wJfKv%6De_B1=h5e~Jo1weem2qODe;TU;qaeM> zXVJ$0J3-TyKV!wl|Ks?Q#FjtxvE|QLvC)4VE2C}v<2Yl@pRvNd09!l%Q}1!C$hP|L z0xetpZQ_r7Csh2|`JekETmGz7+!L{FrvDTqu+^V?Gh6<)`tw^{TmIY^+VW?va4*NU znf^NZ?d;DzsV#rTzD@j3cM*Tw58Lu*uDs44wD$ThpziQHGrRSN^~9Ec3b=g#!L~Vn z`}%hmXxZ}TYT7yesXz1IPXD{R;6D!B&h>}ACnm^B8w)`i7 z+d2QJyZ(PAY}P-X`)v8!)gSWb{>Lu=dFI@H{`U2k=UrR=Q^4&U|Cw6++v(4vT-t!G9eqWx+wp5T+jC&5 zcK+f!C0qVn`zp1=BK6l_-tk-W)?Cly?Ucy{a|H?2W@_h8@=lt;F0SqDpF-_FslFz+ zi$4jTw)%eyxI6=}ZO)(Tj~)LWh`uzi6r`YQMJ>Yg)|21d({C~U){@({~2t0VtkuN(FAa9HeWVunA0Zn=(f|Me literal 0 HcmV?d00001 diff --git a/mail_drop_target/tests/test_mail_drop_target.py b/mail_drop_target/tests/test_mail_drop_target.py new file mode 100644 index 000000000..87b1da7d4 --- /dev/null +++ b/mail_drop_target/tests/test_mail_drop_target.py @@ -0,0 +1,34 @@ +from odoo.tests.common import TransactionCase +from odoo import tools +import base64 + + +class TestMailDropTarget(TransactionCase): + def setUp(self): + super().setUp() + self.partner = self.env['res.partner'].create({ + 'name': 'TEST PARTNER' + }) + + 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)) + + 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)) From 3dd2dc9adfc29193d2ef35ab70c9482e328bb2a9 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Thu, 5 Sep 2019 11:57:34 +0200 Subject: [PATCH 03/12] [ADD] test our code without msgextract --- mail_drop_target/tests/test_mail_drop_target.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mail_drop_target/tests/test_mail_drop_target.py b/mail_drop_target/tests/test_mail_drop_target.py index 87b1da7d4..86b0a44e5 100644 --- a/mail_drop_target/tests/test_mail_drop_target.py +++ b/mail_drop_target/tests/test_mail_drop_target.py @@ -1,5 +1,6 @@ from odoo.tests.common import TransactionCase -from odoo import tools +from odoo import addons, exceptions, tools +from mock import patch import base64 @@ -32,3 +33,10 @@ class TestMailDropTarget(TransactionCase): self.partner._name, message, thread_id=self.partner.id) self.partner.refresh() self.assertEqual(comments+1, len(self.partner.message_ids)) + + def test_no_msgextract(self): + with self.assertRaises(exceptions.UserError), patch.object( + addons.mail_drop_target.models.mail_thread, 'Message', + __nonzero__=lambda x: False, + ): + self.test_msg() From cdc7ac8bdbff2299d6c3ba3fb7ac1a35cfabd03f Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Thu, 5 Sep 2019 13:42:08 +0200 Subject: [PATCH 04/12] [IMP] mail_drop_target: Raise a warning when the file has already been imported --- mail_drop_target/models/mail_thread.py | 27 +++++++++++- .../static/src/js/mail_drop_target.js | 41 +++++++++---------- .../tests/test_mail_drop_target.py | 14 +++++-- 3 files changed, 56 insertions(+), 26 deletions(-) diff --git a/mail_drop_target/models/mail_thread.py b/mail_drop_target/models/mail_thread.py index f85df0627..ce2061612 100644 --- a/mail_drop_target/models/mail_thread.py +++ b/mail_drop_target/models/mail_thread.py @@ -11,6 +11,30 @@ 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): + result = self.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, @@ -28,12 +52,13 @@ class MailThread(models.AbstractModel): 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_process( + 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, diff --git a/mail_drop_target/static/src/js/mail_drop_target.js b/mail_drop_target/static/src/js/mail_drop_target.js index a6d39e5c5..0faac4686 100644 --- a/mail_drop_target/static/src/js/mail_drop_target.js +++ b/mail_drop_target/static/src/js/mail_drop_target.js @@ -1,9 +1,9 @@ -//-*- coding: utf-8 -*- -//Copyright 2018 Therp BV -//License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +// -*- coding: utf-8 -*- +// Copyright 2018 Therp BV +// License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -odoo.define('mail_drop_target', function(require) -{ +odoo.define('mail_drop_target', function (require) { + "use strict"; var Chatter = require('mail.Chatter'); var web_drop_target = require('web_drop_target'); @@ -11,12 +11,12 @@ odoo.define('mail_drop_target', function(require) Chatter.include({ _drop_allowed_types: ['message/rfc822'], - _get_drop_item: function(e) { + _get_drop_item: function (e) { var dataTransfer = e.originalEvent.dataTransfer; - if( - dataTransfer.items.length == 1 && - dataTransfer.items[0].type == '' && - dataTransfer.items[0].kind == 'file' + 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]; @@ -24,16 +24,16 @@ odoo.define('mail_drop_target', function(require) return this._super.apply(this, arguments); }, - _handle_drop_items: function(drop_items, e) { + _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) { + _handle_file_drop_proxy: function (item, e) { var self = this; var file = item; - if(!file || !(file instanceof Blob)) { + if (!file || !(file instanceof Blob)) { return; } var reader = new FileReader(); @@ -43,7 +43,7 @@ odoo.define('mail_drop_target', function(require) reader.onerror = self.proxy('_file_reader_error_handler'); reader.readAsArrayBuffer(file); }, - _handle_file_drop: function(drop_file, reader, e) { + _handle_file_drop: function (drop_file, reader, e) { var self = this, mail_processor = '', data = ''; @@ -53,9 +53,9 @@ odoo.define('mail_drop_target', function(require) new Uint8Array(reader.result) ); } else { - mail_processor = 'message_process'; + mail_processor = 'message_drop'; var reader_array = new Uint8Array(reader.result); - data = "" + data = ""; for (var i = 0; i < reader_array.length; i++) { data += String.fromCharCode(parseInt(reader_array[i])); } @@ -68,11 +68,10 @@ odoo.define('mail_drop_target', function(require) args: [this.record.model, data], kwargs: { thread_id: this.record.data.id, - } - }) - .then(function() { - self.trigger_up('reload',{}); + }, + }).then(function() { + self.trigger_up('reload', {}); }); - } + }, }); }); diff --git a/mail_drop_target/tests/test_mail_drop_target.py b/mail_drop_target/tests/test_mail_drop_target.py index 86b0a44e5..979d7d159 100644 --- a/mail_drop_target/tests/test_mail_drop_target.py +++ b/mail_drop_target/tests/test_mail_drop_target.py @@ -1,5 +1,5 @@ from odoo.tests.common import TransactionCase -from odoo import addons, exceptions, tools +from odoo import exceptions, tools from mock import patch import base64 @@ -21,6 +21,9 @@ class TestMailDropTarget(TransactionCase): 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( @@ -33,10 +36,13 @@ class TestMailDropTarget(TransactionCase): 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_process_msg( + self.partner._name, message, thread_id=self.partner.id) def test_no_msgextract(self): - with self.assertRaises(exceptions.UserError), patch.object( - addons.mail_drop_target.models.mail_thread, 'Message', - __nonzero__=lambda x: False, + with self.assertRaises(exceptions.UserError), patch( + 'odoo.addons.mail_drop_target.models.mail_thread.Message', + new=False, ): self.test_msg() From 94b568e3c51c6419cb63e3462ade4e37a41351a7 Mon Sep 17 00:00:00 2001 From: oca-travis Date: Wed, 13 Nov 2019 08:40:44 +0000 Subject: [PATCH 05/12] [UPD] Update mail_drop_target.pot --- mail_drop_target/i18n/mail_drop_target.pot | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 mail_drop_target/i18n/mail_drop_target.pot diff --git a/mail_drop_target/i18n/mail_drop_target.pot b/mail_drop_target/i18n/mail_drop_target.pot new file mode 100644 index 000000000..dfc26f1d2 --- /dev/null +++ b/mail_drop_target/i18n/mail_drop_target.pot @@ -0,0 +1,32 @@ +# 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.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:46 +#, 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:35 +#, python-format +msgid "This message is already imported." +msgstr "" + From a55fd672ed731f8c129fed45342f2113f22bb73f Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Wed, 13 Nov 2019 09:11:24 +0000 Subject: [PATCH 06/12] [UPD] README.rst --- mail_drop_target/README.rst | 68 ++- .../static/description/index.html | 439 ++++++++++++++++++ 2 files changed, 484 insertions(+), 23 deletions(-) create mode 100644 mail_drop_target/static/description/index.html diff --git a/mail_drop_target/README.rst b/mail_drop_target/README.rst index c6dd98c6e..d0ea1a9df 100644 --- a/mail_drop_target/README.rst +++ b/mail_drop_target/README.rst @@ -1,15 +1,39 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :target: https://www.gnu.org/licenses/agpl-3.0-standalone.html - :alt: License: AGPL-3 - ========================== 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/11.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-11-0/social-11-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/11.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 `_ is installed) files. +**Table of contents** + +.. contents:: + :local: + Usage ===== @@ -31,42 +55,40 @@ Known issues / Roadmap 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. +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 ======= -Images ------- +Authors +~~~~~~~ -* Odoo Community Association: `Icon `_. - -Libraries ---------- - -* `msg-extractor `_ +* Therp BV Contributors ------------- +~~~~~~~~~~~~ * Holger Brunn +* Enric Tobella -Do not contact contributors directly about help with questions or problems concerning this addon, but use the `community mailing list `_ or the `appropriate specialized mailinglist `_ for help, and the bug tracker linked in `Bug Tracker`_ above for technical issues. +Maintainers +~~~~~~~~~~~ -Maintainer ----------- +This module is maintained by the OCA. .. 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. +This module is part of the `OCA/social `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mail_drop_target/static/description/index.html b/mail_drop_target/static/description/index.html new file mode 100644 index 000000000..655a1deb3 --- /dev/null +++ b/mail_drop_target/static/description/index.html @@ -0,0 +1,439 @@ + + + + + + +Drag & drop emails to Odoo + + + +
+

Drag & drop emails to Odoo

+ + +

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

+

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 is installed) files.

+

Table of contents

+ +
+

Usage

+

To use this module, you need to:

+
    +
  1. save your emails on the desktop / somewhere in the file system
  2. +
  3. drag them to your browser, and drop them on the chatter of the record you want to attach your email to
  4. +
+Try me on Runbot +
+
+

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

+
    +
  • Therp BV
  • +
+
+
+

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/social project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + From e279a776d5726d5de0fe3004b66697cfcc62417b Mon Sep 17 00:00:00 2001 From: Jordi Ballester Alomar Date: Fri, 22 Nov 2019 12:28:56 +0100 Subject: [PATCH 07/12] adds an option to disable the notification to existing followers on a new email dropped to a record. --- mail_drop_target/__manifest__.py | 1 + mail_drop_target/models/__init__.py | 1 + mail_drop_target/models/mail_thread.py | 9 ++++- .../models/res_config_settings.py | 33 +++++++++++++++++++ mail_drop_target/readme/CONFIGURATION.rst | 3 ++ mail_drop_target/readme/DESCRIPTION.rst | 4 +++ .../tests/test_mail_drop_target.py | 25 ++++++++++++++ .../views/res_config_settings_views.xml | 26 +++++++++++++++ 8 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 mail_drop_target/models/res_config_settings.py create mode 100644 mail_drop_target/readme/CONFIGURATION.rst create mode 100644 mail_drop_target/views/res_config_settings_views.xml diff --git a/mail_drop_target/__manifest__.py b/mail_drop_target/__manifest__.py index c6140e361..cbadf6326 100644 --- a/mail_drop_target/__manifest__.py +++ b/mail_drop_target/__manifest__.py @@ -18,5 +18,6 @@ }, "data": [ 'views/templates.xml', + 'views/res_config_settings_views.xml', ], } diff --git a/mail_drop_target/models/__init__.py b/mail_drop_target/models/__init__.py index 23c7dbf08..f11e7bf03 100644 --- a/mail_drop_target/models/__init__.py +++ b/mail_drop_target/models/__init__.py @@ -1,3 +1,4 @@ # Copyright 2018 Therp BV # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import mail_thread +from . import res_config_settings diff --git a/mail_drop_target/models/mail_thread.py b/mail_drop_target/models/mail_thread.py index ce2061612..a3a8789dc 100644 --- a/mail_drop_target/models/mail_thread.py +++ b/mail_drop_target/models/mail_thread.py @@ -15,7 +15,14 @@ class MailThread(models.AbstractModel): def message_drop(self, model, message, custom_values=None, save_original=False, strip_attachments=False, thread_id=None): - result = self.message_process( + disable_notify_mail_drop_target = \ + self.env["ir.config_parameter"].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 diff --git a/mail_drop_target/models/res_config_settings.py b/mail_drop_target/models/res_config_settings.py new file mode 100644 index 000000000..2c6e9b941 --- /dev/null +++ b/mail_drop_target/models/res_config_settings.py @@ -0,0 +1,33 @@ +# Copyright 2019 Eficent Business and IT Consulting Services, S.L. +# +# 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 '') diff --git a/mail_drop_target/readme/CONFIGURATION.rst b/mail_drop_target/readme/CONFIGURATION.rst new file mode 100644 index 000000000..79e2eb7b3 --- /dev/null +++ b/mail_drop_target/readme/CONFIGURATION.rst @@ -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'. diff --git a/mail_drop_target/readme/DESCRIPTION.rst b/mail_drop_target/readme/DESCRIPTION.rst index dfd16753e..c017ccdff 100644 --- a/mail_drop_target/readme/DESCRIPTION.rst +++ b/mail_drop_target/readme/DESCRIPTION.rst @@ -1,3 +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 `_ 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. diff --git a/mail_drop_target/tests/test_mail_drop_target.py b/mail_drop_target/tests/test_mail_drop_target.py index 979d7d159..d49330ef8 100644 --- a/mail_drop_target/tests/test_mail_drop_target.py +++ b/mail_drop_target/tests/test_mail_drop_target.py @@ -10,6 +10,7 @@ class TestMailDropTarget(TransactionCase): 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( @@ -36,6 +37,9 @@ class TestMailDropTarget(TransactionCase): 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) @@ -46,3 +50,24 @@ class TestMailDropTarget(TransactionCase): 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) diff --git a/mail_drop_target/views/res_config_settings_views.xml b/mail_drop_target/views/res_config_settings_views.xml new file mode 100644 index 000000000..e4a04dbe2 --- /dev/null +++ b/mail_drop_target/views/res_config_settings_views.xml @@ -0,0 +1,26 @@ + + + + + res.config.settings.view.form.inherit.mail + res.config.settings + + +
+
+
+ +
+
+
+
+
+
+
+
+
From 1ab88b72e9799af1dc07fed3aa9655693523a597 Mon Sep 17 00:00:00 2001 From: oca-travis Date: Tue, 10 Dec 2019 21:15:52 +0000 Subject: [PATCH 08/12] [UPD] Update mail_drop_target.pot --- mail_drop_target/i18n/mail_drop_target.pot | 30 ++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/mail_drop_target/i18n/mail_drop_target.pot b/mail_drop_target/i18n/mail_drop_target.pot index dfc26f1d2..793f27ba0 100644 --- a/mail_drop_target/i18n/mail_drop_target.pot +++ b/mail_drop_target/i18n/mail_drop_target.pot @@ -13,20 +13,46 @@ msgstr "" "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:46 +#: 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:35 +#: 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 "" + From 3c9b2268da6918433245d0d92da457cba4841fd2 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Tue, 10 Dec 2019 21:23:48 +0000 Subject: [PATCH 09/12] [UPD] README.rst --- mail_drop_target/README.rst | 4 ++++ mail_drop_target/static/description/index.html | 3 +++ 2 files changed, 7 insertions(+) diff --git a/mail_drop_target/README.rst b/mail_drop_target/README.rst index d0ea1a9df..426774968 100644 --- a/mail_drop_target/README.rst +++ b/mail_drop_target/README.rst @@ -29,6 +29,10 @@ This module was written to allow users to drag&drop emails from their desktop to It supports as well RFC822 .eml files as Outlook .msg (those only if `an extra library `_ 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:: diff --git a/mail_drop_target/static/description/index.html b/mail_drop_target/static/description/index.html index 655a1deb3..bb4c743ce 100644 --- a/mail_drop_target/static/description/index.html +++ b/mail_drop_target/static/description/index.html @@ -370,6 +370,9 @@ ul.auto-toc {

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

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

    From d4f72d0aa79d341a4a82391861851ed278b1d951 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Tue, 10 Dec 2019 21:23:49 +0000 Subject: [PATCH 10/12] mail_drop_target 11.0.1.1.0 --- mail_drop_target/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mail_drop_target/__manifest__.py b/mail_drop_target/__manifest__.py index cbadf6326..83d62ee8b 100644 --- a/mail_drop_target/__manifest__.py +++ b/mail_drop_target/__manifest__.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { "name": "Drag & drop emails to Odoo", - "version": "11.0.1.0.0", + "version": "11.0.1.1.0", "author": "Therp BV,Odoo Community Association (OCA)", "license": "AGPL-3", "category": "Discuss", From a544c27bc50be55591251dd30eda297d9952a88c Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Mon, 20 Jan 2020 17:23:33 +0100 Subject: [PATCH 11/12] [11.0][FIX] mail_drop_target: Add sudo on config_param --- mail_drop_target/models/mail_thread.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mail_drop_target/models/mail_thread.py b/mail_drop_target/models/mail_thread.py index a3a8789dc..0c674baf7 100644 --- a/mail_drop_target/models/mail_thread.py +++ b/mail_drop_target/models/mail_thread.py @@ -16,7 +16,7 @@ class MailThread(models.AbstractModel): save_original=False, strip_attachments=False, thread_id=None): disable_notify_mail_drop_target = \ - self.env["ir.config_parameter"].get_param( + 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: From ae6f2726ee782cdce33ae0b6f5002f5258be0740 Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Wed, 19 Feb 2020 18:14:46 +0100 Subject: [PATCH 12/12] [12.0][MIG] mail_drop_target --- mail_drop_target/README.rst | 14 +++++--------- mail_drop_target/__manifest__.py | 2 +- mail_drop_target/models/__init__.py | 1 + mail_drop_target/models/mail_message.py | 18 ++++++++++++++++++ mail_drop_target/readme/USAGE.rst | 4 ---- mail_drop_target/static/description/index.html | 9 ++++----- oca_dependencies.txt | 1 + requirements.txt | 1 + 8 files changed, 31 insertions(+), 19 deletions(-) create mode 100644 mail_drop_target/models/mail_message.py diff --git a/mail_drop_target/README.rst b/mail_drop_target/README.rst index 426774968..b112d6f01 100644 --- a/mail_drop_target/README.rst +++ b/mail_drop_target/README.rst @@ -14,13 +14,13 @@ Drag & drop emails to Odoo :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/11.0/mail_drop_target + :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-11-0/social-11-0-mail_drop_target + :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/11.0 + :target: https://runbot.odoo-community.org/runbot/205/12.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -46,10 +46,6 @@ 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 -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/205/10.0 - Known issues / Roadmap ====================== @@ -62,7 +58,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. @@ -93,6 +89,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/social `_ project on GitHub. +This module is part of the `OCA/social `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mail_drop_target/__manifest__.py b/mail_drop_target/__manifest__.py index 83d62ee8b..55ec4b44c 100644 --- a/mail_drop_target/__manifest__.py +++ b/mail_drop_target/__manifest__.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { "name": "Drag & drop emails to Odoo", - "version": "11.0.1.1.0", + "version": "12.0.1.1.0", "author": "Therp BV,Odoo Community Association (OCA)", "license": "AGPL-3", "category": "Discuss", diff --git a/mail_drop_target/models/__init__.py b/mail_drop_target/models/__init__.py index f11e7bf03..53c591e4f 100644 --- a/mail_drop_target/models/__init__.py +++ b/mail_drop_target/models/__init__.py @@ -1,4 +1,5 @@ # Copyright 2018 Therp BV # 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 diff --git a/mail_drop_target/models/mail_message.py b/mail_drop_target/models/mail_message.py new file mode 100644 index 000000000..1a9612255 --- /dev/null +++ b/mail_drop_target/models/mail_message.py @@ -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) diff --git a/mail_drop_target/readme/USAGE.rst b/mail_drop_target/readme/USAGE.rst index abc1459eb..080e2b51f 100644 --- a/mail_drop_target/readme/USAGE.rst +++ b/mail_drop_target/readme/USAGE.rst @@ -2,7 +2,3 @@ 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 - -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/205/10.0 diff --git a/mail_drop_target/static/description/index.html b/mail_drop_target/static/description/index.html index bb4c743ce..0ef163bb5 100644 --- a/mail_drop_target/static/description/index.html +++ b/mail_drop_target/static/description/index.html @@ -3,7 +3,7 @@ - + Drag & drop emails to Odoo