Commit Graph
85 Commits
Author SHA1 Message Date
Olivier Dony e58471b148 [FIX] mail, mass_mailing: fix attachment ownership
Attachments that are uploaded on a record that isn't saved yet are
created with res_id set to 0. In the case of attachments linked through
a m2m rather than the usual (res_model, res_id), it means they may not
be readable afer the creation of the record, except by their creator.

Re-attaching them to the mailing / template at the end of the create()
call fixes the ownership.

Fixes #81935

closes odoo/odoo#82120

X-original-commit: 05fb705f2729ffdf07ab36accda20415a44e1aa6
Signed-off-by: Olivier Dony <odo@odoo.com>
2022-01-10 10:22:22 +00:00
Fabio Barbero 31e58ef720 [IMP] mass_mailing: allow responsible to turn off mailing reports
Purpose
=======
Allow users with enough access rights to disable next-day report on
mass mailing lists. The option has been added in the mass mailing
settings and is enabled by default. Mass mailing reports can also be
disabled with a "Turn off mailing reports" button in the report email
itself. Reports are enabled and disabled for all responsible.

Task-2692211

closes odoo/odoo#82430

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-01-10 08:46:31 +00:00
Philémon van Helden 3b833c73a7 [IMP] mass_mailing, *: improve mailing stat buttons
*mass_mailing_crm, mass_mailing_sale 

Currently, the Mailing stat buttons have a few problems.
The business reporting smart buttons send the user to a list of linked records,
which doesn't provide much value (e.g. what is the user supposed to do with a
list of 12345 leads?). They also show wrong values depending on access rights.
The Mailing KPI smart buttons lead to a blank screen if there's no data to show.

In this commit, we add/adapt all action helpers to help users understand what is
going on. For the business reporting smart buttons we instead send users to
relevant reporting actions, so they can make sense of the data we showed before.
The values of the business reporting smart buttons are now calculated as a super
user.
We also change some domains from the whole UTM Sale Domain to only using
Source ID, which simplifies computation while staying accurate.

task-2604515

closes odoo/odoo#76798

Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2021-11-30 16:53:33 +00:00
Munaf Khan b296e076d4 [IMP] mass_mailing: enable audience segmentation
Right now, in our mass mailing, marketing users refine the audience they are
going to reach with our beautiful domain selector/editor. The problem here
is that the criteria that 'filters' audience can be very common and might be
used in many mailings.

Such filters have to be re-created manually each time they are needed unless
one duplicates a sent mailing. Another possible workaround is to access this
form view while in debug mode so that one can copy and paste those domain
expressions. Unfortunately, none of those solutions are either ideal or
convenient. Especially during the onboarding where new users are not very
familiar with those notions yet.

This commit allow users to save filters on the mass mailings. That way
favorite filters can be re-used on the next mailing. For that, we added
a new model 'mailing.filter'. We do not use existing 'ir.filter' model as
its usage is not completely the same and as we do not want to bloat view
filters with filters created on the fly in marketing application. This new
model contains the following fields:

 - name (given by user while saving the filter)
 - mailing_domain
 - mailing_model_id (m2o for the recipient model)
 - mailing_model_name (technical name of recipient model)

Users can create the filters by setting domain and then hitting hollow star
icon next to 'Filter' m2o and saving it with the name they want. Same way
to delete the saved filter, user simply have to click the filled star icon
when filter is already set. This is done through a new widget that adds its
own behavior on top of m2o widget.

The saved filters can be also managed with a new menu named 'Favorite Filters'
under 'Configuration' menu of Email marketing.

Task-2092853

closes odoo/odoo#70859

Related: odoo/enterprise#21049
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-11-29 19:01:43 +00:00
Thibault Delavallée 072522a3e0 [FIX] mass_mailing: correctly set triggers
Some stored mailing fields should use the real mailing_model_id many2one
field for triggers and not sub-fields of it. As those are not stored this
may lead to unwanted writes.

Followup of odoo/odoo#41877

Spotted during Task-2092853

Part-of: odoo/odoo#70859
2021-11-29 19:01:42 +00:00
Fabio Barbero 43fc87ecc4 [IMP] mass_mailing: improve mailing form view
Purpose
=======

Improve UI of mass_mailing module to give the user a clearer view of the
mailings they send, enabling A/B test by default since it is not invasive.

Specifications
==============

Remove border and padding around the chatter in mass mailing form view.
Add sum and average in mailing list view for KPIs
Change sort order from sent_date to calendar_date
Move user_id in form view
Set group_mass_mailing_campaign to True by default

