[IMP] event: default values for email sent at confirmation of event/registration / better templates

bzr revid: qdp-launchpad@openerp.com-20120228180011-o54w1pi4ovnx5d12
This commit is contained in:
Quentin (OpenERP) 2012-02-28 19:00:11 +01:00
parent beb4a61f6b
commit 75c5372d84
3 changed files with 36 additions and 17 deletions

View File

@ -4,13 +4,13 @@
<record id="confirmation_event" model="email.template">
<field name="name">Confirmation of the Event</field>
<field name="model_id" ref="event.model_event_registration"/>
<field name="email_from" >${object.user_id.user_email or object.company_id.email or 'noreply@localhost'}</field>
<field name="email_from" >${object.user_id.user_email or object.company_id.email or 'noreply@' + object.company_id.name + '.com'}</field>
<field name="email_to" >${object.email}</field>
<field name="subject">Ticket for ${object.event_id.name}</field>
<field name="subject">Your registration at ${object.event_id.name}</field>
<field name="body_text">
hello ${object.name},
The event ${object.event_id.name} that you registered from is confirmed and will be held from ${object.event_id.date_begin} to ${object.event_id.date_end}. For any further information please contact our event department.
The event ${object.event_id.name} that you registered for is confirmed and will be held from ${object.event_id.date_begin} to ${object.event_id.date_end}. For any further information please contact our event department.
we thank you for your participation
@ -24,13 +24,13 @@
<record id="confirmation_registration" model="email.template">
<field name="name">Confirmation of the Registration</field>
<field name="model_id" ref="event.model_event_registration"/>
<field name="email_from" >${object.user_id.user_email or object.company_id.email or 'noreply@localhost'}</field>
<field name="email_from" >${object.user_id.user_email or object.company_id.email or 'noreply@' + object.company_id.name + '.com'}</field>
<field name="email_to" >${object.email}</field>
<field name="subject">Ticket for ${object.event_id.name}</field>
<field name="subject">Your registration at ${object.event_id.name}</field>
<field name="body_text">
hello ${object.name},
We confirm your registration to the event ${object.event_id.name} to be held from ${object.event_id.date_begin} to ${object.event_id.date_end}
We confirm you that your registration to the event ${object.event_id.name} has been recorded. You will automatically receive an email providing you more practical information (such as the schedule, the plan...) as soon as the event will be confirmed to be held.
we thank you for your participation
@ -38,5 +38,21 @@
</field>
</record>
<!-- Default Values -->
<record model="ir.values" id="default_value_event_mail_confirmation">
<field name="name">default_email_event</field>
<field name="key">default</field>
<field name="key2"></field>
<field eval="ref('confirmation_event')" name="value_unpickle"/>
<field name="model">event.type</field>
</record>
<record model="ir.values" id="default_value_registration_mail_confirmation">
<field name="name">default_email_registration</field>
<field name="key">default</field>
<field name="key2"></field>
<field eval="ref('confirmation_registration')" name="value_unpickle"/>
<field name="model">event.type</field>
</record>
</data>
</openerp>

View File

@ -168,8 +168,8 @@ class event_event(osv.osv):
'register_prospect': fields.function(_get_register, string='Unconfirmed Registrations', multi='register_numbers'),
'register_attended': fields.function(_get_register, string='Attended Registrations', multi='register_numbers'),
'registration_ids': fields.one2many('event.registration', 'event_id', 'Registrations', readonly=False, states={'done': [('readonly', True)]}),
'date_begin': fields.datetime('Starting Date', required=True, readonly=True, states={'draft': [('readonly', False)]}),
'date_end': fields.datetime('Closing Date', required=True, readonly=True, states={'draft': [('readonly', False)]}),
'date_begin': fields.datetime('Start Date', required=True, readonly=True, states={'draft': [('readonly', False)]}),
'date_end': fields.datetime('End Date', required=True, readonly=True, states={'draft': [('readonly', False)]}),
'state': fields.selection([
('draft', 'Draft'),
('confirm', 'Confirmed'),
@ -177,7 +177,7 @@ class event_event(osv.osv):
('cancel', 'Cancelled')],
'State', readonly=True, required=True,
help='If event is created, the state is \'Draft\'.If event is confirmed for the particular dates the state is set to \'Confirmed\'. If the event is over, the state is set to \'Done\'.If event is cancelled the state is set to \'Cancelled\'.'),
'email_registration_id' : fields.many2one('email.template','Registration Confirmation Email'),
'email_registration_id' : fields.many2one('email.template','Registration Confirmation Email', help='This field contains the template of the mail that will be automatically sent each time a registration for this event is confirmed.'),
'email_confirmation_id' : fields.many2one('email.template','Event Confirmation Email', help="If you set an email template, each participant will receive this email announcing the confirmation of the event."),
'full_name' : fields.function(_name_get_fnc, type="char", string='Name'),
'reply_to': fields.char('Reply-To Email', size=64, readonly=False, states={'done': [('readonly', True)]}, help="The email address of the organizer is likely to be put here, with the effect to be in the 'Reply-To' of the mails sent automatically at event or registrations confirmation. You can also put the email address of your mail gateway if you use one."),
@ -269,7 +269,7 @@ class event_registration(osv.osv):
""" Open Registration
"""
res = self.confirm_registration(cr, uid, ids, context=context)
self.mail_user(cr, uid, ids)
self.mail_user(cr, uid, ids, context=context)
return res
def button_reg_close(self, cr, uid, ids, context=None):
@ -286,19 +286,22 @@ class event_registration(osv.osv):
self.message_append(cr, uid, ids,_('State set to...'),body_text= _('Cancel'))
return self.write(cr, uid, ids, {'state': 'cancel'})
def mail_user(self, cr, uid, ids, confirm=False, context=None):
def mail_user(self, cr, uid, ids, context=None):
"""
Send email to user with email_template when registration is done
"""
for registration in self.browse(cr, uid, ids, context=context):
template_id = registration.event_id.email_registration_id.id
if template_id:
mail_message = self.pool.get('email.template').send_mail(cr,uid,template_id,registration.id)
if registration.event_id.state == 'confirm' and registration.event_id.email_confirmation_id.id:
self.mail_user_confirm(cr, uid, ids, context=context)
else:
template_id = registration.event_id.email_registration_id.id
if template_id:
mail_message = self.pool.get('email.template').send_mail(cr,uid,template_id,registration.id)
return True
def mail_user_confirm(self, cr, uid, ids, context=None):
"""
Send email to user when the event is done
Send email to user when the event is confirmed
"""
for registration in self.browse(cr, uid, ids, context=context):
template_id = registration.event_id.email_confirmation_id.id

View File

@ -16,8 +16,8 @@
<form string="Event Type">
<field name="name" select="1"/>
<field name="default_reply_to"/>
<field name="default_email_event"/>
<field name="default_email_registration"/>
<field name="default_email_event" domain="[('model_id.model','=','event.registration')]"/>
<field name="default_email_registration" domain="[('model_id.model','=','event.registration')]"/>
<field name="default_registration_min"/>
<field name="default_registration_max"/>
</form>