From 8ca7f866c8c17dece0e2fa50ea9d6df43dc4ebac Mon Sep 17 00:00:00 2001 From: fw-bot Date: Mon, 7 Oct 2019 15:00:25 +0000 Subject: [PATCH] [FIX] mail: correctly fetch customer data when sending invite Currently when inviting someone on a document all recipients are considered as standard customers. It means access buttons are not displayed and addon specific behavior not really triggered. This commit makes use of ``_get_recipient_data`` tool method allowing to categorize recipients in groups and display buttons and action links like other post on documents. Task ID 1967234 closes odoo/odoo#38111 Signed-off-by: Thibault Delavallee (tde) --- addons/mail/wizard/invite.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/addons/mail/wizard/invite.py b/addons/mail/wizard/invite.py index 34f42159cd4..44a68a92bb9 100644 --- a/addons/mail/wizard/invite.py +++ b/addons/mail/wizard/invite.py @@ -71,13 +71,17 @@ class Invite(models.TransientModel): 'no_auto_thread': True, 'add_sign': True, }) - recipients_data = {'partners': [{ - 'id': pid, - 'share': True, - 'notif': 'email', - 'type': 'customer', - 'groups': [] - } for pid in new_partners.ids]} - document._notify_record_by_email(message, recipients_data, send_after_commit=False) + partners_data = [] + recipient_data = self.env['mail.followers']._get_recipient_data(document, 'comment', False, pids=new_partners.ids) + for pid, cid, active, pshare, ctype, notif, groups in recipient_data: + pdata = {'id': pid, 'share': pshare, 'active': active, 'notif': 'email', 'groups': groups or []} + if not pshare and notif: # has an user and is not shared, is therefore user + partners_data.append(dict(pdata, type='user')) + elif pshare and notif: # has an user and is shared, is therefore portal + partners_data.append(dict(pdata, type='portal')) + else: # has no user, is therefore customer + partners_data.append(dict(pdata, type='customer')) + + document._notify_record_by_email(message, {'partners': partners_data, 'channels': []}, send_after_commit=False) message.unlink() return {'type': 'ir.actions.act_window_close'}