diff --git a/mail_todo_custom/README.rst b/mail_todo_custom/README.rst new file mode 100644 index 0000000..56b440e --- /dev/null +++ b/mail_todo_custom/README.rst @@ -0,0 +1,2 @@ +Mark unstarred email as read, remove filter in 'To-do' folder +============================================================= diff --git a/mail_todo_custom/__init__.py b/mail_todo_custom/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/mail_todo_custom/__openerp__.py b/mail_todo_custom/__openerp__.py new file mode 100644 index 0000000..0d295e0 --- /dev/null +++ b/mail_todo_custom/__openerp__.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- +{ + 'name': "Mark unstarred email as read, remove filter in 'To-do' folder", + 'version': '1.0', + 'author': 'IT-Projects LLC', + 'license': 'GPL-3', + 'website': "https://yelizariev.github.io", + 'category': 'Tools', + 'depends': ['mail'], + 'data': ['mail_todo_custom.xml'], + 'demo': [], + 'installable': True, +} diff --git a/mail_todo_custom/mail_todo_custom.xml b/mail_todo_custom/mail_todo_custom.xml new file mode 100644 index 0000000..8274d61 --- /dev/null +++ b/mail_todo_custom/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/mail_todo_custom/static/src/js/mail_todo_custom.js b/mail_todo_custom/static/src/js/mail_todo_custom.js new file mode 100644 index 0000000..4d45c0b --- /dev/null +++ b/mail_todo_custom/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