[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
This commit is contained in:
Nicolas Lempereur 2015-11-09 10:38:19 +01:00
parent f18399f721
commit 9717afbbb7
2 changed files with 15 additions and 8 deletions

View File

@ -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:

View File

@ -369,13 +369,7 @@
<field name="partner_id" attrs="{'readonly':[('state','!=', 'draft')]}"/>
<field name="name"/>
<field name="phone"/>
<label for="email"/>
<div>
<field name="email" class="oe_inline"/>
<button class="oe_inline oe_right" string="Send Email"
name="%(mail.action_email_compose_message_wizard)d"
icon="terp-mail-message-new" context= '{"default_email_to":email}' type="action"/>
</div>
<field name="email"/>
</group>
<group>
<field name="nb_register"/>