Commit Graph
132 Commits
Author SHA1 Message Date
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
Julien Banken fbb9a25367 [IMP] mail: revamp the mail composer
On the CRM module, the user can send an email to all the contacts
associated to the leads matching some criteria by (1) displaying the
list view, (2) applying a search filter, (3) clicking on the "EMAIL"
button and (4) checking a checkbox on the mail composer to ask the
server to use the active search. To do the same thing, the user can
(1) display the list view, (2) apply a search filter, (3) select all
the records and (3) click on the "EMAIL" button.

To avoid redundancy and improve the usability of the composer, we will
remove the search domain passing from the mail composer. Note that it
will still be possible to pass a search domain programmatically.

To improve the guidance of the mail composer, we will add helper
messages, update the labels and move the options in a dedicated pane.
The wording of the buttons will also be updated dynamically based on
the selected options.

Example: When the user enters something in the `mass_mailing_name` field
to create a new mass mailing campaign from the new message, the label of
the "Send" button will be set to "Send Mass Mailing" which gives more
indication on what will happen when the user clicks on it.

task-2523036

Part-of: odoo/odoo#71413
2021-09-30 13:31:52 +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
Victor FeyensandThibault Delavallée f85387ef33 [IMP] mail(_*): limit usage of search
Purpose of this commit is to globally improve code performance by limiting
search impact by

  * adding limits when only first found record id used;
  * avoid unnecessary searches when record set can be filtered instead;
  * using cache when accessing ir.model;

Task-2638444
PR odoo/odoo#76005

Co-Authored-By: Thibault Delavallée <tde@odoo.com>
Co-Authored-By: Victor Feyens <vfe@odoo.com>
2021-09-08 07:56:04 +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 19ce266dbf [REF] mail: rename notification of mail.mail to is_notification
RATIONALE

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

SPECIFICATIONS

Purpose is to prepare future changes by easing its grep. Notification is too
much heavily used through the codebase and finding it was quite hard among
other noise.

Rename ``notification`` field to ``is_notification``.

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 213d5d396c [MOV][REF] mail: add failure type on mail.mail model and move computation in mail
RATIONALE

Currently most of mail related failure types are computed in mass mailing.
This is mainly due to historical reasons. We could move some of this
computation directly at mail level and store failure information directly
in mail.mail records.

SPECIFICATIONS

Overall purpose is to get near SMS implementation where base composer prepare
more advanced pre computation: blacklist, optout, seen list.

Detect and store failure types directly on mail.mail: blacklist, optout,
duplicates, missing email, wrong email, ...

State computation is moved from mass mailing to mail. It is also improved as
currently everything is based on "first recipient found". This is globally
valid for mass mailing who uses default recipients (customer). However when
dealing with generic mailing this is not true anymore.

We choose to store and update status on mail.mail records only when having
a single recipient. When several recipients are defined on a given mail.mail
we cannot really decide a status prior to sending it and skip this computation.

Mass mailing override now uses information from mail.mail to update its linked
traces as computation is now delegated to base composer model.

LINKS

Task ID-2377974
Community PR odoo#61467
Enterprise PR odoo/enterprise#14633
Upgrade PR odoo/upgrade#1907
2021-08-18 13:38:17 +00:00
Thibault Delavallée c178a7829f [REF] mail, mass_mailing: improve mail.notification / mailing.trace failure_type
PURPOSE

Clean mailing code and ease understanding by replacing some old selection
keys by new ones better highlighting their use and aligned with other keys
used notably in mass mailing or SMS.

SPECIFICATIONS

Use shorted and mail-related keys. Indeed we already have sms_ and sn_ for
sms and snailmail related failure type. We therefore update failure_type for
mail as

  * "UNKNOWN" -> "unknown", a generic unknown of uncategorized error;
  * "RECIPIENT" -> "mail_email_missing", indicates email address is
    invalid;
  * "SMTP" -> "mail_smtp", connection issue;

