From 83b2e473f9446ab1cb1e1a500b112e8d14a78eaa Mon Sep 17 00:00:00 2001 From: ufaks Date: Wed, 30 Sep 2015 11:57:53 +0500 Subject: [PATCH] [REF] Apply remarks --- README.rst | 2 ++ __init__.py | 0 __openerp__.py | 12 +++++++++ mail_todo_custom.xml | 25 ++++++++++++++++++ static/src/js/mail_todo_custom.js | 44 +++++++++++++++++++++++++++++++ 5 files changed, 83 insertions(+) create mode 100644 README.rst create mode 100644 __init__.py create mode 100644 __openerp__.py create mode 100644 mail_todo_custom.xml create mode 100644 static/src/js/mail_todo_custom.js diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..56b440e --- /dev/null +++ b/README.rst @@ -0,0 +1,2 @@ +Mark unstarred email as read, remove filter in 'To-do' folder +============================================================= diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/__openerp__.py b/__openerp__.py new file mode 100644 index 0000000..34e8357 --- /dev/null +++ b/__openerp__.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +{ + 'name': "Mark unstarred email as read, remove filter in 'To-do' folder", + 'version': '1.0', + 'author': "Ivan Yelizariev", + 'website': "https://yelizariev.github.io", + 'category': 'Tools', + 'depends': ['mail'], + 'data': ['mail_todo_custom.xml'], + 'demo': [], + 'installable': True, +} diff --git a/mail_todo_custom.xml b/mail_todo_custom.xml new file mode 100644 index 0000000..8274d61 --- /dev/null +++ b/mail_todo_custom.xml @@ -0,0 +1,25 @@ + + + + + + + + + { + 'default_model': 'res.users', + 'default_res_id': uid, + 'thread_model': 'res.partner', + 'search_default_message_unread': False, + 'view_todo': True + } + + + + + + diff --git a/static/src/js/mail_todo_custom.js b/static/src/js/mail_todo_custom.js new file mode 100644 index 0000000..4d45c0b --- /dev/null +++ b/static/src/js/mail_todo_custom.js @@ -0,0 +1,44 @@ +openerp.mail_todo_custom = function(session) { + + var mail = session.mail; + + mail.ThreadMessage.include({ + + on_star: function (event) { + event.stopPropagation(); + var self=this; + var button = self.$('.oe_star:first'); + + this.ds_message.call('set_message_starred', [[self.id], !self.is_favorite, true]) + .then(function (star) { + self.is_favorite=star; + if (self.is_favorite) { + button.addClass('oe_starred'); + } else { + button.removeClass('oe_starred'); + } + + if (self.options.view_inbox && self.is_favorite) { + self.on_message_read_unread(true); + } + else { + self.check_for_rerender(); + } + if (self.options.view_todo && !self.is_favorite) { + self.on_message_read_unread(true); + } + }); + return false; + }, + + }); + + mail.Widget.include({ + + init: function (parent, action) { + this._super(parent, action); + this.action.params.view_todo = this.action.context.view_todo || false; + }, + + }); +} \ No newline at end of file