From 7533a0d64c275a2a10e599aadfd77ea85a1463e4 Mon Sep 17 00:00:00 2001 From: "Adrien Peiffer (ACSONE)" Date: Mon, 4 Apr 2016 20:58:03 +0200 Subject: [PATCH] [CHG][mail_optional_autofollow] some improvements --- mail_optional_autofollow/README.rst | 2 +- .../wizard/mail_compose_message.py | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/mail_optional_autofollow/README.rst b/mail_optional_autofollow/README.rst index 3223d748..cc74075d 100644 --- a/mail_optional_autofollow/README.rst +++ b/mail_optional_autofollow/README.rst @@ -14,7 +14,7 @@ Usage 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 .. figure:: static/description/autofollow.png diff --git a/mail_optional_autofollow/wizard/mail_compose_message.py b/mail_optional_autofollow/wizard/mail_compose_message.py index a36b6b03..912a3d91 100644 --- a/mail_optional_autofollow/wizard/mail_compose_message.py +++ b/mail_optional_autofollow/wizard/mail_compose_message.py @@ -11,18 +11,19 @@ class MailComposeMessage(models.TransientModel): @api.model def default_get(self, fields_list): res = super(MailComposeMessage, self).default_get(fields_list) - if self.env.context.get('mail_post_autofollow'): - res['autofollow_recipients'] = True + res.setdefault( + 'autofollow_recipients', + self.env.context.get('mail_post_autofollow', False)) 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 def send_mail(self): for wizard in self: - if wizard.autofollow_recipients: - wizard = wizard.with_context(mail_post_autofollow=True) - else: - wizard = wizard.with_context(mail_post_autofollow=False) - super(MailComposeMessage, wizard).send_mail() + super(MailComposeMessage, wizard.with_context( + mail_post_autofollow=wizard.autofollow_recipients)).send_mail() return {'type': 'ir.actions.act_window_close'}