[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:
parent
f18399f721
commit
9717afbbb7
|
@ -23,7 +23,7 @@ from datetime import timedelta
|
||||||
import pytz
|
import pytz
|
||||||
|
|
||||||
from openerp import models, fields, api, _
|
from openerp import models, fields, api, _
|
||||||
from openerp.exceptions import Warning
|
from openerp.exceptions import AccessError, Warning
|
||||||
|
|
||||||
class event_type(models.Model):
|
class event_type(models.Model):
|
||||||
""" Event Type """
|
""" Event Type """
|
||||||
|
@ -384,6 +384,19 @@ class event_registration(models.Model):
|
||||||
if template:
|
if template:
|
||||||
mail_message = template.send_mail(self.id)
|
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')
|
@api.onchange('partner_id')
|
||||||
def _onchange_partner(self):
|
def _onchange_partner(self):
|
||||||
if self.partner_id:
|
if self.partner_id:
|
||||||
|
|
|
@ -369,13 +369,7 @@
|
||||||
<field name="partner_id" attrs="{'readonly':[('state','!=', 'draft')]}"/>
|
<field name="partner_id" attrs="{'readonly':[('state','!=', 'draft')]}"/>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="phone"/>
|
<field name="phone"/>
|
||||||
<label for="email"/>
|
<field name="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>
|
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="nb_register"/>
|
<field name="nb_register"/>
|
||||||
|
|
Loading…
Reference in New Issue