In this commit we introduce a new module ``test_mail_sms`` that holds the
tests for sms application, like ``test_mail`` does for mail. Currently all
sms tests are inside ``test_mail_full``. After this commit code is moved
from ``test_mail_full`` into that module. Full testing module should be used
mainly to test integrations with a lot of submodules and for performance
tests, not testing details of SMS implementation.
We also add ``mass_mailing_sms`` as dependency of ``test_mass_mailing`` so
that both mailing types are tested in the same module. It eases maintenance
and writing of tests. Mass mailing SMS tests from `test_mail_full`` are
therefore moved in ``test_mass_mailing``.
This commit also allows some cleaning in classes used in tests, to have
classes in ``test_mail_sms`` and ``test_mail_full`` that contain everything
necessary to test mail features.
Task-2890111 (Test Mail/Mass Mailing: SMS tests reorganization and move)
Part-of: odoo/odoo#96223
Purpose of this commit is to have as less custom test data as possible. In
some sms tests we can re-use existing mailing, leading to more standard
tests and expected results.
We also improve ``gateway_sms_sent_click`` tool that now creates random IP
addresses allowing to have various clicks on a given tracker. Indeed as IP
is unique several clicks are currently set into the same click record, which
will now not be the case anymore.
Task-2641394 (Digest emails sending improvement)
Task-2582128 (Digest onbarding and usage improvement)
Task-2686586 (Repair mailing statistics email)
X-original-commit: f76b154412a111067203979075fa65f198cc39f4
Part-of: odoo/odoo#79877
Jinja as a templating engine was problematic in differents respect:
- introduce external dependency to Odoo (less controll)
- add another templating mechanism in the stack
- specific feature in qweb cannot be reused
- difficulty in rendering easily editable templates
- more knowledge required with no betterment
By replacing jinja with qweb we can now build tools to edit a qweb
that will work with the previously jinja encoded document
(essentially `mail.template` records).
There is a catch however. Some email fields (eg. email_to) used jinja
syntax for rendering dynamic variables (ie. ${object.something} and
${object.something_that_should_not_be_escaped | safe}).
We still want user to use dynamic variables for some char fields (eg.
subject, from, to, ...). We made a new rendering engine called
"inline_template" that will render an expression enclosed by `{{` and
`}}`.
To be able to edit the templates from the backend interface, a
plugin to the Odoo editor has been made for seamlessly edit the
document.
This qweb plugin includes:
- make dynamic variables (eg. `<t t-out="variable"/>`) not editable
(for preventing the user to shoot himself in the foot)
- group and hide related logical branching (ie. t-if, t-elif, and t-else)
in order to see only one at once
- a floating select input to switch visibility of a particular logical
branching
Task-27033
X-original-commit: odoo/odoo@68182baff4
Part-of: odoo/odoo#77377
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
It is better to use another naming than re-using class names. Somehow it
seems sometimes we have MRO issues.
Task ID-2390314
PR odoo/odoo#62384
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Purpose is to have some low level tests for composer itself allowing to
ensure its behavior. We add tests notably about default values computation
in mass mailing mode as well as template_id change and values synchronization
in composer model.
In a near future composer will probably be improved (use computed fields,
rewrite part of its logic to improve performances). Having tests done before
those tasks ensure we notice every change that might happen.
Task ID-2390314
PR odoo/odoo#62061
X-original-commit: def98d2375a8a906092293f0aa1ce03bf948d2d3
This commit adapts the business code in which
class/module/function/method redefinition took place so that it no
longer happens and the pylint test passes.
Modules holding tests and helpers
* link_tracker: mainly mock, asserts and tools for link tracker tests
(MockLinkTracker);
* mail: mainly gateway mock and base for mail tests
* MockEmail -> mocks for mail gateway;
* MailCase -> tools and asserts for mail tests;
* MailCommon -> base for mail functional tests);
* sms: mainly SMS gateway mock and base for sms tests
* MockSMS -> mocks for SMS gateway;
* SMS Case -> tools and asserts for mail / SMS tests;
* SMSCommon -> update of MailCommon with SMS capabilities);
* mass_mailing: mainly asserts and tools for mass mailing tests
* MassMailCase -> update of MailCase for mass mailing tools and asserts;
* MassMailCommon -> update of MailCommon with mass mailing);
* mass_mailing_sms: mainly asserts and tools for mass SMS tests
* MockMassSMS -> update of MockSMS for mass SMS tools and asserts;
* MassSMSCommon -> update of MassMailCommon with SMS capabilities);
Modules for tests
* test_mail: module for mail app tests (TestMailCommon);
* test_mass_mailing: module for mass mailing app tests (TestMassMailCommon);
* test_mail_full: tests integrating all discuss features, currently mainly
mail and SMS (TestMailFullCommon);
Enterprise: update test_mail_enterprise and test_marketing_automation
Task ID 2247037
Community PR odoo/odoo#50384
Enterprise PR odoo/enterprise#10266
Upgrade PR odoo/upgrade#1122
URPOSE
Prepare code cleaning and optimization in mail, mass_mailing and SMS by
cleaning models for readability and code complexity and footprint reduction.
SPECIFICATIONS
Add tool methods and asserts for link tracker tests.
Add tool methods and assets for mass mailing tests, notably about mailing
traces and their link with emails.
Merge existing and duplicated tests and rewrite them a bit.
Rename and improve test_mass_mailing models.
LINKS
Prepares task ID 2238597 (notification and trace models cleaning)
Task ID 1906925 (mass mailing tests cleaning)
PR #50169
Related: odoo/enterprise#10180
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
PURPOSE
Currently tools and asserts for mail tests are located inside test_mail
module. It makes difficult to re-use them in apps tests or force them to
write custom quick and dirty tools and asserts.
SPECIFICATIONS
Update this module to new tools / asserts / helpers / classes defined in mail
and test_mail.
In this commit we remove the ``BaseFunctionalTest`` and replace it by a fresh
``TestSMSCommon`` that is the combination of ``TestMailCommon`` from mail and
mass mailing with SMS mocks capabilities. That way all mocks and asserts are
available in all sub test classes.
``MassSMSBaseFunctionalTest`` is not necessary anymore as everything is
available directly with ``TestSMSCommon``.
Coming from common update, we have notably
* ``BaseFunctionalTest`` class is replaced by the new ``TestMailCommon``
pimped one;
* ``assertNotifications`` is replaced by ``assertSinglePostNotifications``
(shortcut for a simple message_post) or ``assertPostNotifications``
(complete asserts involving several messages and notifications);
* correctly invoke ``mock_mail_gateway`` when mocking email sending;
* replace manual check of sent emails or ``assertEmails`` by
``assertSentEmails``;
* remove custom mocks / checks and replace them by now standard mocks
and assertions (if any);
LINKS
Task ID 2068986
PR #38070
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
Create a new application called "Mass SMS" that follows the structure of
mass_mailing application.
General guidelines
* use the fa-comment icon for this module;
* add a "Notification type" field to the mailings: email or sms. Set it
invisible and set as domain from context when choosing mass mailing or
mass sms application (menus / action specific);
* adapt the metrics from Mass Mailing to SMS
* sent = received = whether the SMS was sent or not;
* opened => we don't have this information;
* replied => we don't have this information;
* clicks = from link tracker (no change of behavior);
* bounced = SMS that failed to be delivered because the format is wrong;
* exception = any issue when sending SMS;
* keep the Mailing Lists menu, hide email related fields on contact model;
* settings: hide the "Specific Mail Server" feature
Mailing form view
* add an "SMS Content" tab between Mail Body and Options. In there, we should
have the following fields:
* content
* opt-out link: provide a link to the Unsubscribe page. Make it as short
as possible;
* SMS Template
* add an "SMS Text Message" Medium;
Mailing actions
* add an "SMS Sent" smart button. Use the fa-comment-o icon and it should
redirect to the same list views as the "Email sent" smart button and list
the contacts to which an SMS was sent;
* add a "Mobile" field in the list views of the "Email sent" smart button:
* adapt the TEST button > Test Mailing modal to SMS (we should have 1 button
for Email and 1 for SMS); update description;
* default value for the Recipients field should be Name of the current
user, work mobile/phone number;
* If there are no Work Mobile/Phone numbers set on res.users, display
(123)-456-7890 instead;
* rename the Send Sample Mail button into Send Sample SMS;
* adapt the SEND NOW button > Confirmation modal to SMS. Change the message
into "This will send the SMS Text Message to all recipients. Do you still
want to proceed?"
* hide the following elements: Subject, From, Reply to, Attachments, Mail
Server, Mail Body tab; Opened, Replied;
* adapt the label of the following "warnings" to SMS
* x SMS Text Message(s) have been ignored and will not be sent.
* x SMS Text Message(s) are in queue and will be sent soon.
* x SMS Text Message(s) could not be sent.
Mailing kanban view
* hide the following stats: https://nimb.ws/grvBn0: Opened, Replied;
Mailing list / contact management
* following fields should be left empty: https://nimb.ws/3HBeJL: Opened,
Replied;
* when browsing through mailing lsits and contacts through the Mass SMS
application, update actions and views to hide fields related to
email and display only phone-related information;
UTM Campaign
* form view > Related Mailings tab: the following fields should be left
empty if notification type = SMS: https://nimb.ws/nfvr1O: Opened, Replied
Mass Mailing > Reporting (mail.trace.report model)
* adapt the reporting based on the fact that we do not have the following
metrics for SMS: Opened, Replied;
Mass Mailing > Configuration > Blacklist
* do not display any email information (phone blacklist is about phone);
* support phone blacklist. Phone blacklist is therefore a separate model
from mail.blacklist to simplify management. It is included in sms sending
process like mail blacklist when mailing in mass;
Opt-out and blacklist handling
* we do support mailing lists because they could come from different sources
and are a way to communicate with a specific audience (and not just a list
we bought), e.g. subscribe to this list to be kept updated whenever this
product is back in stock, or to receive results of this ...
* if the SMSing is from a list, opt-out removes ourselves from the list;
* if it is from the contact ==> Sent to blacklist;
* allow to attach unsubscription links in sent SMS, redirecting to a new
route in mass mailing SMS allowing quick unsubscribe and/or blacklist
of phone numbers;
Error management
* if the user clicks on Send Now / Schedule / Test and does not have enough
credits, open the "Insufficient credits" modal in a lazy option (aka when
having failed statistics linked to insufficient credits);
* on the mailing, we however display this failure as :
* a message on the mailing kanban view
* a message on the top of the form view + same behavior as the mailing and
"Could not be sent" https://www.screencast.com/t/BExgd1Gc;
LINKS
Task 1997464
PR #34424
Original SMS addition: Task 1922163 (4287481)
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
Purpose of this commit is to add a blacklist mechanism for phone numbers
used to send SMS like what already exists for email addresses when sending
emails.
Define a new phone.blacklist model, holding a number and the state of the
blacklist (active field), as well as tools methods to access it. Make it
as private as possible, accessing it in sudo once access are granted.
Also clean phone validation tools: lessen number of tool functions and update
caller to simplify code readability. Some fixes are also included in this
commit, notably blank spaces cleaning in phone numbers.
Improve phone.validation.mixin to add a tool method computing a sanitized
number, in addition to formatting it to national / international.
Define a new mail.thread.phone mixin computing the blacklist status of a
record. This mixin
* inherit from phone.validation.mixin in order to have access to some
base phone number parsing capabilities;
* computes a sanitized phone number based on ´´_phone_get_number_fields´´.
It takes first sanitized value, trying each field returned by the
method. That means one sanitized phone number is available per record
even if several fields are available;
* compute blacklist state of records. It is based on phone.blacklist
model and give an easy-to-use field and API to manipulate blacklisted
records;
* give some API methods :
* ``_phone_set_blacklisted``: set recordset as blacklisted;
* ``_phone_reset_blacklisted``: reactivate recordset (even if not blacklisted
this method can be called safely);
Put menus in technical in order to have access to it. Add a Phone / SMS
menu below "Email" and use it to store SMS / Phone actions.
Finally prepare tests addition by performing some light cleaning while adding
blacklist tests. Purpose is to ease future tests related to SMS.
LINKS
Task 1997464
PR #34424
Original SMS addition: Task 1922163 (4287481)
PURPOSE
Purpose of this commit is to add options and improve sms composer behavior.
Followup of merge 4287481bf0 .
SPECIFICATIONS
* mass mode: add an option to keep archives when doing mass sms. This mode
is actually a _message_sms in batch using the note subtype to speedup the
process;
* improve _message_sms_schedule_mass to allow more fine-tuning of options
when calling it;
* do not block sending SMS in batch if some recipients are invalid. Indeed
using notifications there will be traces of failed SMS;
* avoid reload of form view;
Linked to task 1925950 and 1935280
Part of PR #34864
Purpose of this commit is to better include SMS notifications when posting a
message. SMS is now just another way of notifying people along with Inbox and
email. Following recent mail merge improving notification mechanism [1] we
have to define a _notify_record_by_sms method on mail.thread.
When a message_post is done using message_type being ``sms`` notification type
of customers is set to sms. Customers can be computed on model (generally based
on partner_id field) or directly set usign partner°ids. Notification model is
updated to store this information directly inside the notification itself.
An new ``_message_sms`` helper method is introduced in SMS module allowing
to send messages using sms type and notification with a reduced parameters
number. It is just a shortcut to message_post, easier to use. Either it
computes default recipients on the record set, either it is based on given
partners and numbers to notify.
The following use cases are notably supported
* default computation: find customer, notify by sms;
* force recipients to notify by sms (partner_ids);
* give a set of numbers to notify by sms (sms_nubmers), not necessarily
linked to existing partners;
* force number / customer relationship independently of mobile number defined
on customer (for example when sending an SMS directly from a mobile field
on a lead linked to a customer);
Tests are updated accordingly. Performance tests are added in order to have
some insights on queries generated when sending SMS, like already done for
mail.thread alone.
Related to task 1922163
Linked to PR #33510
[1] see be27955136: performance and notification code improvements
Co-Authored-By: Thibault Delavallee <tde@odoo.com>
Co-Authored-By: Pierre Rousseau <pro@odoo.com>
Purpose of this commit is to improve and add tools, methods and data to test
mail and SMS features. We also add tests for current implementation of SMS
feature, allowing to better understand future changes.
[ADD] test_mail_full
* have a module depending on mail sub-applications like sms or snailmail.
Its purpose is to check that standard mail features work effectively with
all overrides and extra behaviors activated;
* add a new model specific for SMS gateway, with default recipient
computation;
* add SMS tests for SMS module adding SMS capabilities linked to mail
feature. This commit tests SMS feature before the upcoming refactoring
and improvement of SMS module in community: posting with SMS and sms
composer usage;
In test_mail
* add necessary mobile information on test partners;
* improve assertBusNotification that was not correctly asserting all items
in message of bus notifications;
In sms
* add mock for SMS sending. Purpose is to mock the connection to IAP
services by mocking the call to IAP server. It allows to perform SMS
tests without having to contact (and pay) for this service;
* allow some customization when calling the SMS gateway mock to simulate
errors and test corner cases;
Related to task 1922163
Linked to PR #34516