Task-2679537

closes odoo/odoo#79213

Related: odoo/enterprise#22202
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-11-24 13:16:52 +00:00
Aurélien Warnon 1e25946a76 [IMP] utm: globally improve UTM records management across all apps
PURPOSE

This commit consolidates UTM usage across all applications.

Global purpose is to avoid having undesired side-effects, such as unlinking an
utm.source/utm.medium/utm.campaign and at the same time cascading the deletion
to various records without noticing.

SPECS

ALLOW MORE PEOPLE TO CLEAN UTM RECORDS

Currently, not even the system administrator can delete utm.mediums and
utm.sources (he can only delete campaigns).

These were considered as "technical records", but allowing some cleanup is
a good idea since these records are often automatically generated and can
create a lot of unnecessary noise in the database.

That's why we now allow the following groups to delete all UTM records
(sources, mediums and campaigns):
- group_system
- group_mass_mailing_user
- group_social_manager (enterprise)

PREVENT DELETION

For some use cases, removing an utm.source/utm.medium/utm.campaign would
cascade delete the related record, which was unintended / hidden side effect.

These combinations were secured by preventing to unlink:
- mailing.mailing source_id field
  Trying to delete the utm.source will throw an error message
- mailing.mailing medium_id field
  Trying to delete the utm.medium will throw an error message
- hr.recruitment.source source_id field
  Trying to delete the utm.source will throw an error message

ADDING CLEAN ERROR MESSAGES

When trying to delete an UTM record that is linked with ondelete="restrict", we
improved the error message to give a clear explication to the user, e.g:

"You can't delete these UTM sources as they are linked to the following
mailings in the Mass Mailing APP, and deleting the source would break the
statistics: Newsletter"

SPECIFY 'ondelete' strategy

For a lot of uses of sources/mediums/campaigns, the 'ondelete' strategy was not
specified, leading to the confusion of "is this really how we want to handle
this?".

A lot of ondelete="set null" have been added in various field definitions to
ensure that this is the desired and logical strategy we want for that
specific model.

PREVENT REMOVING HARDCODED UTM RECORDS

In some functional flows, UTM records are hardcoded using their direct
record reference.
This is notably the case for the recruitment process and its creation of
aliases, and for the Email / SMS Marketing flows.

As deleting them would break these flows, we prevent their deletion in a
"api.ondelete" method.

ENFORCE NEW RULES WITH TESTS

A lot of python tests have been added to make sure we enforce the decisions
taken here above.

LINKS

ENT PR odoo/enterprise#19048
Task-2459480

closes odoo/odoo#72239

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-11-23 11:12:04 +00:00
Thibault Delavallée 73672cfc9f [FIX] mass_mailing: fix mail related values of statistics emails
When mailings have no responsible, KPIs emails are broken as there is no
from and to on the mail. This leads to mails being invalid and set in
exception.

Moreover currently author and from / to of those D+1 emails are not coherent
as author is current user (generally odoobot as this is generated through
a cron) while from and to are based on mailing responsible.

In this commit we make statistics emails more coherent
  * when a responsible is set on the mailing: author, from and to are linked
    to the responsible;
  * when there is no responsible, current user is set as it may be sent by
    regular people;
  * reply-to is set to company email as it is often the case with 'marketing'
    emails;

Task-2686586 (Repair mailing statistics email)

X-original-commit: 95a21ca16f560cf4341c547f6bc909d3261acd1b
Part-of: odoo/odoo#79877
2021-11-16 16:58:36 +00:00
Thibault Delavallée 8df08eac57 [FIX] mass_mailing: use queue to send statistics emails
When there is an issue updating mailing state (concurrent access, or some other
error that may happen), mailing statistics emails may be sent in loop. As we
do not think timing is so important, we now use the email queue to send
statistics emails.

Task-2686586 (Repair mailing statistics)

X-original-commit: f78ac45c2eafc3cf6b213e1f1608e76e243bd8d2
Part-of: odoo/odoo#79877
2021-11-16 16:58:36 +00:00
Thibault Delavallée 581286346a [FIX] mass_mailing(_sms/_crm/_sale): fix digest layout change breaking mailing statistics
Recently some "de-t-rawify" [1] was done through Odoo. A change in digest
layout broke mailing statistics. Indeed mailing statistics are build on digest
main layout to re-use it. In mailing case a ``kpi_name`` value was missing when
rendering statistics columns, leading to a crash. This is now fixed in both
mailing and sms marketing.

