diff options
| author | fw-bot <otis@odoo.com> | 2019-10-07 15:00:25 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2019-10-08 13:48:34 +0000 |
| commit | 8ca7f866c8c17dece0e2fa50ea9d6df43dc4ebac (patch) | |
| tree | b45945abf6156a8221cfc1e66f0705cd05017fb2 /addons/mail/wizard | |
| parent | 17b0215ed59a85649d401245c89255e3eedc3f2e (diff) | |
[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>
Diffstat (limited to 'addons/mail/wizard')
| -rw-r--r-- | addons/mail/wizard/invite.py | 20 |
1 files 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'} |
