diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 26d85aa68e9..eeefd730f22 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -151,7 +151,6 @@ class mail_message(osv.Model): 'date': lambda *a: fields.datetime.now(), 'author_id': lambda self, cr, uid, ctx={}: self._get_default_author(cr, uid, ctx), 'body': '', - 'is_private': False, } #------------------------------------------------------ @@ -473,11 +472,9 @@ class mail_message(osv.Model): self.pool.get('ir.attachment').unlink(cr, uid, attachments_to_delete, context=context) return super(mail_message, self).unlink(cr, uid, ids, context=context) - def _notify(self, cr, uid, newid, context=None): + def _notify_followers(self, cr, uid, newid, message, context=None): """ Add the related record followers to the destination partner_ids. - Call mail_notification.notify to manage the email sending """ - message = self.browse(cr, uid, newid, context=context) partners_to_notify = set([]) # message has no subtype_id: pure log message -> no partners, no one notified if not message.subtype_id: @@ -505,6 +502,14 @@ class mail_message(osv.Model): else: self.write(cr, SUPERUSER_ID, [newid], {'partner_ids': [(3, message.author_id.id)]}, context=context) + def _notify(self, cr, uid, newid, context=None): + """ Add the related record followers to the destination partner_ids if is not a private message. + Call mail_notification.notify to manage the email sending + """ + message = self.browse(cr, uid, newid, context=context) + if message and (message.is_private!=False and message.is_private!=None): + self._notify_followers(cr, uid, newid, message, context=context) + self.pool.get('mail.notification')._notify(cr, uid, newid, context=context) def copy(self, cr, uid, id, default=None, context=None): diff --git a/addons/mail/mail_message_view.xml b/addons/mail/mail_message_view.xml index 173b18d0ed8..6d854d4d701 100644 --- a/addons/mail/mail_message_view.xml +++ b/addons/mail/mail_message_view.xml @@ -101,14 +101,14 @@ Archives mail.wall - Sent mail.wall - diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 9f53b4c08b1..9215b120361 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -627,7 +627,6 @@ class mail_thread(osv.AbstractModel): ``(name,content)``, where content is NOT base64 encoded :return: ID of newly created mail.message """ - context = context or {} attachments = attachments or [] assert (not thread_id) or isinstance(thread_id, (int, long)) or \ @@ -679,6 +678,12 @@ class mail_thread(osv.AbstractModel): 'attachment_ids': attachment_ids, 'subtype_id': subtype_id, }) + + if parent_id: + msg = messages.browse(cr, uid, parent_id, context=context) + if msg.is_private: + values["is_private"] = msg.is_private + # Avoid warnings about non-existing fields for x in ('from', 'to', 'cc'): values.pop(x, None) diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 3baf3ff9023..b7c51a20125 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -121,7 +121,7 @@ class mail_compose_message(osv.TransientModel): 'partner_ids': lambda self, cr, uid, ctx={}: [], } - def notify(self, cr, uid, newid, context=None): + def _notify(self, cr, uid, newid, context=None): """ Override specific notify method of mail.message, because we do not want that feature in the wizard. """ return @@ -219,7 +219,6 @@ class mail_compose_message(osv.TransientModel): email(s), rendering any template patterns on the fly if needed. """ if context is None: context = {} - print '**', context active_ids = context.get('active_ids') for wizard in self.browse(cr, uid, ids, context=context):