In this commit we also add tests for statistics emails (D+1 KPIs) rendering
for both mail and SMS marketing mailings. Email details are also tested
in order to better highlight future changes and tweaks in email sending
linked to D+1 KPIs emails.

Task-2641394 (Digest emails sending improvement)
Task-2582128 (Digest onboarding and usage improvement)
Task-2686586 (Repair mailing statistics email)

[1] odoo/odoo@c56e8c9f5a

X-original-commit: c9905ceb3172d8e80e3aff4ae9bc925dcb6b6519
Part-of: odoo/odoo#79877
2021-11-16 16:58:35 +00:00
Martin Trigaux b588a9caae [FIX] mass_mailing: avoid Expected singleton error
When writing on more than one record (e.g. via
_process_mass_mailing_queue cron)

X-original-commit: b18614bf99df47de77650f431e2062b8d2eacd06
Part-of: odoo/odoo#78259
2021-10-14 09:28:08 +00:00
Nicolas Bayet 4813f42997 [IMP] mail,*: replace jinja with qweb
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
2021-09-28 23:42:54 +00:00
Jérémy Hennecart bc8f4373c3 [IMP] mass_mailing(_sms): a/b testing
Manage correctly a/b testing in mass_mailing.
We can now organize a mass_mailing campaign by testing
multiple mailings for the recipients targeted (subject,
templates, design, ...)

For this a new tab on the mailing record is added to better
promote the existence of the feature.

When an user has the group to manage mailing campaign, he can
access the tab A/B Test. This tab allows to enable A/B testing
for the mailing. If there is no campaign set for the mailing,
one is automatically created allowing the user to continue
smoothly.

Once A/B testing enable, the percentage of recipients use can be
set for each mailings. Also, the user can choose the deciding factor
that will set the final mailing as winner.
In a case, the user is not in manual mode, he can set the schedule datetime
for sending the final mailing.

task-2123242
COM PR: odoo/odoo#75622
ENT PR: odoo/enterprise#20454
UPG PR: odoo/upgrade#2781

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-09-07 18:08:03 +00:00
Jérémy Hennecart c9870c73dd [FIX] mass_mailing: fix send with batch
This commit fixes a behavior when we send a batch of mailings
with no recipients.
When there is no recipients passed down, each mailing should
use it's own recipients and not the recipients of the first mailing.

closes odoo/odoo#75652

X-original-commit: 88d74fde5ce1ec70a88679429fda02180ce7fa81
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-08-26 15:18:01 +00:00
Thibault Delavallée ad2fe60525 [IMP] mass_mailing: improve trace views in mailing context
PURPOSE

Improve user experience by correctly contextualizing trace display when coming
from a mailing.

SPECIFICATIONS

Display relevant fields, hide other one (sms number when coming from a mail
mailing, email when coming from an sms marketing). Set some technical fields
as optional (message ID, status update). Use badge for status. Allow to open
recipient document directly from list view.

Improve wording (mail -> email). Reorder form view to try to have less noise
by hiding void fields and replacing the status bar (not clickable and any not
a business flow) by a classic field.

LINKS

Task ID-2377974
Community PR odoo/odoo#61467
Enterprise PR odoo/enterprise#14633
2021-08-18 13:38:17 +00:00
Thibault Delavallée 4e709ca3b7 [REF] mail, mass_mailing: stop using context for seen/optout list
Purpose of this commit is to keep blacklist and optout lists computation
at mailing level and correctly call it in composer. This allow to have
a clearer and more readable code as well as more robust.

Currently it is done by adding this information in context before invoking
the mail composer. It is now correctly done in composer: if a mailing is
linked to the composer, it calls both blacklist and optout lists methods.

LINKS

Task ID-2377974
Community PR odoo/odoo#61467
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 e9af609616 [IMP] mail, various: reorganize and lint composer action name
In this commit some reorganization is performed within mail compose message
code. Purpose is to reorder a bit methods by main usage: onchange, CRUD,
actions, values generation with rendering and template management.

Some renaming is performed on action methods, notably send_mail that has some
impact on sub-addons. Finally we also set onchange and sub-onchange methods
private.

No functional change should be implied by this commit.

LINKS

Task ID-2377974
Community PR odoo/odoo#61467
Enterprise PR odoo/enterprise#14633
2021-08-18 13:35:07 +00:00
std-odoo 5c44c5438d [IMP] mass_mailing: improve the default mail FROM used for mailing
Purpose
=======
Now that we try to not spoof the FROM SMTP headers, we want to improve
the default mail FROM used in mailing. By default, it's the email of
the current user, but if no mail server is configured for it, we will
use the notification email instead and encapsulate the email of the
user in it.

