From 507b43cedf52efae1ac058e27d2e017a5e7762b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 29 Jun 2012 17:27:58 +0200 Subject: [PATCH] [IMP] mail.message: can now have void subjects. Void subjects are not displayed in chatter/wall; this allows to have a more flexible way to display blog post, while avoiding to display unnecessary data for notifications or quick replies. This imply that a way to manually add a subject when posting a comment is required; this will be done in openchatter part3. bzr revid: tde@openerp.com-20120629152758-9t23sdvtpdd49yyd --- addons/mail/mail_message.py | 17 +++++++++++++++-- addons/mail/mail_thread.py | 9 ++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 1c1e980e3ed..301657ba4c2 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -96,11 +96,24 @@ class mail_message_common(osv.osv_memory): continue result[message.id] = self.pool.get(message.model).name_get(cr, uid, [message.res_id], context=context)[0][1] return result - + + def name_get(self, cr, uid, ids, context=None): + res = [] + for message in self.browse(cr, uid, ids, context=context): + name = '' + if message.subject: + name = '%s: ' % (message.subject) + if message.body_text: + name = '%s%s ' % (name, message.body_text[0:20]) + if message.date: + name = '%s(%s)' % (name, message.date) + res.append((message.id, name)) + return res + _name = 'mail.message.common' _rec_name = 'subject' _columns = { - 'subject': fields.char('Subject', size=512, required=True), + 'subject': fields.char('Subject', size=512), 'model': fields.char('Related Document Model', size=128, select=1), 'res_id': fields.integer('Related Document ID', select=1), 'record_name': fields.function(get_record_name, type='string', string='Message Record Name', diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index e0f2bfaf455..d0af1ed8841 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -746,13 +746,8 @@ class mail_thread(osv.osv): self.message_append_note(cr, uid, [id], 'res.log', message, context=context) def message_append_note(self, cr, uid, ids, subject=None, body=None, parent_id=False, type='notification', subtype='html', context=None): - if subject is None: - if type == 'notification': - subject = _('System notification') - elif type == 'comment' and not parent_id: - subject = _('Comment') - elif type == 'comment' and parent_id: - subject = _('Reply') + if type in ['notification', 'reply']: + subject = None if subtype == 'html': body_html = body body_text = body