Purpose is to test specific behavior of opt-out for SMS marketing. This is currently not tested and working a bit strangely, as they are flagged as blacklist. This will soon be updated in another task but at least current behavior is logged somewhere. We also update some test models in order to reflect potential strange and non-default behavior, notably partner_id field used as contact field. It will be used soon when cleaning some opt-out behavior. Tests are added to check phone sanitized is correctly taken into account in default domains when inheriting from the phone blacklist mixin. Some counters notes are also updated next to some last updates. Task ID-2431217 COM PR odoo/odoo#71140 X-Original-Commit odoo/odoo@3ba3054f0a X-original-commit: a9ac2582eb508daa21fd0d3a5a551261ecc18f8b
57 lines
2.2 KiB
Python
57 lines
2.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo.addons.phone_validation.tools import phone_validation
|
|
from odoo.addons.mass_mailing_sms.tests.common import MassSMSCommon
|
|
from odoo.addons.test_mail.tests import common
|
|
from odoo.addons.test_mass_mailing.tests.common import TestMassMailCommon
|
|
|
|
|
|
class TestMailFullCommon(TestMassMailCommon, MassSMSCommon):
|
|
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
super(TestMailFullCommon, cls).setUpClass()
|
|
|
|
cls.mailing_sms = cls.env['mailing.mailing'].with_user(cls.user_marketing).create({
|
|
'name': 'XMas SMS',
|
|
'subject': 'Xmas SMS for {object.name}',
|
|
'mailing_model_id': cls.env['ir.model']._get('mail.test.sms').id,
|
|
'mailing_type': 'sms',
|
|
'mailing_domain': '%s' % repr([('name', 'ilike', 'SMSTest')]),
|
|
'body_plaintext': 'Dear ${object.display_name} this is a mass SMS with two links http://www.odoo.com/smstest and http://www.odoo.com/smstest/${object.id}',
|
|
'sms_force_send': True,
|
|
'sms_allow_unsubscribe': True,
|
|
})
|
|
|
|
@classmethod
|
|
def _create_mailing_sms_test_records(cls, model='mail.test.sms', partners=None, count=1):
|
|
""" Helper to create data. Currently simple, to be improved. """
|
|
Model = cls.env[model]
|
|
phone_field = 'phone_nbr' if 'phone_nbr' in Model else 'phone'
|
|
partner_field = 'customer_id' if 'customer_id' in Model else 'partner_id'
|
|
|
|
vals_list = []
|
|
for idx in range(count):
|
|
vals = {
|
|
'name': 'SMSTestRecord_%02d' % idx,
|
|
phone_field: '045600%02d%02d' % (idx, idx)
|
|
}
|
|
if partners:
|
|
vals[partner_field] = partners[idx % len(partners)]
|
|
|
|
vals_list.append(vals)
|
|
|
|
return cls.env[model].create(vals_list)
|
|
|
|
|
|
class TestMailFullRecipients(common.TestRecipients):
|
|
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
super(TestMailFullRecipients, cls).setUpClass()
|
|
cls.partner_numbers = [
|
|
phone_validation.phone_format(partner.mobile, partner.country_id.code, partner.country_id.phone_code, force_format='E164')
|
|
for partner in (cls.partner_1 | cls.partner_2)
|
|
]
|