calendar_alarm.py 1.0 KB

1234567891011121314151617181920212223242526
  1. # -*- coding: utf-8 -*-
  2. # Part of Odoo. See LICENSE file for full copyright and licensing details.
  3. from odoo import api, fields, models
  4. class CalendarAlarm(models.Model):
  5. _inherit = 'calendar.alarm'
  6. alarm_type = fields.Selection(selection_add=[
  7. ('sms', 'SMS Text Message')
  8. ], ondelete={'sms': 'set default'})
  9. sms_template_id = fields.Many2one(
  10. 'sms.template', string="SMS Template",
  11. domain=[('model', 'in', ['calendar.event'])],
  12. compute='_compute_sms_template_id', readonly=False, store=True,
  13. help="Template used to render SMS reminder content.")
  14. @api.depends('alarm_type', 'sms_template_id')
  15. def _compute_sms_template_id(self):
  16. for alarm in self:
  17. if alarm.alarm_type == 'sms' and not alarm.sms_template_id:
  18. alarm.sms_template_id = self.env['ir.model.data']._xmlid_to_res_id('calendar_sms.sms_template_data_calendar_reminder')
  19. elif alarm.alarm_type != 'sms' or not alarm.sms_template_id:
  20. alarm.sms_template_id = False