[CHG][mail_optional_autofollow] some improvements

This commit is contained in:
Adrien Peiffer (ACSONE) 2016-04-04 20:58:03 +02:00 committed by Karl Southern
parent 772040686e
commit a3d4685d76
2 changed files with 10 additions and 9 deletions

View File

@ -14,7 +14,7 @@ Usage
To use this module, you need to use the autofollow recipients checkbox on mail.compose.message: To use this module, you need to use the autofollow recipients checkbox on mail.compose.message:
Technically, this field it's initialized to true if there is an Technically, this field is initialized to true if there is an
'mail_post_autofollow' key in the current context 'mail_post_autofollow' key in the current context
.. figure:: static/description/autofollow.png .. figure:: static/description/autofollow.png

View File

@ -11,18 +11,19 @@ class MailComposeMessage(models.TransientModel):
@api.model @api.model
def default_get(self, fields_list): def default_get(self, fields_list):
res = super(MailComposeMessage, self).default_get(fields_list) res = super(MailComposeMessage, self).default_get(fields_list)
if self.env.context.get('mail_post_autofollow'): res.setdefault(
res['autofollow_recipients'] = True 'autofollow_recipients',
self.env.context.get('mail_post_autofollow', False))
return res return res
autofollow_recipients = fields.Boolean() autofollow_recipients = fields.Boolean(
string='Make recipients followers',
help="""if checked, the additional recipients will be added as\
followers on the related object""")
@api.multi @api.multi
def send_mail(self): def send_mail(self):
for wizard in self: for wizard in self:
if wizard.autofollow_recipients: super(MailComposeMessage, wizard.with_context(
wizard = wizard.with_context(mail_post_autofollow=True) mail_post_autofollow=wizard.autofollow_recipients)).send_mail()
else:
wizard = wizard.with_context(mail_post_autofollow=False)
super(MailComposeMessage, wizard).send_mail()
return {'type': 'ir.actions.act_window_close'} return {'type': 'ir.actions.act_window_close'}