"BOUNCE" key is never used and removed. Actually we use a bounce state for
bounced emails / traces so this key has no use.

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 d950b97dbf [REF] mass_mailing(_sms): improve mail/sms and traces failed/ignored state management
RATIONALE

Currently there are differences between mail and sms error management
especially when sending them in batch (mass mode). Moreover cancel
(ignored) and error (exception) states meaning is not clear. Finally
some failure types management between mail and sms can be cleaned.

SPECIFICATIONS

Meaning of ignored / error we want to enforce now is

  * error: there was something wrong at sending and user has an action to
    perform, i.e. server failed -> check its logs;
  * canceled: invalid recipients due to contact information or mailing
    configuration (blacklist, opt out, void or invalid email or phone number).
    In indicates issues linked to records themselves;

In this task we also add failure information granularity on mailing traces
linked to email like what is done currently on SMS. This can be related to
mailing (blacklist, optout, duplicates) or related to recipient (no recipient,
incorrectly formatted).

We also correctly distinguish optout from blacklist when sending SMS.

SPECIFIC USE CASES

  * recipient without email / number: mail / sms is set as canceled, trace is
    ignored;
  * recipient with invalid email (no @) / number (formatting impossible):
    mail / sms is set as canceled, trace is ignored;

    -> we now distinguish when possible a void email from a wrong email using
       a newly-added selection key (mail_email_missing);

  * recipient with email / number blacklisted: mail / sms is canceled, trace
    is ignored;
  * recipient with email / number that optouted from mailing: mail / sms is
    canceled, trace is ignored;
  * recipient with email that bounces: mail is sent and will be set as bounce
    when receiving bounce in gateway; trace follow same path;
  * recipient with number that bounces: not supported as currently no support
    of bounce through IAP;
  * mail server error, IAP error: mail / sms is set as exception / error,
    trace is set in exception;

This means we introduce new failure types on mailing.trace model to reflect
those failure types

  * ``mail_missing``: missing email (different from wrong value);
  * ``mail_bl``: blacklisted;
  * ``mail_optout``: optouted;
  * ``mail_dup``: duplicated email skipped during mass email send;

We introduce ``sms_optout`` on SMS and trace models as it was merged with
blacklist previously. Now both errors are distinguished.

LINKS

Task ID-2377974
Community PR odoo/odoo#61467
Enterprise PR odoo/enterprise#14633
Upgrade PR odoo/upgrade#1907
2021-08-18 13:37:33 +00:00
Gorash 7df343dd1b [IMP] base: QWeb _render return Markup unicode instead of utf8 bytes
In order to limit encoding decoding, the _render method returns a
unicode string in the markup safe object instead of a MarkupSafeBytes

closes odoo/odoo#68299

Related: odoo/upgrade#2454
Related: odoo/enterprise#17270
Signed-off-by: Antony Lesuisse (al) <al@openerp.com>
2021-08-03 16:20:22 +00:00
Kevin Baptiste 86aa7b78aa [IMP] *: introduce data-hotkey on form and modal views
Define `data-hotkey` on most used action buttons.

For the modals, the following keys are dedicated for "special"
actions:
 - Alt+G: add
 - Alt+V: save
 - Alt+Z: cancel

closes odoo/odoo#73275

Taskid: 2588233
Related: odoo/enterprise#19464
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2021-07-15 08:39:49 +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
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
Xavier Morel 34fbed3639 [FIX] mass_mailing: str/bytes confusion thing
qweb returns bytes, which would be stored in a dict's `body_html`,
which would then be stringified *but not decoded*.

Running with `-b` this gets flagged, it's probably better to fill the
dict with what's actually expected (text).
2021-04-29 05:34:21 +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
dht-odoo bf8bd2d4d5 [FW][FIX] mass_mailing: improve default values management when merging mailing lists
Since PR #55995 is merged, we get traceback while trying to merge the
mailing lists. This has recently been fixed in odoo/odoo@fc1005aa1e .

