summaryrefslogtreecommitdiff
path: root/addons/mail/wizard/mail_resend_message.py
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2018-04-27 17:44:28 +0200
committerThibault Delavallée <tde@odoo.com>2018-08-07 15:43:06 +0200
commit689a496f1c60eb662dec7bbf7079f33b070a2cee (patch)
tree06d7887d9ccd1bcaab673aa8cd296c39fd92c794 /addons/mail/wizard/mail_resend_message.py
parent89051058f4ab7069024f7f6cf2caac05bd68b499 (diff)
[REF] mail: propagate recipient data through notification process
Purpose of this commit is to avoid browsing and prefetching data about recipients when notifying a message to partners and channels. Mail message _notify computes all necessary data in a single query. This commit allow to re-use this data by propagating it through the call chain. Addons inheriting from classification methods used when sending notification emails are updated accordingly to the API and data update. This commit is linked to task ID 47934 and PR #24033. No functional change should occur with this commit.
Diffstat (limited to 'addons/mail/wizard/mail_resend_message.py')
-rw-r--r--addons/mail/wizard/mail_resend_message.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/addons/mail/wizard/mail_resend_message.py b/addons/mail/wizard/mail_resend_message.py
index bf56128ad61..77b1a2a102d 100644
--- a/addons/mail/wizard/mail_resend_message.py
+++ b/addons/mail/wizard/mail_resend_message.py
@@ -60,7 +60,26 @@ class MailResendMessage(models.TransientModel):
if to_send:
message = wizard.mail_message_id
record = self.env[message.model].browse(message.res_id) if message.model and message.res_id else None
- to_send.sudo()._notify(self.mail_message_id, record, force_send=True, send_after_commit=False)
+
+ rdata = []
+ for pid, cid, active, pshare, ctype, notif, groups in self.env['mail.followers']._get_recipient_data(None, False, pids=to_send.ids):
+ if pid and notif == 'email' or not notif:
+ pdata = {'id': pid, 'share': pshare, 'active': active, 'notif': 'email', 'groups': groups}
+ if not pshare and notif: # has an user and is not shared, is therefore user
+ rdata.append(dict(pdata, type='user'))
+ elif pshare and notif: # has an user and is shared, is therefore portal
+ rdata.append(dict(pdata, type='portal'))
+ else: # has no user, is therefore customer
+ rdata.append(dict(pdata, type='customer'))
+
+ self.env['res.partner']._notify(
+ message,
+ rdata,
+ record,
+ force_send=True,
+ send_after_commit=False
+ )
+
self.mail_message_id._notify_failure_update()
return {'type': 'ir.actions.act_window_close'}