e.g.:
    Original: "Admin" < admin@odoo.com >
    Final: "Admin (admin@odoo.com)" < notifications@odoo.com >

Show a warning message if the configured mail server can not be used
for the email from.

Task-2367946
odoo/odoo#61853
odoo/upgrade#1903
2021-08-13 12:27:09 +00:00
Julien Banken ceb78ebf14 [IMP] mass_mailing: cosmetic changes on the tree view of the mass mailing model
PURPOSE

This commit aims to apply some cosmetic changes on the mass mailing
tree view to improve its usability.

SPECS

- New precedence order for the mass mailing views: With the kanban view,
mailings tend to pile up. When there are a lot of mailings, it can become
tricky to find a specific mailing given that the names of the mailing are
often generic and redondant (e.g. "Don't Miss Out", "Special Offer", ...)
For this reason, we will encourage people to use the list view by giving
the list view a higher precedence over the kanban view.
- Add progress bars for the delivered rate and the open rate (in the tree view).
- New column order for the tree view.
- Remove the unused and invisible field 'mailing_type' from the tree view.
- Set the fields 'mailing_model_id' and 'campaign_id' as optional.
- Minor decorator update.

LINKS

Task id: 2588188

closes odoo/odoo#73276

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-07-16 07:44:11 +00:00
Julien Banken c9a712ab25 [FIX] mass_mailing: Fix crash when trying to schedule a new compaing from the calendar view
To reproduce the error:

1. Open Email marketing
2. Go to the calendar view
3. Click on a cell

Explanation:

The function 'default_get' defines an argument named 'field' that conflicts
with the 'field' variable imported from the default 'odoo' package. When
two identifiers conflict, Python will use the variable defined in the closest
enclosing scope.

When the 'default_get' function accesses the 'Datetime' attribute of 'field',
the function will raise an exception as the identifier 'field' will refer to
the argument of the function and the property 'Datetime' will not defined on
that variable.

To solve the issue, we will rename the argument of the function 'default_get'
to 'fields_list' so that it will no longer conflict with the imported variable
'fields'.

Links:

Task id: 2581357

closes odoo/odoo#72857

X-original-commit: a9f6f708d40d0ecafb4a903eb9ff810a6c959416
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-06-28 10:52:03 +00:00
Romain Derie 92175d3341 [IMP] *: replace web.base.url ICP by helper method
Previous commit introduce an helper to get the most suited URL for a record
instead of always using the ICP, which is not correct in a website context.

This commit replaces calls to ICP by the helper method.

Community: https://github.com/odoo/odoo/pull/68201
Enterprise: https://github.com/odoo/enterprise/pull/17538
Upgrade: https://github.com/odoo/upgrade/pull/2372

task-2476101
2021-06-02 10:04:29 +00:00
Stéphane DebaucheandThibault Delavallée 2d6df1fe7a [IMP] mail, sms, mass_mailing: define rendering model at render level and improve mixin code
Currently ``mail.render.mixin`` offers rendering tools, some of them being
based on a ``model`` field. It allows to know which model to use to fetch
records on which we perform rendering. However this field is not defined at
mixin level but in inheriting models without being clearly implemented that
way (see ``mail.template`` or ``sms.template`` models).

In order to clean this mixin it is now defined at mixin level, using a
not stored computed field allowing to define how to find this model. Sub
models are updated accordingly.

Other cleaning is done in the render mixin
  * rename ``_render_template_qweb`` to ``_render_template_qweb_view``
    to indicate it works on views, not on raw qweb templates;
  * extract some common available variables for rendering in a method then
    called / upated for jinja and qweb views;
  * correctly set same rendering context for jinja and qweb views rendering;
  * allow to propagate an additional context from _render_field to sub
    rendering methods;
  * allow to propagate options through rendering methods (notably for escaping
    or safe attributes in jinja);
  * allow to specify engine used to render lang;
  * clean or update some docstrings;

Some tests are also added, as render mixin lacks some more detailed test to
ensure various use cases will be correctly migrated to other engines like
QWeb.

Task ID-2534550 (Template usage improvement)
Task ID-2477164 (Composer mixin)
Prepares Task ID-27033 (QWeb in templates)
COM PR odoo/odoo#70889
ENT PR odoo/enterprise#18352