However code can still be improved to correctly take default values from
context instead of always relying on active_ids, as well as ensuring we
are effectively working on mailing lists.

Apart from that, this commit also shortens the action name to 'Merge'
from 'Merge Selected Mailing Lists'.

Task ID-2471692
COM PR odoo/odoo#67213

X-original-commit: 58722d7e855aac75f76e48c24265130c7f03cec9
2021-04-26 09:03:09 +00:00
Achraf (abz) 31730d74c8 [FIX] mass_mailing: Traceback on mass mailing list merging
What are the steps to reproduce your issue ?

    Try to merge two mailing lists

What is currently happening ?

    Traceback

opw-2504230

closes odoo/odoo#69601

X-original-commit: 66af485530cfc2f5e224b70850b011f0c05743d0
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-04-21 10:38:57 +00:00
Thibault Delavallée cbb911f530 [FIX] mass_mailing: keep invalid email on failed traces
SPECIFICATIONS

Traces are sent to normalized emails. If email is invalid email set on traces
is void as we cannot normalize it. In this commit we set it to the original
value of email, allowing to debug or at least understand what was wrong. It
also makes behavior coherent with SMS Marketing.

LINKS

Task ID-2508643
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: af841ccece14ffee0291f761d5363eceded65dfc
2021-04-20 09:18:22 +00:00
nounoubensebiaandThibault Delavallee e58379f769 [IMP] mass_mailing: create "add to mailing list" wizard
This commit introduces a new wizard that allows adding existing contacts of a
specific mailing list to another mailing.list.

It's typically used on the list view of a mailing.list where you tick a bunch
of contacts and add them all at once to another mailing.list (existing OR new
one that you create on the fly).

That tool will help users manage their mailing.list a bit easier and avoid some
tedious copy/pasting if mailing.lists need to share common contacts.

Wizard has two options: either simply create a new mailing list, either create
it and use it directly in a new mailing. It allows to cover the following
user flow
  * select contacts;
  * add them in a new list created on-the-fly;
  * jump on a new mailing targeting this mailing-list;
  * fill body, launch, enjoy !

Task-2453990

closes odoo/odoo#65965

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Co-authored-by: Noureddine Bensebia <neb@odoo.com>
Co-authored-by: Thibault Delavallee <tde@odoo.com>
2021-03-23 13:52:12 +00:00
Aurélien Warnon fb1b25802b [IMP] mass_mailing[_sms]: send user feedback when testing mass mailings/sms
This commit adds user feedback in the form of a message logged on the related
document (mailing.mailing) when testing a mailing/sms.

Before this change, when sending an email to your own mailbox for testing
purpose, or when sending an SMS to your phone, you did not get any interface
feedback on whether it worked or not.
Now, a logged message will show if it's successful and if not, explain why it
failed with a short error message (no IAP credits / misconfigured outgoing mail
server / ...).

In addition, email and phone inputs are now split on the '\n' character instead
of a coma, which allows easier validation of the email addresses.

Task-2375526

closes odoo/odoo#63421

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-01-28 09:23:35 +00:00
Ivan Yelizariev defa46715e [IMP] mass_mailing: show attachments composer mailings
This improvement allows user to review mail attachments that were sent using
composer in mass mail mode while creating a mass mailing on the fly. This is
achieved via `Action > Send email` menu and setting a mailing name.

For example, you sent different mails to different set of partners and you want
to check that you sent correct attachments and didn't miss anything. This
behavior is doable in Email Marketing apps. Before this commit you would need
to open different partners in Contacts app and check messages in the chatter.
Now attachments are displayed in composer.

STEPS:
* Install mass_mailing
* Open Contacts menu
* Select any number of records
* Click `Action > Send email`
* Set **Mass Mailing Name**
* Attach a file
* Send
* Open ``Email Marketing`` app
* Open the created mailing
* Check ``[Settings]`` tab

