[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) <tde@openerp.com>
This commit is contained in:
fw-bot
2019-10-08 13:48:34 +00:00
committed by Thibault Delavallée
parent 17b0215ed5
commit 8ca7f866c8
+12 -8
View File
@@ -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'}