diff --git a/mail_archives/README.rst b/mail_archives/README.rst index 3b2d013..56bd506 100644 --- a/mail_archives/README.rst +++ b/mail_archives/README.rst @@ -5,7 +5,7 @@ Adds Archive menu, which shows all messages Usage ----- -Click Messaing/Arhive menu -- all messages are displayed +Click Discuss/Archive menu -- all messages are displayed Further information ------------------- diff --git a/mail_archives/__openerp__.py b/mail_archives/__openerp__.py index 8ecce36..e27a813 100644 --- a/mail_archives/__openerp__.py +++ b/mail_archives/__openerp__.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- { "name": "mail_archives", - "summary": """Create archive channel""", - "category": "Uncategorized", + "summary": """Adds menu to find old messages""", + "category": "Discuss", "images": [], "version": "1.0.0", diff --git a/mail_base/static/src/js/base.js b/mail_base/static/src/js/base.js index dee2ae8..dbc5fa2 100644 --- a/mail_base/static/src/js/base.js +++ b/mail_base/static/src/js/base.js @@ -160,9 +160,9 @@ var MailTools = core.Class.extend({ _.each(msg.channel_ids, function (channel_id) { var channel = chat_manager.get_channel(channel_id); if (channel) { - cls.add_to_cache(msg, []); + chat_manager.mail_tools.add_to_cache(msg, []); if (options.domain && options.domain !== []) { - cls.add_to_cache(msg, options.domain); + chat_manager.mail_tools.add_to_cache(msg, options.domain); } if (channel.hidden) { channel.hidden = false; @@ -412,7 +412,7 @@ var MailTools = core.Class.extend({ _.each(message.channel_ids, function (channel_id) { var channel = chat_manager.get_channel(channel_id); if (channel) { - var channel_cache = cls.get_channel_cache(channel, domain); + var channel_cache = chat_manager.mail_tools.get_channel_cache(channel, domain); var index = _.sortedIndex(channel_cache.messages, message, 'id'); if (channel_cache.messages[index] !== message) { channel_cache.messages.splice(index, 0, message); @@ -586,12 +586,12 @@ var MailTools = core.Class.extend({ _.each(data.message_ids, function (msg_id) { var message = _.findWhere(messages, { id: msg_id }); if (message) { - cls.invalidate_caches(message.channel_ids); + chat_manager.mail_tools.invalidate_caches(message.channel_ids); message.is_starred = data.starred; if (!message.is_starred) { - cls.remove_message_from_channel("channel_starred", message); + chat_manager.mail_tools.remove_message_from_channel("channel_starred", message); } else { - cls.add_to_cache(message, []); + chat_manager.mail_tools.add_to_cache(message, []); var channel_starred = chat_manager.get_channel('channel_starred'); channel_starred.cache = _.pick(channel_starred.cache, "[]"); } diff --git a/mail_sent/README.rst b/mail_sent/README.rst index 2b0336f..aded732 100644 --- a/mail_sent/README.rst +++ b/mail_sent/README.rst @@ -1,8 +1,16 @@ Sentbox ======= -Description: https://apps.odoo.com/apps/modules/8.0/mail_sent/ +Adds Sent menu, which shows sent messages +Usage +----- +Click Discuss/Sent menu -- sent messages are displayed + +Further information +------------------- Further information and discussion: https://yelizariev.github.io/odoo/module/2015/02/19/sentbox.html -Tested on Odoo 8.0 231e02693640325c9a05fa31c680063b9e4b017b +HTML Description: https://apps.odoo.com/apps/modules/9.0/mail_sent/ + +Tested on Odoo 9.0 b9f206953e3f877adf18643f154d1262842564ee diff --git a/mail_sent/__init__.py b/mail_sent/__init__.py index bff786c..c7b5ac7 100644 --- a/mail_sent/__init__.py +++ b/mail_sent/__init__.py @@ -1 +1,3 @@ +# -*- coding: utf-8 -*- + import models diff --git a/mail_sent/__openerp__.py b/mail_sent/__openerp__.py index 7027e83..2390dc7 100644 --- a/mail_sent/__openerp__.py +++ b/mail_sent/__openerp__.py @@ -1,15 +1,28 @@ +# -*- coding: utf-8 -*- { - 'name' : 'Sentbox', - 'version' : '1.0.2', - 'author' : 'IT-Projects LLC, Ivan Yelizariev', - 'license': 'LGPL-3', - 'category' : 'Social Network', - 'website' : 'https://twitter.com/yelizariev', + "name": "Sentbox", + "summary": """Quick way to find sent messages""", + "category": "Discuss", + "images": [], + "version": "1.0.3", + + "author": "IT-Projects LLC, Ivan Yelizariev, Pavel Romanchenko", + "website": "https://it-projects.info", + "license": "LGPL-3", 'price': 9.00, 'currency': 'EUR', - 'depends' : ['mail'], - 'data':[ - 'views.xml', - ], - 'installable': False + + "depends": [ + "base", + "mail", + "mail_base" + ], + + "data": [ + "views/templates.xml", + ], + "qweb": [ + "static/src/xml/menu.xml", + ], + 'installable': True, } diff --git a/mail_sent/models.py b/mail_sent/models.py index 38c82e9..a77c2ae 100644 --- a/mail_sent/models.py +++ b/mail_sent/models.py @@ -1,28 +1,32 @@ +# -*- coding: utf-8 -*- from openerp import api, models, fields -class mail_message(models.Model): +class MailMessage(models.Model): _inherit = 'mail.message' + sent = fields.Boolean('Sent', compute="_get_sent", help='Was message sent to someone', store=True) + @api.one - @api.depends('author_id', 'notified_partner_ids') + @api.depends('author_id', 'needaction_partner_ids') def _get_sent(self): self_sudo = self.sudo() - self_sudo.sent = len(self_sudo.notified_partner_ids) > 1 or len(self_sudo.notified_partner_ids) == 1 and self_sudo.author_id and self_sudo.notified_partner_ids[0].id != self_sudo.author_id.id - - sent = fields.Boolean('Sent', compute=_get_sent, help='Was message sent to someone', store=True) - - -class mail_notification(models.Model): - _inherit = 'mail.notification' - - def _notify(self, cr, uid, message_id, **kwargs): - super(mail_notification, self)._notify(cr, uid, message_id, **kwargs) - self.pool['mail.message'].browse(cr, uid, message_id)._get_sent() - - -class mail_compose_message(models.TransientModel): - + self_sudo.sent = len(self_sudo.needaction_partner_ids) > 1 \ + or len(self_sudo.needaction_partner_ids) == 1 \ + and self_sudo.author_id \ + and self_sudo.needaction_partner_ids[0].id != self_sudo.author_id.id + + @api.multi + def message_format(self): + message_values = super(MailMessage, self).message_format() + message_index = {message['id']: message for message in message_values} + for item in self: + msg = message_index.get(item.id) + if msg: + msg['sent'] = item.sent + return message_values + + +class MailComposeMessage(models.TransientModel): _inherit = 'mail.compose.message' sent = fields.Boolean('Sent', help='dummy field to fix inherit error') - diff --git a/mail_sent/static/description/menu.png b/mail_sent/static/description/menu.png index 9c7664c..926661c 100644 Binary files a/mail_sent/static/description/menu.png and b/mail_sent/static/description/menu.png differ diff --git a/mail_sent/static/description/messages.png b/mail_sent/static/description/messages.png index 97d1d9d..c1bf159 100644 Binary files a/mail_sent/static/description/messages.png and b/mail_sent/static/description/messages.png differ diff --git a/mail_sent/static/src/js/sent.js b/mail_sent/static/src/js/sent.js new file mode 100644 index 0000000..e253f29 --- /dev/null +++ b/mail_sent/static/src/js/sent.js @@ -0,0 +1,61 @@ +odoo.define('mail_sent.sent', function (require) { +"use strict"; + +var base_obj = require('mail_base.base'); + +//------------------------------------------------------------------------------- +var bus = require('bus.bus').bus; +var config = require('web.config'); +var core = require('web.core'); +var data = require('web.data'); +var Model = require('web.Model'); +var session = require('web.session'); +var time = require('web.time'); +var web_client = require('web.web_client'); + +var _t = core._t; +//------------------------------------------------------------------------------- + +// Inherit class and override methods +base_obj.MailTools.include({ + get_properties: function(msg){ + var properties = this._super.apply(this, arguments); + properties.is_sent = this.property_descr("channel_sent", msg, this); + return properties; + }, + + set_channel_flags: function(data, msg){ + this._super.apply(this, arguments); + if (data.sent && data.author_id[0] == session.partner_id) { + msg.is_sent = true; + } + return msg; + }, + + get_channel_array: function(msg){ + var arr = this._super.apply(this, arguments); + return arr.concat('channel_sent'); + }, + + get_domain: function(channel){ + return (channel.id === "channel_sent") ? [ + ['sent', '=', true], + ['author_id.user_ids', 'in', [openerp.session.uid]] + ] : this._super.apply(this, arguments); + } +}); + +base_obj.chat_manager.is_ready.then(function(){ + // Add sent channel + base_obj.chat_manager.mail_tools.add_channel({ + id: "channel_sent", + name: _t("Sent"), + type: "static" + }); + + return $.when(); + }); + +return base_obj.chat_manager; + +}); diff --git a/mail_sent/static/src/xml/menu.xml b/mail_sent/static/src/xml/menu.xml new file mode 100644 index 0000000..de92e3a --- /dev/null +++ b/mail_sent/static/src/xml/menu.xml @@ -0,0 +1,20 @@ + + diff --git a/mail_sent/views.xml b/mail_sent/views.xml deleted file mode 100644 index 804d323..0000000 --- a/mail_sent/views.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - Sent - mail.wall - { - 'default_model': 'res.users', - 'default_res_id': uid, - 'thread_model': 'res.partner', - 'needaction_menu_ref': ['mail.mail_tomefeeds', 'mail.mail_starfeeds', 'mail.mail_inboxfeeds'] - } - - -

- No message found and no message sent yet. -

- Click on the top-right icon to compose a message. This - message will be sent by email if it's an internal contact. -

-
-
- - - Sent - - - - -
-
diff --git a/mail_sent/views/templates.xml b/mail_sent/views/templates.xml new file mode 100644 index 0000000..3e685e0 --- /dev/null +++ b/mail_sent/views/templates.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file