BEFORE: Attachments field is empty
AFTER: You can see the attachments sent to the partners

WHY: In 2014 attachments were added to mailing.mailing, but not to composer
https://github.com/odoo/odoo/commit/7e1e475d89694d09e62c33d2529fa061c7983dff

---

Task ID-2418997
opw-2410938
closes #63065
closes #63470

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-01-05 08:04:30 +00:00
Aurélien Warnon 8cd623e1d5 [IMP] mass_mailing[_sms]: pimp mailing list views & demo data
PURPOSE

Improves various views related to the mass mailing lists to help the user to
check the "health" of its lists at a glance.

SPECS

Introduce statistic fields on mailing.list:
- Total number of contacts (replaces the previous number of valid emails)
- Number of valid email contacts
- Number of valid SMS contacts
- Number of mailings sent using the list
- Percentage (and total count) of opted-out contacts
- Percentage (and total count) of blacklisted contacts
- Percentage of contacts having at least one bounced message

The statistics are shown on the kanban and also on the form view where they are
used to quickly reach the associated mailings / contacts.
Demo data were slightly adapted to show more interesting demos on views.

On a technical point of view, the various counts of contacts are made in a
single query using CASE WHEN syntax.
We need some entry points in the query to be able to dynamically add fields and
joins in the mass_mailing_sms app, but it's better than copy/pasting multiple
times a very similar query.

LINKS

Task 2182622
UPG PR odoo/upgrade#1990

closes odoo/odoo#53221

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-12-02 09:39:59 +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
Jérémy Hennecart eafbc90df8 [FIX] mass_mailing: try to render jinja content when using test wizards
Before when a user clicked on the button "Test", jinja syntax was not taken
into account for the test mail sent. If an error was present clicking on the
button did not raise an error before the cron was executed.

Now, if there is at least one record in the mailing model, the template is
correctly rendered and throws an error if there is a syntax error.

If we don't have any record to render the template, we fallback on the raw
content like before.

PR odoo/odoo#55696
Task ID-2312442

X-original-commit: 92aef67cc8cd1f3ac1ac28803f69aeab1d14ca97
2020-10-20 12:29:28 +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
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
Paul Morelle 544e22f4f2 [FIX] mass_mailing: respect mail_server_id for test emails
When sending a test email for a mass mailing, it was using the default
server, ignoring the one that could have been set on the mailing object.

This commit fixes this issue, so that the way the test emails are sent
is even closer to the real process.

closes odoo/odoo#55072

X-original-commit: 6af6e4714f2ccc703e9a3189b12a2317bd6af49c
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Paul Morelle <madprog@users.noreply.github.com>
2020-07-28 15:43:36 +00:00
Xavier Morel 6835aeb0de [REM] core, *: deprecate <act_window> and <report>
Convert deprecated tags through the codebase.
2020-07-28 13:03:13 +00:00
Martin Trigaux d9287caf94 [IMP] *: convert to private methods
render, render_template, load, activity_schedule_with_view,
get_website_pages should all be private:
It should not be possible to render an aribtrary template only with
its name or id

Still need to render some qweb views from js so the method
render_template is kept public.
This explains why the website editor still need read access on
ir.ui.view as we want to allow any snippet to be rendered.
2020-05-14 13:59:10 +02:00
Thibault Delavallée 3d86a29aeb [MOV] mail, various: move replace_local_links to render mixin
PURPOSE

Move links shortening tools on mail.render.mixin to have rendering and
post procesing tools available on that mixin.

LINKS

Task ID 1963529
Community PR odoo/odoo#32397
2020-03-24 10:24:44 +00:00
jerome hanke (jhk) 19d00d668a [FIX] mass_mailing: mailing.mailing does not use template_id
Steps to reproduce:
- install crm and mass_mailing
- go to crm > configuration > settings > activate leads
- go to crm > leads > select at least 2 leads > action > send mail
- set a subject > set a mass mailing name > send

