PURPOSE SMS are a powerful marketing tool. For instance it is perfect to announce a sale or to communicate a coupon code, to welcome a new customer in a fidelity program, ... Purpose of this task is to integrate SMS sending in batch in mass mailing. It will use same mailing objects but sending SMS instead of emails. Some metrics and flows will have to be slightly updated at the same time. SPECIFICATIONS Limit use of templates to models that are really capable of sending SMS. Templates are now available on models that inherit from mail.thread and effectively have fields used in SMS sending. Technically this is done through a not stored field on ir.model that is searchable. SMS sending capabilities is based on * having fields holding phone numbers, as defined on mail.thread in SMS; * having fields holding partners, as defined on mail.thread in SMS; This implied some code rewriting notably about finding default SMS recipients on a given model, in order to have fields instead of directly returning partners. LINKS Task 1997464 PR #34424 Original SMS addition: Task1922163(4287481)
60 lines
1.8 KiB
Python
60 lines
1.8 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import api, fields, models
|
|
|
|
|
|
class MailTestSMS(models.Model):
|
|
""" A model inheriting from mail.thread with some fields used for SMS
|
|
gateway, like a partner, a specific mobile phone, ... """
|
|
_description = 'Chatter Model for SMS Gateway'
|
|
_name = 'mail.test.sms'
|
|
_inherit = ['mail.thread']
|
|
_order = 'name asc, id asc'
|
|
|
|
name = fields.Char()
|
|
subject = fields.Char()
|
|
email_from = fields.Char()
|
|
phone_nbr = fields.Char()
|
|
mobile_nbr = fields.Char()
|
|
customer_id = fields.Many2one('res.partner', 'Customer')
|
|
|
|
def _sms_get_partner_fields(self):
|
|
return ['customer_id']
|
|
|
|
def _sms_get_number_fields(self):
|
|
return ['phone_nbr', 'mobile_nbr']
|
|
|
|
|
|
class MailTestSMSBL(models.Model):
|
|
""" A model inheriting from mail.thread with some fields used for SMS
|
|
gateway, like a partner, a specific mobile phone, ... """
|
|
_description = 'Chatter Model for SMS Gateway'
|
|
_name = 'mail.test.sms.bl'
|
|
_inherit = ['mail.thread.phone']
|
|
_order = 'name asc, id asc'
|
|
|
|
name = fields.Char()
|
|
subject = fields.Char()
|
|
email_from = fields.Char()
|
|
phone_nbr = fields.Char()
|
|
mobile_nbr = fields.Char()
|
|
customer_id = fields.Many2one('res.partner', 'Customer')
|
|
|
|
def _sms_get_partner_fields(self):
|
|
return ['customer_id']
|
|
|
|
def _sms_get_number_fields(self):
|
|
return ['phone_nbr', 'mobile_nbr']
|
|
|
|
|
|
class MailTestSMSSoLike(models.Model):
|
|
""" A model like sale order having only a customer, not specific phone
|
|
or mobile fields. """
|
|
_description = 'Chatter Model for SMS Gateway (Partner only)'
|
|
_name = 'mail.test.sms.partner'
|
|
_inherit = ['mail.thread']
|
|
|
|
name = fields.Char()
|
|
partner_id = fields.Many2one('res.partner', 'Customer')
|