[FIX] Chatter: mail_post_autofollow can be completed with mail_post_autofollow_partner_ids, that filters the recipients to subscribe. Purpose: suggested partners are added as followers, not people that could have been added after in the compose wizard.

bzr revid: tde@openerp.com-20130228164054-e3y3pdrygqph0dm2
This commit is contained in:
Thibault Delavallée 2013-02-28 17:40:54 +01:00
parent caaccea679
commit 718d38f056
3 changed files with 17 additions and 3 deletions

View File

@ -970,7 +970,10 @@ class mail_thread(osv.AbstractModel):
# automatically subscribe recipients if asked to
if context.get('mail_post_autofollow') and thread_id and partner_ids:
self.message_subscribe(cr, uid, [thread_id], list(partner_ids), context=context)
partner_to_subscribe = partner_ids
if context.get('mail_post_autofollow_partner_ids'):
partner_to_subscribe = filter(lambda item: item in context.get('mail_post_autofollow_partner_ids'), partner_ids)
self.message_subscribe(cr, uid, [thread_id], list(partner_to_subscribe), context=context)
# _mail_flat_thread: automatically set free messages to the first posted message
if self._mail_flat_thread and not parent_id and thread_id:

View File

@ -18,9 +18,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.tools.translate import _
from openerp.osv import fields, osv
class res_partner_mail(osv.Model):
""" Update partner to add a field about notification preferences """
_name = "res.partner"
@ -42,6 +43,12 @@ class res_partner_mail(osv.Model):
'notification_email_send': lambda *args: 'comment'
}
def message_get_suggested_recipients(self, cr, uid, ids, context=None):
recipients = super(res_partner_mail, self).message_get_suggested_recipients(cr, uid, ids, context=context)
for partner in self.browse(cr, uid, ids, context=context):
self._message_add_suggested_recipient(recipients, partner, partner=partner, reason=_('Customer'))
return recipients
def message_post(self, cr, uid, thread_id, **kwargs):
""" Override related to res.partner. In case of email message, set it as
private:

View File

@ -550,6 +550,7 @@ openerp.mail = function (session) {
'default_attachment_ids': self.attachment_ids,
'default_partner_ids': partner_ids,
'mail_post_autofollow': true,
'mail_post_autofollow_partner_ids': partner_ids,
};
if (self.is_log) {
_.extend(context, {'mail_compose_log': true});
@ -708,7 +709,10 @@ openerp.mail = function (session) {
'parent_id': this.context.default_parent_id,
'attachment_ids': _.map(this.attachment_ids, function (file) {return file.id;}),
'partner_ids': partner_ids,
'context': _.extend(this.parent_thread.context, {'mail_post_autofollow': true}),
'context': _.extend(this.parent_thread.context, {
'mail_post_autofollow': true,
'mail_post_autofollow_partner_ids': partner_ids,
}),
'type': 'comment',
'content_subtype': 'plaintext',
};