Skip to content
Browse files

[IMP] calendar_sms: use sms template

  • Loading branch information...
pro-odoo committed Apr 24, 2019
1 parent ad2b8b9 commit 40855d37f7fbf4ec0d0855eb47f892f848435a68
@@ -10,6 +10,7 @@
'depends': ['calendar', 'sms'],
'data': [
'application': False,
'auto_install': True,
@@ -0,0 +1,14 @@
<?xml version="1.0" ?>

<!-- SMS template are declared in a NOUPDATE block
so users can freely customize/delete them -->
<data noupdate="1">
<!--Email template -->
<record id="sms_reminder_template" model="sms.template">
<field name="name">Calendar SMS: SMS Reminder</field>
<field name="model_id" ref="calendar.model_calendar_event"/>
<field name="body">Event reminder: ${} on ${object.start_datetime or object.start_date}</field>
@@ -20,12 +20,15 @@ def _get_default_sms_recipients(self):
def _do_sms_reminder(self):
""" Send an SMS text reminder to attendees that haven't declined the event """
for event in self:
sms_msg = _("Event reminder: %s on %s.") % (, event.start_datetime or event.start_date)
recipients = self._get_default_sms_recipients()
template = self.env.ref('calendar_sms.sms_reminder_template', False)
# PRO: PIM, what to do if template is False ?
contents = template._render_template(template.body, self._name, recipients.ids)
note_msg = _("SMS text message reminder sent !")
values = [{
'name': partner.display_name,
'number': if else,
'content': sms_msg,
'content': contents.get(,
'country_id': if partner.country_id else False
} for partner in self._get_default_sms_recipients()]
sms_ids = self.env['sms.sms'].create(values)

0 comments on commit 40855d3

Please sign in to comment.
You can’t perform that action at this time.