Co-Authored-By: Stéphane Debauche <std@odoo.com>
Co-Authored-By: Thibault Delavallée <tde@odoo.com>
2021-06-01 09:05:42 +00:00
Thibault Delavallée ed508ee1bd [REF] mass_mailing: move mailing capability on model
PURPOSE

Remove hardcoded list of models on which mailing is possible. Indeed it is
not modular and not really smart with enterprise code not being reachable
in community.

SPECIFICATIONS

Replace hardcoded list of models on which mailing (both mail or sms) is
possible by a computed searchable field on ``ir.model`` based on a class
attribute.

It allows to cleanly define models having mass mailing capabilities and add
this attribute in bridge modules (when existing) or directly on base model
definition to avoid bridge modules.

In this commit we introduce a basic ``_mailing_enabled`` class attribute
activating mailing on model.

Mailing models may also have a ``_mailing_get_default_domain`` method allowing
to define a custom default domain when sending a marketing mailing on records
on this class.

Mailing models can now define a ``_mailing_get_opt_out_list(_sms)`` method
allowing to define custom behavior to fetch opt-outed records. Instead of
defining a model-based behavior on Mailing itself, it now calls the model
defined one. We still have two methods, one for mailing and one for SMS
opt out computation as it relies on different underlying models and fields.

LINKS

Task ID-2431217
COM PR odoo/odoo#67322
ENT PR odoo/enterprise#16876
UPG PR odoo/upgrade#2236
2021-05-26 07:57:47 +00:00
Thibault Delavallée 0ba617ca87 [FIX] mass_mailing: subject and preview should not be user translatable
Having those fields as translatable lead people to think those will be
translated into recipient's language. This is incorrect as translations
in Odoo are based on current user, not about any recipient who would
see the field value.

In this commit we therefore remove translation capabilities for
subject and preview. Indeed mailings currently offer no multi languages
support. Instead people should create separate mailings targetting
some specific recipients, based on lang or country for example.

Task ID-2535807

closes odoo/odoo#71093

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-05-20 10:47:03 +00:00
nounoubensebia 171eea3fae [IMP] mass_mailing[_sms], tools: make mass mailing form focus on body
Make the email body take the entire space to avoid having some wasted space,
this will also make the user have more focus when designing an email.

Revamp the settings notebook page in order to give more clarity to the user,
and move some fields from the main form have been moved to this section to
have more space in the bottom for the email body.

In the mailing form, when the mailing is sent or is being sent, set fields
which are no longer useful for the user to change to readonly mode.

Add a wizard that enables the user to schedule a mailing, the schedule field is
still kept in the form for the user to be able to change the date when the
mailing is in the queue (if they want to send it sooner).

Display an action helper-style content when the email is empty, because,
currently, the user is left with a big white screen when the email has no
content which is not desirable.

Update the html_empty function to take into account style attributes to better
match the editor's void content.

Hide A/B testing fields from SMS mailing form view as these are not supported
for SMS marketing.

Task-2469409

closes odoo/odoo#68882

Ent-pr: https://github.com/odoo/odoo/pull/68882
Related: odoo/enterprise#18391
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-05-20 09:40:40 +00:00
Thibault Delavallée c8aabac87d [IMP] mass mailing: update reply_to_mode keys
Propagate reply_to radio keys (update and new) to mass mailing in order to have
a coherent naming (was thread and email). This naming is also coherent with
gateway naming (message_update and message_new).

LINKS

Task ID-2117639
COM PR odoo/odoo#40931
ENT PR odoo/enterprise#17941
UPG PR odoo/upgrade#2419
2021-04-26 14:18:33 +00:00
shreya thakrar 59ce7d3969 [IMP] mail, mass_mailing: ease "reply to" fields understanding
PURPOSE

Right now, `reply_to` field on email template is misleading due to poor
explanation. This commit improves the placeholder and tooltip of the fields
to make the purpose of the field clearer especially for non technical users.

SPECIFICATIONS

Update reply-to field placeholder to "Preferred email address when sending
via mass mailing options".

Update reply-to field helper message to "Preferred email address when sending
via mass mailing options. <br> Only used when the answer is not added into
the original discussion.""

Update the no_auto_thread field label to "Reply to" in composer and introduce
a new radio button replacing the checkbox

  * The original discussion (thread)
  * Another email address (new)

Rename fields on mail_thread and wizard: ``no_auto_thread`` should be replaced
to ``reply_to_force_new`` to ease understanding and be prefixed by reply_to.

LINKS

