From 803bf8f75d239ccb7910cd2dca621b6a05e79289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 1 Oct 2015 10:43:32 +0200 Subject: [PATCH] [IMP] mail: invite email, notification style Use the notification template when sending invite emails (add a follower with send a message checked). --- addons/mail/models/mail_thread.py | 7 ++++--- addons/mail/wizard/invite.py | 24 +++++++++--------------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 20a4b77f96f..7aa0efbae31 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -583,9 +583,10 @@ class MailThread(models.AbstractModel): # At this point, all access rights should be ok. We sudo everything to # access rights checks and speedup the computation. recipients_sudo = recipients.sudo() - # message_sudo = message.sudo() - - access_link = self._notification_link_helper('view', message_id=message.id) + if self._context.get('auto_delete', False): + access_link = self._notification_link_helper('view') + else: + access_link = self._notification_link_helper('view', message_id=message.id) if message.model: model_name = self.env['ir.model'].sudo().search([('model', '=', self.env[message.model]._name)]).name_get()[0][1] diff --git a/addons/mail/wizard/invite.py b/addons/mail/wizard/invite.py index 36736cb355d..b32d9dd657f 100644 --- a/addons/mail/wizard/invite.py +++ b/addons/mail/wizard/invite.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from openerp import _, api, fields, models -from openerp import tools class Invite(models.TransientModel): @@ -49,21 +48,16 @@ class Invite(models.TransientModel): model_name = model_ids.name_get()[0][1] # send an email if option checked and if a message exists (do not send void emails) if wizard.send_mail and wizard.message and not wizard.message == '
': # when deleting the message, cleditor keeps a
- # TDE FIXME: use a template + _notification methods - # add signature - signature = self.env.user.signature - wizard.message = tools.append_content_to_html(wizard.message, signature, plaintext=False, container_tag='div') - - # send mail to new followers - self.env['mail.mail'].create({ - 'model': wizard.res_model, - 'res_id': wizard.res_id, + message = self.env['mail.message'].create({ + 'subject': _('Invitation to follow %s: %s') % (model_name, document.name_get()[0][1]), + 'body': wizard.message, 'record_name': document.name_get()[0][1], 'email_from': email_from, 'reply_to': email_from, - 'subject': _('Invitation to follow %s: %s') % (model_name, document.name_get()[0][1]), - 'body_html': '%s' % wizard.message, - 'auto_delete': True, - 'message_id': self.env['mail.message']._get_message_id({'no_auto_thread': True}), - 'recipient_ids': [(4, id) for id in new_partners.ids]}).send() + 'model': wizard.res_model, + 'res_id': wizard.res_id, + 'no_auto_thread': True, + }) + new_partners.with_context(auto_delete=True)._notify(message, force_send=True, user_signature=True) + message.unlink() return {'type': 'ir.actions.act_window_close'}