Previous behavior:
you get a traceback
ValueError: Invalid field 'template_id' on model 'mailing.mailing'

Current behavior:
the mass mail is sent

opw-2212605

closes odoo/odoo#48088

X-original-commit: c87db90d5dbab4d02a9378a1fc905c9b2935cbe2
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Signed-off-by: mightyjol <jhk-odoo@users.noreply.github.com>
2020-03-20 09:47:19 +00:00
Loan (lse) 1c1d84255a [FIX] mass_mailing: remove wrong state default value from context
When testing to send an email of a campaign from the automation
marketing app, a traceback is thrown.

This is due to a context error. We define a default value which isn't
possible to be assigned for the variable.

opw-2190077

closes odoo/odoo#47039

X-original-commit: ff1d42e26bca3ce60697f9d4ee28f6aae5b7046b
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-03-05 18:41:12 +00:00
Nicolas Lempereur 1dc3301332 [FIX] mass_mailing: can unsubscribe in multidomain
The `unsubscribe` feature of mass mailings repose on having a link with
HREF attribute `/unsubscribe_from_list` inside the mail message.

When the mass mailing is sent:

- relative URL are replaced by absolute URL (`/unsubscribe_from_list` is
  replaced by `{system parameter web.base.url}/unsubscribe_from_list`)

- `{system parameter web.base.url}/unsubscribe_from_list` is replaced by
  the real mass mailing link containing info that will be used to
  unsubscribe the user.

But there was an issue in the case of multiple domain, if this scenario
happened:

- system parameter web.base.url is http://domain1
- a user use "Test" button on a mass mailing
- system parameter web.base.url becomes http://domain2
- the mass mailing is sent

The unsubscribe link is broken, this is because the implementation of
"Test Mailing" feature would update the mass mailing with absolute
links, so if the domain change, we the `unsubscribe` link will no longer
be found and replaced into the source.

opw-2124890
closes #42373

closes odoo/odoo#43308

X-original-commit: c5036bcb11fef8081f005fe4bd0025aea41401a8
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2020-01-14 17:48:26 +00:00
Thibault Delavallée 69ccabb212 [FIX] mail: restrict access to mail.mail model
From now on mail.mail is considered as a technical model. Indeed people should
not really manually craft mails by hand. Instead various functional flows
should either send mails, either craft mails based on some user input.

We therefore make mail restricted to admin users. Flows creating mail.mail
are updated to use sudo, and ensure it was done in a context that makes
sense to delegate this power to the user.

Task ID 1853147
PR #32243
2019-11-29 13:35:14 +00:00
Thibault Delavallée 1838191eec [REF] mail, various: improve mail creation calls, notably author and email from default computation
Purpose of this commit is to correctly compute author_id and email_from
in mail_message and mail_mail as they depends from each other. Moreover it
is a good idea in various flows to specify email and author when giving
creation values to avoid default computation that is not always guaranteed to
be accurate notably when involving super user.

Mail message creation could lead to desynchronized values between author
and email_from. This is improved with this commit by correctly inheriting
from default_get and computing both of them at the same time instead of having
two default values. Indeed they depend on each other.

Same thing is done for mail composer. Mail Thread offers a tool method to
find email_from / author_id based on having one of those values or current
user and it is called whenever necessary.

Some calls to mail template send_mail are also cleaned.

Task ID 1853147
PR #32243
2019-11-29 13:35:14 +00:00
laa 2b6ebb3df7 [IMP] mass_mailing : improve interface, UI and usability
In order to improve and clarify the mass-mailing (Email Marketing) module
several changes have been made

1 - Clarify the name of the application:
2 - Prevent the “Quick Add/Create” feature in the mailing kanban view
3 - Label and wording clarification in mailing_mailing form view :
4 - Clarify button names "Send now" ("put_in_queue")
5 - Mailing Form view layout
6 - Clarify the required field
7 - Clarify the readonly field
8 - Wording clarification if scheduling mail in the future
9 - Add a Placeholders tools page in the form view:
10 - Clarify the Campaigns view
11 - Clarify the Action Helpers