Task ID-2117639
COM PR odoo/odoo#40931
ENT PR odoo/enterprise#17941
UPG PR odoo/upgrade#2419
2021-04-26 13:53:20 +00:00
Thibault Delavallée b96d941aaa [IMP] mail, (test)_mass_mailing, test_mail_full: improve email-based mailing tests
PURPOSE

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

SPECIFICATIONS

In this commit we improve Email 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 mass mailing emails;
  * add tests to simulate a click on links sent through mass mailing and
    ensure click statistics are effectively updated;
  * add tests to simulate bounce emails coming back to the mail gateway;

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.

Various docstrings are added to helpers and custom asserts.

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: 7b940ad46bde30f9bf16837f7bff5a70cd88c640
2021-04-20 09:18:21 +00:00
Lucas Perais (lpe) 8f033a2b50 [FIX] mass_mailing: typo that broke ensure_one down the line
Sometimes it crashed when the domain used for the mailing cron
returned more than one record

source commit: 1738f9c8f7

closes odoo/odoo#67556

X-original-commit: cb97f7c64a1fa575799a7832cb52e433436581e0
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-03-09 16:35:48 +00:00
Julien Castiaux 2ba1e83253 [IMP] mass_mailing: use cron trigger to send "now"
The "launch" button of an email campaign mark the current campaign ready
to be processed. As sending all the mails is a pretty heavy operation,
it is done asynchronously in a cron. The cron was running every hour, it
means the cron was running even if there was no active campaign and it
has a best precision of 1 hour.

We now use the new mechanism of cron triggers (4b28f11) to schedule the
con execution at the time the campaign is configured to be sent. It
achieves a better precision and ensures the cron only runs when there are
stuff to process.

We still let the cron run once a day as a security until the cron
mechanisme proves reliable.

closes odoo/odoo#65124

Task: 2416741
Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.com>
2021-03-09 09:31:24 +00:00
Damien Abeloos 62ae7896f5 [IMP] mass_mailing: add various usability improvements
* When clicking on a button that is a preview for a "mass mailing",
  always open it in a new window for the user that is editing the form, so
  that changes are not discarded (when leaving the page).
    - The option "Open in a new window" remains effective for the recipients of the mail.

* Rename Mailing Campaign to Campaign : this is just a mailing campaign,
  they are used everywhere in the marketing scope now. And it can be part of
  a multi-channel campaign.

* Show/hide mailings count depending on settings :
    - Mailing Campaign must be activated in the email marketing settings in
    order to display the Mailings count in the utm.campaign kanban view

* When there is no matching recipient for a mailing campaign,
  properly display 0 / 0 instead of 0 / 1 to better indicate that it is
  not expected that anyone will receive an email.

Task ID : 2410217
PR : https://github.com/odoo/odoo/pull/63370
2021-03-03 12:12:52 +00:00
Julien Castiaux 412973f7d8 [FIX] mass_mailing: wrong clicks_ratio compute
Fine tuning of 2d63fff13be6d19170fb58fd0248e879e2be2de8

closes odoo/odoo#67173

X-original-commit: d4210430a911fb23d6fce5dbd4279f03f134cd2e
Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.com>
2021-03-03 15:36:54 +00:00
Julien Castiaux 917964266e [FIX] mass_mailing: wrong clicks_ratio compute
The `clicks_ratio` field was computed outside of its compute method,
this is illegale as the ORM cannot protect the field from being included
in the "towrite" structure.

Backport of 7acc035

closes odoo/odoo#67111

X-original-commit: ca1f2e9d1285a02ebaf2502eaeb3d38feea6c477
Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.com>
2021-03-02 17:44:20 +00:00
Thibault Delavallée 1b8aa71e6b [FIX] mass_mailing: fix batch call of action_send_mail
Loop inner calls should use mailing not self.

Task ID-2455433

closes odoo/odoo#65755

X-original-commit: d63734eb6e00c079ad9c0658674efb2321610173
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-02-09 07:55:23 +00:00
Raphael Collet 60e0c99ede [REV] mass_mailing: correctly support mailing domain from default context value
This partially reverts commit 1ec887b773,
which was a hack to deal with the issue.  From now on, the first call to
onchange() no longer computes editable fields when they are given a
default value.

X-original-commit: c01657d345f59e3ccea70a5004732050fae99320
2021-01-13 16:19:15 +00:00
Francois (fge) 1738f9c8f7 [IMP] mass_mailing_sms: support KPIs emails for sms mailings
Currently KPIs reporting on mailings is supported only for mail mailings.
However we think it is interesting to have insights on SMS mailings as well
even if less KPIs are available. Indeed we currently do not support open
or reply KPIs.

