Commit Graph
9 Commits
Author SHA1 Message Date
Thibault Delavallée dad888de50 [REF] test_mail_full: cleanup test data, use default one
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
2021-11-16 16:58:35 +00:00
Thibault Delavallée 8c16737135 [REF] sms: rename sms.sms error_code to failure_type
PURPOSE

Prepare code cleaning and optimization in mail, mass_mailing and SMS by
cleaning models for readability and code complexity and footprint reduction.

SPECIFICATIONS

Be aligned with mail_mail and mass_mailing naming where failure_type is used
instead of error_code.

LINKS

Task ID-2377974
Community PR odoo/odoo#61467
Enterprise PR odoo/enterprise#14633
Upgrade PR odoo/upgrade#1907
2021-08-18 13:38:17 +00:00
Thibault Delavallée bbf4783ac6 [REF] mass_mailing: improve traces state management
PURPOSE

Improve modeling and performances of mass mailing by manually updating trace
status instead of using complex computed fields and lessening fields usage.

Remove some fields and keep only relevant metrics to simplify and clean trace
model.

SPECIFICATIONS

In this commit we clean the way trace state is managed. Currently it is a
computed field based on several datetime fields. However this generates a
lot of noise in the table as well as unnecessary computation

  * there are several columns (one for each state) storing datetime at
    which status was reached. Generally only 2 or 3 contain relevant
    information;
  * state could be set in code directly to avoid a computed field based on
    many triggers;
  * recomputing it each time a date changes is not necessarily necessary;
  * state value can always be updated manually as this is main done through
    some automated server update (mailgateway, link clicks, ...);

As trace states and its triggers should not be updated manually it is better
to synchronize it in code flow. When there is an exception or update done
through sending or gateway status is updated as well accordingly. Various
datetime fields are also updated at the same time. In order to align with
notification model mail and sms trace status are updated to a classic field.
Only last status update is now kept as there is no need to store the entire
history of status change.

We keep only a datetime for relevant metrics: open, reply and click. Other
datetime bring no real value. Knowing when a trace was in error or bounced
is not necessary. Indeed exception generally indicates a server issue (at
sending), cancel indicates a data issue (at sending) and bounce depends on
customer email server.

Status update is removed as using write_date is sufficient. Once created
traces are updated only when an external event occurs (opened, replied, ...).
It allows to simplify trace model.

We also rename ignored field into canceled to match naming use through mail
and sms.

QUERY COUNTERS

This change has some positive update on query counters when sending mailings
as traces have less unnecessary status update compared to priori this change.

LINKS

Task ID-2377974
Community PR odoo/odoo#61467
Enterprise PR odoo/enterprise#14633
Upgrade PR odoo/upgrade#1907
2021-08-18 13:38:08 +00:00
Thibault Delavallée 781b61405b [IMP] event_sms, link_tracker, sms, test_mail_full: improve SMS-based mailing tests
PURPOSE

Purpose is to have more tests when sending sms mailings, notably about
canceled or failed mails or sms as well as jinja and links rendering.

SPECIFICATIONS

In this commit we improve SMS Marketing mailing tests. We notably

  * add tests for void and invalid email and numbers. It allows to check they
    correctly update their trace status;
  * add tests for unsubscribe and view links embedded in sms marketing;
  * add tests to simulate a click on links sent through sms marketing and
    ensure click statistics are effectively updated;
  * ensure content of sent sms are checked;

Default content of mailings used in test is updated to ensure jinja is
correctly rendered, including links and some corner cases. This will also
helps ensuring behavior is kept when converting to QWeb.

In event we now correctly use sms gateway mock to ensure SMS finding.

In link_tracker a helper is added to check url tracking in plaintext content.

LINKS

Task ID-2508643
Followup of odoo/odoo#68874 (improve mail tests)
Prepares Task ID-27033 (support QWeb in templates)
Prepares Task ID-2377974 (clean trace and status management in mass mailing)
COM PR odoo/odoo#69461
ENT PR odoo/enterprise#17780

X-original-commit: f1182b9da9aca9e67518fc10c240f3b21895a7ab
2021-04-20 09:18:22 +00:00
Dharmraj Jhala 297c3d8378 [IMP] mass_mailing_sms: improve shortened URL detection in tests
Before this commit, in gateway tools, we used to consider URL as a
shortened which was having `/r` in it. However this is not true in
all cases. Any random URL can have `/r` in it but it might not be
a shortened one. It caused random failures on runbot time to time.

This commit makes a bit precise search (`/r/`) to consider URL as
a shortened one and thus avoiding those random test failures on the
runbot.

TaskID - 2276386

closes odoo/odoo#54944

X-original-commit: b8045b49d0693292e6240dfb3acd7c9a6450ad77
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-07-27 08:04:10 +00:00
Thibault Delavallée e8b1e2b7e4 [IMP] sms, link_tracker: clean some test helpers and add an helper to click SMS links
Clean some helpers, and add a helper to simulata a click on a shortened link
embedded in an SMS.

Task ID 2247037
Community PR #50384
2020-05-26 10:35:58 +00:00
Thibault Delavallée c13c3318b2 [FIX] sms: fix test helpers calling a removed method
Fix a crash when calling assertSMSStatistics without a number but taking the
number from a partner.

Also fix "sent" sms helper, content should be optional like other helpers.

Task ID 2247037
Community PR #50384
2020-05-26 10:35:58 +00:00
Thibault Delavallée 4a2ac044f8 [IMP] (test_)(mass_)mail(_full): rename and reorganize mail related test classes
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
2020-05-26 10:35:58 +00:00
Thibault Delavallée 14648272da [ADD] mass_mailing_sms: support SMS in mass mailing
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)
2019-08-12 12:00:22 +00:00