TASK-ID : 2046078

closes odoo/odoo#36124

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2019-09-06 07:47:13 +00:00
Thibault Delavallée 2f75534244 [FIX] mass_mailing: allow to delete recently scheduled mailings
Scheduling a mailing creates a wizard with a m2o linking the mailing. While
this wizard is still alive and not garbage collected it is impossible to
delete the mailing. This commit fixes that.

LINKS

Task 1997464
2019-08-09 11:49:33 +00:00
qmo-odoo a661b00015 [REF] utm,mass_mailing: replace mass mailing campaign by utm campaign
PURPOSE

This commit removes the mass_mailing.campaign model. Instead of having a fully
fledged model, we will simply inherit utm.campaign. We will also add relevant
statistics on utm campaign model in order to use it in various applications.

SPECIFICATIONS

This commit removes the mass_mailing.campaign model. Instead of having a fully
fledged model, we will simply inherit utm.campaign. This change implies that
mass_mailing.tag and mass_mailing.stage have to move to the utm model along
their associated views/data.

These changes were made so that campaigns could be used in the future
by social, mass_mailing and mass_sms and available in the same view

This commit also removes the source_id and the medium_id
fields on the campaign.

This commit also moves the unique_ab_testing field from the mass_mailing_campaign
to the mass_mailing model

Task ID: 2002029
PR: #34015
2019-08-02 12:32:35 +00:00
Thibault Delavallée 49d2899fbd [REF] mass_mailing: rename mail.mass_mailing model
PURPOSE

Mass mailing is currently a bit messy. As SMS will be added as a way to notify
people in mass through SMS let us take this opportunity to somehow clean this
application: organization, light code cleaning, model renaming.

SPECIFICATIONS

Rename mail.mass_mailing model to mailing.mailing. Rationale :

  * mailing is now a prefix for mass mailing models;
  * mailing.mailing is easier to read / find / understand;

Note that mail.mass_mailing.campaign is not updated as it is likely to be
removed soon and replaced by simple utm.campaign model.

MIGRATION

mail.mass_mailing model -> mailing.mailing
mail_mass_mailing table -> mailing_mailing

LINKS

Task ID 2037906
Preparing task ID 1997464 (SMS addition in mass mailing)
PR #34938
2019-07-17 15:50:33 +00:00
Thibault Delavallée 772e1c0cc4 [REF] mass_mailing: rename mail.mass_mailing.{.contact{_rel}, list{.merge}} models
PURPOSE

Mass mailing is currently a bit messy. As SMS will be added as a way to notify
people in mass through SMS let us take this opportunity to somehow clean this
application: organization, light code cleaning, model renaming.

SPECIFICATIONS

Rename mail.mass_mailing.list and mail.mass_mailing.list to mailing.list
and mailing.list.merge. Rename mail.mass_mailing.contact to mailing.contact.
Rename mail.mailing_list.list_contact_rel to mailing.contact.subscription.
Rationale :

  * those new names are easier to understand: mailing.list and mailing.contact
    are less mail-related, especially taking into account that SMS will allow
    to be less mail-oriented;
  * those names are easier to read / find / understand;
  * align wizard and sub-models naming with the main naming;
  * have a mailing as first part of namespacing;

MIGRATION

mail.mass_mailing.list model -> mailing.list
mail.mass_mailing.list.merge model -> mailing.list.merge
mail.mass_mailing.contact model -> mailing.contact
mail.mass_mailing.list_contact_rel model -> mailing.contact.subscription
mail_mass_mailing_contact_list_rel table -> mailing_contact_list_rel (specific
case of a decorated m2m)

fields updated (no column change)
  * mailing.list: subscription_contact_ids -> subscription_ids

LINKS