This report will be sent by email 24 hours after the campaign sms are sent.
Modification are done of the digest_mail_layout to be able to use it to
generate the KPI report for Email or SMS mass mailing campaigns.

The goal is to have a single template that can be used for both SMS and email
mailings.

Some wording is also improved in various places of KPIs process.

Task ID-2274770
COM PR odoo/odoo#56887
UPG PR odoo/upgrade#1744
2020-12-03 12:46:51 +00:00
Victor FeyensandThibault Delavallée 3dc757008f [IMP] mass_mailing: support batch creation
See merge commit for more details.

Task ID-2330149
COM PR odoo/odoo#61246
ENT PR odoo/enterprise#14561

Co-Authored-By: Thibault Delavallée <tde@odoo.com>
Co-Authored-By: Victor Feyens <vfe@odoo.com>
2020-12-03 10:18:56 +00:00
Nasreddin (bon)andAurélien Warnon e598e74648 [IMP] mass_mailing(_sms): support calendar view and ease scheduling
PURPOSE

To ease the scheduling process, we introduce a new calendar view on mailings
that allows to easily schedule your communications. In addition, mailings and
sms views are improved to ease global usability especially about scheduling
configuration.

SPECIFICATIONSS

- add a calendar view to allow marketeers to either schedule or overview their
  ongoing mailings/sms;
  Side note: inspired by what has been done with Social Posts

- improve the scheduling flow by allowing to configure it directly in the form
  view using fields rather than action buttons that open an extra window. This
  implied removing the schedule wizard as everything is now configured directly
  from the mailing form view;

- add a constraint on 'schedule_date' to make sure it's not scheduled in the
  past;

- compute a calendar_date to be used by calendar view. It is either sent
date (if sent), next departure of cron (if in queue) or schedule date (if
scheduled).

- update mass_mailing_sms to match scheduling flow of emails and adjust the
  'sms_force_send' display to ease understanding ;

LINKS

Task ID-2202759
COM PR odoo/odoo#57000
ENT PR odoo/enterprise#12920
UPG PR odoo/upgrade#1736

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Co-authored-by: Aurélien Warnon <awa@odoo.com>
2020-11-24 15:25:50 +00:00
Priyanka Kakadiya 7f5ef74b90 [FIX] mass_mailing: do not add opt_out by default on mailing domains
In mass mailing (_sms) when you set `Mailing Contact` as target model the
`opt_out` field is added to the default domain. However as it is a computed
field depending on a single mailing list given in context it should not be
used that way. Moreover current implementation raises a warning as only some
custom views can use this field accordingly.

This commit removes `opt_out` field being set by default in mailing domain and
also removes the UserError raised by the search function, thus avoiding
unwanted warnings.

Opt-out field is automatically taken into account when sending mass mailing on
contacts (see ``_get_opt_out_list``) so removing it from domain is actually
even better for coherency. Opt-out is not an option in sending process.

Task Id-2300427
PR #57310

closes odoo/odoo#60262

X-original-commit: 5ccf5b51feaa348d775890e107fd30cd750699d8
Related: odoo/enterprise#14200
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-10-19 14:31:54 +00:00
Martin Trigaux 2683184aa6 [FIX] *: fix all the typos
And other reported English mistakes in source string
Courtesy of Transifex translators

And remove leftover from gengo

closes odoo/odoo#59022

X-original-commit: 26efc84c5cac47a2cc83d7b084f8b71528fec6c7
Related: odoo/enterprise#13781
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-10-05 09:36:34 +00:00
Olivier Dony d6e734d436 [FIX] mass_mailing: speed up recipients filtering
Using a `set` to lookup recipients that already received an email is
much faster on average than with a list. `x in list` is O(n) on
average, whereas `x in set` closer to O(1) on average.

Example: for a sample mailing with 50k recipients that is half-through,
filtering the remaining half (25k) took 10s with a list, and 1s with
the set.

X-original-commit: 7948698cc6e6b0af5fc84847ea7ec166882eda0b
2020-09-05 04:34:13 +00:00
std-odoo 0c6dcb5b88 [FIX] mass_mailing: fix performance issue on the "total" field
Issue
=====
There's a performance issue when computing the total field on the
mailing model. When there're a lot of record (e.g. 500.000 leads).

This is because when we compute the field, we are fetching all the
records and then we calculate the length of the array.

We can just use a `search_count` and let Postgre count the records.

Task-2313123

closes odoo/odoo#56298

