Browse Source

[MIG] mail_drop_target: Migration to 11.0

pull/403/head
Enric Tobella 5 years ago
parent
commit
9df00078db
  1. 1
      .travis.yml
  2. 1
      mail_drop_target/__init__.py
  3. 3
      mail_drop_target/__manifest__.py
  4. 1
      mail_drop_target/models/__init__.py
  5. 1
      mail_drop_target/models/mail_thread.py
  6. 2
      mail_drop_target/readme/CONTRIBUTORS.rst
  7. 3
      mail_drop_target/readme/DESCRIPTION.rst
  8. 2
      mail_drop_target/readme/ROADMAP.rst
  9. 8
      mail_drop_target/readme/USAGE.rst
  10. 55
      mail_drop_target/static/src/js/mail_drop_target.js
  11. 1
      oca_dependencies.txt

1
.travis.yml

@ -27,6 +27,7 @@ env:
install:
- pip install https://github.com/mattgwwalker/msg-extractor/tarball/master
- git clone --depth=1 https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools
- export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}
- travis_install_nightly

1
mail_drop_target/__init__.py

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

3
mail_drop_target/__manifest__.py

@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
# 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": "10.0.1.0.0",
"version": "11.0.1.0.0",
"author": "Therp BV,Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Discuss",

1
mail_drop_target/models/__init__.py

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

1
mail_drop_target/models/mail_thread.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Therp BV <https://therp.nl>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from base64 import b64decode

2
mail_drop_target/readme/CONTRIBUTORS.rst

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

3
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 <https://github.com/mattgwwalker/msg-extractor>`_ is installed) files.

2
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

8
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

55
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',{});
});
}
});

1
oca_dependencies.txt

@ -1 +1,2 @@
server-tools
web
Loading…
Cancel
Save