Task ID 2037906
Preparing task ID 1997464 (SMS addition in mass mailing)
PR #34938
2019-07-17 15:50:33 +00:00
Thibault Delavallée 2896aad34e [REF] mass_mailing: rename mail.mail.statistics and reporting model
PURPOSE

Mass mailing is currently a bit messy. As SMS will be added as a way to notify
people in mass through SMS let us take this opportunity to somehow clean this
application: organization, light code cleaning, model renaming.

SPECIFICATIONS

Rename mail.mail.statistics to mailing.trace and mail.statistics.report
to mail.trace.report. Rationale :

  * mail.mail.statistics is linked to mail.mail model. Soon this model will
    hold data related to SMS sending. It makes sense to be broader in the
    naming;
  * mailing.trace is more inlined with marketing.trace model that is the
    marketing automation model using it in marketing automation (enterprise
    application);
  * mailing.trace is shorter to write;
  * mail.statistics.report model should sense to be updated at the same
    time;

MIGRATION

mail.mail.statistics model -> mailing.trace
mail_mail_statistics table -> mailing_trace
mail.statistics.report model -> mail.trace.report

fields updated (w column change)
  * link.tracker.click: mail_stat_id -> mailing_trace_id

fields updated (no column change)
  * mail.mail: statistics_ids -> mailing_trace_ids
  * mail.mass_mailing: statistics_ids -> mailing_trace_ids

LINKS

Task ID 2037906
Preparing task ID 1997464 (SMS addition in mass mailing)
PR #34938
2019-07-17 15:39:06 +00:00
Adrian Torres 4b38cc6590 [REM] *: calls to @api.multi
Multi is the default api for methods, it is not necessary to explicitly
decorate methods with it, adds clutter and most people use it because
they see that the rest of the code uses it.

Done with `find . -type f -name '*.py' | xargs sed -i '/@api.multi/d'`
2019-07-17 14:13:12 +02:00
Hiral Bhavsar 3cd7ed07a2 [IMP] *: remove 'view_type' on window actions.
The old tree views don't really exist anymore, this odd pseudo-flag to
dispatch between "list" and "tree" tree views has no reason to remain.

Task 1937686

closes odoo/odoo#31243

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2019-06-17 11:34:17 +00:00
Christophe Simonis 71a50a2214 [MERGE] forward port branch saas-12.3 up to 409679866b 2019-06-06 11:54:35 +02:00
Nicolas Seinlet 3435f4a8b0 [FIX] mass_mailing: use subject field as subject
closes odoo/odoo#33494

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2019-05-20 09:11:07 +00:00
Xavier Morel 10f1a1a0c4 [REM] multi from ir.actions.act_window
Task 1843603

* src_model is redundant with binding_model_id
* multi -> binding_view_types (if empty => all views) (maybe should be
empty by default yo?)
* in convert, type => rec.get(type) but no @type possible on <act_window>...
* removed deprecated auto_refresh & auto_search (not used anywhere (?))

closes odoo/odoo#24738

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2019-05-27 12:00:39 +00:00
Christophe Simonis 6d4940675f [MERGE] forward port branch 12.0 up to ea1fc124ef 2019-04-09 11:11:48 +02:00
Thibault Delavallée b0491c4445 [FIX] mass_mailing: correctly find partner email in mass mailing
In mass mailing access to partners when performing a mass mailing has been
done in batch to speedup computation [1]. Emails are put into a dictionary
allowing to find back the email based on partner_id.

However the matching between the partner and its emails is done using a
shortcut using the current document ID as partner ID. It works when performing
a mass mailing on partners but fails when performing a mass mailing on models
having message_get_default_recipients not returning only emails. Currently
in saas-14 main models return only emails (crm, event, mailing contacts) but
other models may encounter issues (applicants, tickets).

This commit fixes it by correctly matching partner id and its found email.

Related to task ID 1924711
Linked to PR #32496

[1] See 65ed4553a5
2019-04-08 12:39:18 +00:00