diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index ef741e31783..f8d1f6d1e6c 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -74,10 +74,11 @@ class mail_message(osv.Model): notif_obj = self.pool.get('mail.notification') notif_ids = notif_obj.search(cr, uid, [ ('partner_id', 'in', [partner_id]), - ('message_id', 'in', ids) + ('message_id', 'in', ids), + ('read', '=', True) ], context=context) for notif in notif_obj.browse(cr, uid, notif_ids, context=context): - res[notif.message_id.id] = notif.read and 'read' or 'unread' + res[notif.message_id.id] = not notif.read return res def _search_read(self, cr, uid, obj, name, domain, context=None): @@ -126,7 +127,7 @@ class mail_message(osv.Model): 'date': fields.datetime('Date'), 'message_id': fields.char('Message-Id', help='Message unique identifier', select=1, readonly=1), 'body': fields.html('Contents', help='Automatically sanitized HTML contents'), - 'read': fields.function(_get_read, fnct_search=_search_read, + 'to_read': fields.function(_get_read, fnct_search=_search_read, type='boolean', string='Read', help='Functional field to search for read messages linked to uid'), 'subtype_id': fields.many2one('mail.message.subtype', 'Subtype'), @@ -139,7 +140,7 @@ class mail_message(osv.Model): def _needaction_domain_get(self, cr, uid, context=None): if self._needaction: - return [('read', '=', 'unread')] + return [('to_read', '=', True)] return [] def _get_default_author(self, cr, uid, context=None): @@ -252,7 +253,7 @@ class mail_message(osv.Model): 'vote_user_ids': vote_ids, 'has_voted': has_voted, 'has_stared': has_stared, - 'read': msg.read + 'to_read': msg.to_read } def _message_read_expandable(self, cr, uid, tree, result, message_loaded_ids, domain, context, parent_id, limit): diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index a0fb1deec55..094970156df 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -685,7 +685,6 @@ class mail_thread(osv.AbstractModel): values["is_private"] = msg.is_private or False values["partner_ids"] = [(4, partner.id) for partner in msg.partner_ids] + [(4, msg.author_id.id)] - print values # Avoid warnings about non-existing fields for x in ('from', 'to', 'cc'): values.pop(x, None) @@ -709,10 +708,10 @@ class mail_thread(osv.AbstractModel): attachment_ids=[] if attachments: ir_attachment = self.pool.get('ir.attachment') - attachment_ids = ir_attachment.search(cr, 1, [('res_model', '=', False), ('res_id', '=', False), ('user_id', '=', uid), ('id', 'in', attachments)], context=context) + attachment_ids = ir_attachment.search(cr, SUPERUSER_ID, [('res_model', '=', 'mail.message'), ('res_id', '=', 0), ('create_uid', '=', uid), ('id', 'in', attachments)], context=context) if attachment_ids: - self.pool.get('ir.attachment').write(cr, 1, attachment_ids, { 'res_model': self._name, 'res_id': thread_id }, context=context) - self.pool.get('mail.message').write(cr, 1, [added_message_id], {'attachment_ids': [(6, 0, [pid for pid in attachment_ids])]} ) + self.pool.get('ir.attachment').write(cr, SUPERUSER_ID, attachment_ids, { 'res_model': self._name, 'res_id': thread_id }, context=context) + self.pool.get('mail.message').write(cr, SUPERUSER_ID, [added_message_id], {'attachment_ids': [(6, 0, [pid for pid in attachment_ids])]} ) added_message = self.pool.get('mail.message').message_read(cr, uid, [added_message_id]) return added_message diff --git a/addons/mail/mail_thread_view.xml b/addons/mail/mail_thread_view.xml index 2d7cf2ecf58..fed0cdde9e3 100644 --- a/addons/mail/mail_thread_view.xml +++ b/addons/mail/mail_thread_view.xml @@ -16,7 +16,7 @@ - Stared + Favorites mail.wall @@ -61,7 +61,7 @@ - Stared + Favorites diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 83f234f3d33..5e4e4d7d689 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -213,7 +213,7 @@ openerp.mail = function(session) { on_attachment_loaded: function (event, result) { //session.web.unblockUI(); for(var i in this.datasets.attachment_ids){ - if(this.datasets.attachment_ids[i].filename == result.filename && this.datasets.attachment_ids[i].upload){ + if(this.datasets.attachment_ids[i].filename == result.filename && this.datasets.attachment_ids[i].upload) { this.datasets.attachment_ids[i]={ 'id': result.id, 'name': result.name, @@ -503,7 +503,7 @@ openerp.mail = function(session) { 'has_voted' : false, 'has_stared' : false, 'thread_level' : 0, - 'read' : false, + 'to_read' : true, 'author_id' : [], 'attachment_ids' : [], }, param || {}); @@ -530,13 +530,13 @@ openerp.mail = function(session) { } }; - this.datasets.show_reply = this.options.message.show_reply[0]<=0 && - this.options.message.show_reply[0]>=this.datasets.thread_level && - (this.options.message.show_reply[1]<0 || this.options.message.show_reply[1]<=this.datasets.thread_level); + this.datasets.show_reply = this.options.message.show_reply[0]>=0 && + this.options.message.show_reply[0]<=this.datasets.thread_level && + (this.options.message.show_reply[1]<0 || this.options.message.show_reply[1]>=this.datasets.thread_level); - this.datasets.show_read_unread = this.options.message.show_read_unread[0]<=0 && - this.options.message.show_read_unread[0]>=this.datasets.thread_level && - (this.options.message.show_read_unread[1]<0 || this.options.message.show_read_unread[1]<=this.datasets.thread_level); + this.datasets.show_read_unread = this.options.message.show_read_unread[0]>=0 && + this.options.message.show_read_unread[0]<=this.datasets.thread_level && + (this.options.message.show_read_unread[1]<0 || this.options.message.show_read_unread[1]>=this.datasets.thread_level); // record options and data this.parent_thread= parent.messages!= undefined ? parent : options.options.thread._parents[0]; @@ -1363,7 +1363,7 @@ openerp.mail = function(session) { }, 'message': { 'show_reply': [0,0], - 'show_read_unread': [0,0], + 'show_read_unread': [0,-1], 'show_dd_delete': false, }, }, diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml index a225fcc7f63..7ddf5e3743b 100644 --- a/addons/mail/static/src/xml/mail.xml +++ b/addons/mail/static/src/xml/mail.xml @@ -42,7 +42,7 @@ /web/binary/upload_attachment - + @@ -60,7 +60,7 @@ - ...wait upload... + ...Upload in progress... @@ -180,7 +180,7 @@ - +