From 2ff3c1eb1dfbace5e3c02215cd40c95eca79d5e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 2 Apr 2012 18:06:04 +0200 Subject: [PATCH 1/2] [IMP] mail.thread: Small improvement in message_append_note, to avoid adding subject everywhere in addons. Backward compatible with old formatting to ease the forthcoming merge process :) bzr revid: tde@openerp.com-20120402160604-i5ac9sxpuijyvc79 --- addons/mail/mail_thread.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 6d91e126400..03045eda15b 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -667,7 +667,14 @@ class mail_thread(osv.osv): subject = _('Reply on %s at %s') % (self._name, fields.datetime.now()) return self.message_append(cr, uid, ids, subject, body_text=body, parent_id=parent_id, type=type, context=context) - def message_append_note(self, cr, uid, ids, subject, body, parent_id=False, type='notification', context=None): + 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') return self.message_append(cr, uid, ids, subject, body_text=body, parent_id=parent_id, type=type, context=context) #------------------------------------------------------ From 506fd1459b011f8178f09246cd13546d2a2f6e31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 2 Apr 2012 18:24:25 +0200 Subject: [PATCH 2/2] [IMP] Type back to mail.message instead of mail.common bzr revid: tde@openerp.com-20120402162425-207jpzsz28nhrhou --- addons/mail/mail_message.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 5ac146066cf..371565872b2 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -123,15 +123,9 @@ class mail_message_common(osv.osv_memory): help="Content of the message. This content equals the body_text field for plain-test messages, and body_html for rich-text/HTML messages. This allows having one field if we want to access the content matching the message subtype."), 'parent_id': fields.many2one('mail.message', 'Parent message', help="Parent message, used for displaying as threads with hierarchy", select=True, ondelete='set null',), - 'type': fields.selection([ - ('email', 'e-mail'), - ('comment', 'Comment'), - ('notification', 'System notification'), - ], 'Type', help="Message type: e-mail for e-mail message, notification for system message, comment for other messages such as user replies"), } _defaults = { - 'type': 'comment', 'subtype': 'plain', 'date': (lambda *a: fields.datetime.now()), } @@ -206,6 +200,11 @@ class mail_message(osv.osv): return result _columns = { + 'type': fields.selection([ + ('email', 'e-mail'), + ('comment', 'Comment'), + ('notification', 'System notification'), + ], 'Type', help="Message type: e-mail for e-mail message, notification for system message, comment for other messages such as user replies"), 'partner_id': fields.many2one('res.partner', 'Related partner'), 'user_id': fields.many2one('res.users', 'Related user', readonly=1), 'attachment_ids': fields.many2many('ir.attachment', 'message_attachment_rel', 'message_id', 'attachment_id', 'Attachments'), @@ -223,6 +222,7 @@ class mail_message(osv.osv): } _defaults = { + 'type': 'comment', 'state': 'received', }