From 9717afbbb72638b43037bc6c304a2d15f7dc3f20 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Mon, 9 Nov 2015 10:38:19 +0100 Subject: [PATCH] [FIX] event: fix send mail to event registrant Currently, the button "Send Email" next to the email address of an event registration didn't work if a partner was not set. This commit removes the button, thus removing the feature but partially adds it back via the chatter suggested recipients in the same way it is done for a lead. It is still partially a feature regression since to work the viewing user need more access rights (e.g read access right on res.partner) than before. closes #9486 opw-653127 --- addons/event/event.py | 15 ++++++++++++++- addons/event/event_view.xml | 8 +------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/addons/event/event.py b/addons/event/event.py index 9aab9b8ee25..20697c1a86c 100644 --- a/addons/event/event.py +++ b/addons/event/event.py @@ -23,7 +23,7 @@ from datetime import timedelta import pytz from openerp import models, fields, api, _ -from openerp.exceptions import Warning +from openerp.exceptions import AccessError, Warning class event_type(models.Model): """ Event Type """ @@ -384,6 +384,19 @@ class event_registration(models.Model): if template: mail_message = template.send_mail(self.id) + @api.multi + def message_get_suggested_recipients(self): + recipients = super(event_registration, self).message_get_suggested_recipients() + try: + for registration in self: + if registration.partner_id: + self._message_add_suggested_recipient(recipients, registration, partner=registration.partner_id, reason=_('Registrant')) + elif registration.email: + self._message_add_suggested_recipient(recipients, registration, email=registration.email, reason=_('Registrant Email')) + except AccessError: # no read access rights -> ignore suggested recipients + pass + return recipients + @api.onchange('partner_id') def _onchange_partner(self): if self.partner_id: diff --git a/addons/event/event_view.xml b/addons/event/event_view.xml index 201f5568cc4..3ee33e011b6 100644 --- a/addons/event/event_view.xml +++ b/addons/event/event_view.xml @@ -369,13 +369,7 @@ -