X-original-commit: d1ab37de0c4782b4f12b44f9858446b4c9c7dc08
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-08-21 12:11:11 +00:00
Raphael Collet 8486007832 [FIX] mass_mailing: query without ids in compute methods 2020-08-20 13:39:04 +00:00
std-odoo 13d1f3e012 [IMP] mass_mailing: allow to customize the mail preview
Purpose
=======
Allow to customize the preview text in mass mailing.

Specifications
==============
We do not generate the preview text anymore, instead we add
a new field to let the user choose want he want to put into
the preview. As the preview is added in the mail body, it
supports dynamic placeholders.

Rename "View in browser" into "View Online" because the text
will be displayed in the preview if the snippet is added at
the beginning of the email. And we want to make it shorter.

Remove the alt attribute of the image tag which are not part
of the "email content" in the mass mailing template.
So, we improve the email preview in the mail clients
(otherwise the mail client include the alt attribute into the
preview).

Task-2313872

closes odoo/odoo#55695

Related: odoo/upgrade#1584
Related: odoo/enterprise#12323
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-08-18 08:47:28 +00:00
Martin Trigaux 6156f98288 [FIX] *: adapt action content retrieval
Use _for_xml_id to replace all the self.env.ref().read()[0]
This has the advantage of having a single point of control and to add
the fields filtering and model verification.

Add sudo for other operations on ir.actions.*
2020-08-17 09:09:02 +00:00
xO-Tx f7862cd2b5 [IMP] mass_mailing[_sms]: update subject and allow emoji support for sms content
PURPOSE

Subject field on mailing has not the same use in email marketing (subject of
emails) and in SMS maketing (used internally as there is no subject in SMS).

Purpose of this commit is to improve mailing form view to better distinguish
email and SMS flows.

SPECIFICATIONS

This commit changes helper for mailing subject and update its label according
to mailing_type (mail or sms), as well as the sms content field to enable emoji
support in mailing subjects. This is done through a fake sms_subject field
that is a text without emojis while standard subject allows emojis. Helpers
depends on the displayed field.

Override CRUD to synchronize sms_subject on subject to have only one field
used to store data.

Also allow emojis in SMS content, suing the enable_emojis option.

LINKS

Task ID-2224393
PR #49096
2020-08-11 14:38:33 +00:00
std-odoo ed4846dd9d [IMP] mass_mailing: add preview block for mailings
PURPOSE

When displaying an email in a list the mail client (gmail, outlook...) computes
a preview based on the content. This preview is generally not well computed as
it contains a lot of garbage and tags while it should contain only relevant
text.

SPECIFICATIONS

To build this preview, all mail clients read the content of the email.
The only way to be able to customize the preview is to add an invisible
HTML element at the beginning of the email with the wanted preview text.

We add at the end of the preview `&zwnj;` (zero-width non-joiner) to
fill the end of the preview in order to not have the beginning of the
mail at the end of the preview. It doesn't work with simple space as
the mail clients trim each HTML element content.

Task ID-2172125
PR #49886
2020-08-05 13:55:04 +00:00
Sébastien Mottet (oms) ac0579263b [IMP] mass_mailing: add 'view in browser' link in mailings
PURPOSE

Add a block that allows recipients to check the email in a browser in case
their mail service provider does not render it well or to see it full screen.

SPECIFICATIONS

A thumbnail has been added in the snippet thumbnails list of the mail editor.
It allows to add an header snippet. This snippet contains a link allowing the
recipient to see the mail in its browser instead of its mail client.

Add a route to display a mailing content. This route should be recipient
dependent as mailings could contain jinja markers. Using the same access token
and check as unsubscribe route this public route allows to display a mailing
content directly rendered for a given customer.

_get_unsubscribe_url method is moved from mail_mail to mailing as it does
not really belong to the mail model. Indeed it is mailing dependent.

A view URL leading to the view in browser route is added. It is managed like
the unsubscribe url: magically avoid shortening, magically rewrite when
sending email.

Task ID-2239327
PR #49886
2020-08-05 13:55:04 +00:00
Thibault Delavallée fd62fa16ad [FIX] link_tracker, mass_mailing: make convert_link work in batch
In this commit we correctly use mailing variable inside a loop
on self to enable multi-mode on convert_links method.

We also update link_tracker shortening methods docstrings. We
add some explanation, notably about parameters. A variable is
fixed to better indicate parameter content (html -> content).

closes odoo/odoo#55452

X-original-commit: 3e1633d5b3590ec5657b851c21cbae059944d964
Related: odoo/enterprise#12218
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-08-05 10:39:09 +00:00