Commit Graph
81 Commits
Author SHA1 Message Date
std-odoo eae1a0a7ab [FIX] mass_mailing: the blank.gif image in the emails always raise a 500 error
Bug
===
Since 6185f14807 we check the <mail.mail>
existence before marking the <mailing.trace> as opened, but since
57ae1b9b8b61f5f4719a8a81e9d0d21fab58cfda we remove the <mail.mail>
automatically when we send them.

The result is that this endpoint always raise a 500 error.

To be: the <mail.mail> existence shouldn't be checked in this endpoint
(the token is valid for the raw integer id).

Task-3234519

closes odoo/odoo#115842

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-03-21 10:44:40 +01:00
Benoit Socias fb9efde4f3 [FIX] *: replace werkzeug's Response by odoo's Response
*: base, http_routing, mass_mailing, web, web_editor, website_slides

In some situations `werkzeug.wrappers.Response` are used instead of
`odoo.http.Reponse` that extends it.
This is a problem because since [1] the calls to `set_cookie` expect it
to accept the `cookie_type` parameter, which is not the case in the base
werkzeug implementation.

This commit replaces the `werkzeug.wrappers.Response` by
`odoo.http.Response`.

[1]: https://github.com/odoo/odoo/commit/2cbda6c98ee947cea1d06c09880eee8c758304a8

closes odoo/odoo#112827

X-original-commit: 28da08292b7028575e628c5ad846fc05d30498f2
Signed-off-by: Julien Castiaux (juc) <juc@odoo.com>
2023-02-16 09:01:07 +01:00
Julien Castiaux 3d1f486bcc [IMP] *: update modules to use the new geoip API
request.geoip is no more a dictionnary cached in the session. It is now
a full blown object with lazy and smart geolocalisation capabilities.

Among other things, the previous dictionnary API is now deprecated. The
changes are:

* `request.geoip['country_name']` -> `request.geoip.country_name`
* `request.geoip['country_code']` -> `request.geoip.country_code`
* `request.geoip['city']` -> `request.geoip.city.name`
* `request.geoip['latitude']` -> `request.geoip.location.latitude`
* `request.geoip['longitude']` -> `request.geoip.location.longitude`
* `request.geoip['region']` -> `(request.geoip.subdivisions[0].iso_code if request.geoip.subdivisions else None)`
* `request.geoip['time_zone']` -> `request.geoip.location.time_zone`

It is safe to access all the attributes. Doing `request.geoip.city.name`
when the geolocalization failed (missing db, invalid address, ...)
evaluates to None. It does not raise an AttributeError.

Task: 2848206
Part-of: odoo/odoo#91337
2023-01-03 13:16:02 +01:00
Thibault Delavallée efe53fbe88 [IMP] mass_mailing: improve routes naming
Rename main routes, and keep a legacy for the main unsubscribe route to
keep retro compatibility for existing mailings.

Task-2710804 (Mail: Clean MailThread API)
Task-2669037 (Mass Mailing: Subscription page code cleaning)
Prepares Task-2150462 (Mass Mailing: Unsubscribe flow refactoring)

Part-of: odoo/odoo#106568
2022-11-25 18:55:21 +01:00
Thibault Delavallée 6185f14807 [REF] mass_mailing: rename hash methods
PURPOSE

Overall cleaning of subscription and exclusion management code from portal.

SPECIFICATIONS

In this commit we rename methods generating tokens (for recipients and report
management). Otherwise it is hard to distinguish them as naming is not really
convenient to use

  * _unsubscribe_token -> was actually generating token for a given recipient
    on a given mailing;
  * _get_unsubscribe_token -> was actually generating token for mailing
    users to deactivate D+1 KPI reporting;

Hash for mail tracking is also moved in its own method to avoid having the
same code twice. Better delegate it to a tool sub method.

Task-2710804 (Mail: Clean MailThread API)
Task-2669037 (Mass Mailing: Subscription page code cleaning)
Prepares Task-2150462 (Mass Mailing: Unsubscribe flow refactoring)

Part-of: odoo/odoo#106568
2022-11-25 18:55:21 +01:00
Thibault Delavallée b4559e55d2 [REF] mass_mailing: rename templates and controller methods
PURPOSE

Overall cleaning of subscription and exclusion list management code from portal.

SPECIFICATIONS

Rename templates to better understand their purpose. Current naming is not
crystal clear.

Rename controller methods in order to be clearer and more aligned with current
guidelines. Notably namespace by mailing, try to be clearer about their
purpose, ...

No change should occur with this commit.

Task-2710804 (Mail: Clean MailThread API)
Task-2669037 (Mass Mailing: Subscription page code cleaning)
Prepares Task-2150462 (Mass Mailing: Unsubscribe flow refactoring)

Part-of: odoo/odoo#106568
2022-11-25 18:55:21 +01:00
Thibault Delavallée f0bbe9561f [REF] mail, mass_mailing: improve logging of emails exclusion
Purpose of this commit is to use the newly introduced feature to log a message
when adding or removing an entry in block list of emails in email marketing
application.

Logging itself is improved, as it now contains

  * source of the request (unsubscribe link, or manual ask through the portal
    unsubscription page);
  * link to the source mailing;
  * link to the document that generated the click (a mailing contact, a sales
    order, ...);

Task-2710804 (Mail: Clean MailThread API)
Prepares Task-2150462 (Mass Mailing: Unsubscribe flow refactoring)

Part-of: odoo/odoo#106568
2022-11-25 18:55:20 +01:00
Thibault Delavallée 3d5b012501 [REF] mail, various: cleanup usage of options in render mixin
Due to recent improvements (Jinja -> Qweb, safe rendering) rendering API
supports several ways of giving options to the rendering process. Those
have mainly two usage

  * ``preserve_comments`` : keep comments in rendered HTML, used notably
    in mass mailing or digest to keep browser-specific comments;
  * ``post_process`` : perform a post processing on rendered HTML, used notably
    to process local links and add tracking to shortened links;

All those are now given directly inside an optional ``options`` parameter
given to ``_render_field`` and its sub-method ``_render_template``.

They can also be defined as field level, using ``render_options`` field
parameter. Some fields are updated

  * composer mixin body (which impacts all inheriting models, notably
    mail composer, survey and elearning invite wizards as well as appraisal
    and appraisal feedback): post processing is now always done by default.
    It was already done manually in calls that can be simplified;
  * mail template body_html: post processing is now always done by default. It
    was already done manually in calls that can be simplified;
  * mailing body_html and preview are now post processed by default. It was
    already the case in testing wizard. Preview is updated to avoid post
    processing of links, as it was before. Remaining use case is the sending
    which uses the mail composer, therefore was already post processed;

Finally some 'compute_lang' are explicitly added in _render_field calls in
order to be explicit on what we want, instead of being unsure.

Task-2710804 (Mail: Clean MailThread API)
Prepares Task-2088884 (Mail: Use editable computed stored fields in composer)

Part-of: odoo/odoo#106072
2022-11-21 19:55:13 +01:00
Patrick Hoste 34f1274fe6 [IMP] mass_mailing: add a mobile preview to mailing editor
PURPOSE

With this commit you can now see how the mailing you're creating
will look like on a mobile.

LINKS

Task-2818037

closes odoo/odoo#101822

X-original-commit: 2b195390e15c9ed3b54f0adf0afc439f06429616
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-10-02 12:19:41 +02:00
Pierre-Yves Dufays 5ae80f1dcc [FIX] mass_mailing: render placeholder in mailing web view
The placeholders were rendered as empty string in the web version of the
mailing (accessed through the "view online" link in the email). This fixes the
problem.

Technical note: we cannot use mail_mail.body_html (which contains already the
rendered placeholder for the specific user) as it is marked for deletion so we
render it from mailing_mailing.body_html.

Task-2954282

closes odoo/odoo#100984

X-original-commit: 6b2d5db762ef198e9f07af95116c166b027eb383
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-09-23 14:36:52 +02:00
Thibault Delavallée f446e54cbd [MOV] mass_mailing: reorganize controllers and templates
PURPOSE

Reorganize addon according to guidelines, helping finding and updating

SPECIFICATIONS

Reorganize templates in order to see a bit what's going on here. Notably split
subscription (opt-out, blacklist) from management (view, reporting) templates.

Reorganize controller code by main section in order to separate a bit various
code purpose.

This commit contains only file split / renaming and code move.

Task-2864264 (Mass Mailing Module Reorganization)

Part-of: odoo/odoo#92509
2022-05-31 16:02:25 +02:00
Fabio Barbero fc79bd1e0e [IMP] sm modules: "neutralise" genders
Purpose
=======
Change all masculine nouns in Odoo's code to neutral nouns (when
possible), making sure that demo data is correctly handled. This is
particularly important since our code is open source, and nowadays lots
of machine learning models are trained on open source repositories.

With this small change we contribute to training more "fair" models, and
teaching models that "employee" or "user" != "he".

This also affects some text visible by the user, hence making it more
inclusive for Odoo users.

Task-2853046

closes odoo/odoo#91292

Related: odoo/enterprise#27302
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-05-16 10:09:32 +02:00
Julien Castiaux c46f4b908a [IMP] *: request.session.geoip -> request.geoip
Commit "[IMP] core: don't save visitor default session" moved the geoip
from the session to the request with a deprecation warning. This commit
adapts the remaining modules to use `request.geoip` instead of
`request.session.geoip`.

Geoip is always set on the request but it can be an empty dictionnary in
case the geolocalization failed.

closes odoo/odoo#86015

Task: 2789035
Related: odoo/enterprise#25192
Signed-off-by: Julien Castiaux <juc@odoo.com>
2022-04-05 14:13:54 +02: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
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
Jeremy Kersten 478068c829 [IMP] *: always use Odoo Response
This branch adds request.redirect on all requests.
In case of a front end request, we do an url_for to the location.

We removed redirect_with_hash that was only for retro compatibility

local_redirect has been renamed to redirect_query, and param keep_hash has been
removed and moved.

Default code for redirect is 303 now instead of 302.

Now redirect and redirect_query make local redirect by default, you need to
pass local=False to make external redirect.

All werkeug.utils.redirect has been replaced by request.redirect.

Http.redirect now use an http.Response type, and it become easy to add an
override like 'set_cookies' e.g.

Dispatch of a website.page return an http.response too, so we first need to
check if it is a cached version before to check if it is an Odoo Response.

Migrate your code:

http.redirect -> request.redirect(location, code, local)
http.local_redirect -> request.redirect_query(location, query, code, local)
http.redirect_with_hash -> request.redirect

Courtesy of odony for help and review ;)

closes odoo/odoo#72599

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2021-07-08 07:00:06 +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
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
Martin Trigaux 400cc4f14e [FIX] *: correct all or improve code translation lookup
This commit fixes all issues detected by the new pylint
gettext-variable test.
It converts some calls to the new syntax
  _("Foo %s", bar)

to progressively migrate the code to the new syntax.

A few calls were not technically incorrect but still detected by the
linter.

  _("Foo" +
    "Bar")

has been converted to

  _("Foo"
    "Bar")

as it has the same effect and make sure the argument is of type
asteroid.Const instead of BinOp).

closes odoo/odoo#53683

Related: odoo/enterprise#11467
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-06-30 10:19:59 +00:00
std-odoo 1c7c837a10 [FIX] mass_mailing: improve opened traces tracking
Purpose of this commit is to improve tracking of opened traces. Notably
a token is added to ensure we do not mess with traces and have unique
tracking URLs.

MIGRATION REMARK

Emails sent before the migration will not be marked as opened anymore after
migration. We recommend to avoid sending statistically important mass mailings
about one week before migrating database. Indeed statistics show that most of
open emails happen within the first week after being sent.

Task 2223146

closes odoo/odoo#49139

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-05-18 08:30:59 +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
Martin Trigaux 5d57e1862f [MERGE] Forward port of saas-12.4 to master up to beba36416f
closes odoo/odoo#34924

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-07-16 15:45:24 +00:00
Martin Trigaux beba36416f [MERGE] Forward port of saas-12.3 to saas-12.4 up to 40421be73c 2019-07-16 16:36:40 +02:00
Martin Trigaux cf8e74a1a7 [MERGE] Forward port of 12.0 to saas-12.2 up to 1bd434da34
closes odoo/odoo#34901

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-07-16 09:14:17 +00:00
Martin Trigaux 1bd434da34 [MERGE] Forward port of saas-11.3 to 12.0 up to d8072d54ac 2019-07-16 09:22:49 +02:00
Julien Castiaux ad4a618a82 [FIX] mass_mailing: disable sitemap on unsubscribe route
Insall website and mass_mailing, go to the `/sitemap.xml` url, the
`/unsubscribe_from_list` url is listed, it should not.

opw-2033251

closes odoo/odoo#34677

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-07-09 07:52:25 +00:00
Raphael Collet caf900e89e [FIX] *: use auth='public' in controllers that use request.env
The following trick used to work, because `sudo()` was actually making
an environment for the superuser to operate upon:

request.env[...].sudo().method(...)

It no longer works in general, since `sudo()` now makes an environment
in superuser mode but with `uid=None`!  It may still work by accident
for operations that never use `env.uid`, but is broken in general.

Using `auth='public'` fixes the problem by using the public user when no
user is available.

closes odoo/odoo#34297

Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
2019-07-04 11:32:22 +00:00
Xavier-Do c9d173a3e7 [REF] mail, various: apply light code cleaning
Purpose of this commit is to clean some bits of code, notably calls to
message_post/log as well as notification methods. It will ease performance
improvement work.

Small optimization: account: read content after extension check

Parameter cleaning

 * use message log with kwargs instead of args;
 * remove message post after hook useless parameters;
 * remove _notify_email_recipients useless message parameter;
 * remove message_notify useless send_after_commit parameters;
 * remove message post params matching default values;

Other improvements

 * remove message_post commands support for partners and channels;
 * only calls message_post with ids list for channels and partners. We
   don't support mix of ids and command anymore to simplify code;
 * remove support of private discussion in mail.thread adding partners
   as recipients, as there is no use anymore;

Related to task 1943901
Linked to PR #32404
2019-05-29 13:32:26 +00:00
Christophe MatthieuandAntoine Guenet f296992317 [IMP] web_editor,*: Refactoring the wysiwyg editor and 'html' field
* Creating a new structure by transforming all the plugins in the
  library using the odoo inheritance system. Plugins are easier to
  implement with the AbstractPlugin to add Odoo behaviors.

* From now on, the methods of the library (in this case Summernote) can
  no longer be called by other modules or files. Only the wysiwyg
  widgets can access it, to simplify the updating process. The wysiwyg
  object serves as an interface.

* Depending on the options the snippets will be loaded or not, the
  editor will be in an iframe or not... all of this is transparent from
  the outside.

* Regarding iframes, all controllers related to editing have been
  removed: the new API no longer needs them. This speeds up loading,
  eases testing and removes complexity for the same
  features.

PUBLIC FEATURES

There are several public methods on the Wysiwyg class:
* Wysiwyg.prepare (WidgetParent): returns a deferred resolved when the
  library (xml, lazy, assets...) is loaded.
* Wysiwyg.getRange (DOM): returns the range (selection in the dom)
* Wysiwyg.setRange (startNode, startOffset, endNode, endOffset): creates
  a range (selection in the dom)
* Wysiwyg.setRangeFromNode (DOM, options) that creates a range from an
  element (option available to select all, start or end)

A jQuery selector was added: :o_editable, which indicates whether the
current element is editable. That is, if it is contained in a tag with
the attribute 'contentEditable = "true"' or in a tag with the class
o_editable.
Several methods are also present:
* focusIn: makes a focus and places the cursor at the beginning of the
  element
* focusInEnd: makes a focus and places the cursor at the end of the
  element
* selectContent: makes a focus and selects the content

HTML FIELD

The HTML field can receive different options:
* style-inline: {boolean} transforms a class into an inline style when
  saving and vice versa when reading.
* no-attachment: {boolean} prevents the use of attachments (in media
  dialog)
* cssEdit: {xml_id} to use a template containing the css to loaded in
  an iframe when editing
* cssReadonly: {xml_id} to use a template containing the css to load
  into an iframe when viewing in readonly
* snippets: {xml_id} snippets template (can be used with or without
  cssEdit)
* wrapper: {template} qweb static template (containing a tag:
  id = "wrapper") that will include the content during editing (removed
  on save)

MASS MAILING

A widget was created for mass mailing. There are now two fields:
body_html and body_arch.
body_arch contains the code with the class without conversion into
inline style, useful when editing and one with the inline style that is
visible in readonly mode and sent by email.
Advantage: no spreading errors, able to update css/theme, able to do
more changes when converting to inline style so that a maximum of mail
clients have an impeccable rendering.

Co-authored-by: Antoine Guenet <age@odoo.com>
2019-01-17 08:40:21 +00:00
Thibault Delavallée b670911a92 [REF] link_tracker, mass_mailing: simplify add_click method and add tests
In this commit we rewrite a bit add_click in order to remove the inlined sudo
and ease inheritance and parameter management inside the method.

Access through controllers is sudo-ed as the main API method is now done
with current user access rights.

This commit is linked to task ID 1904277 and PR #28242.
2019-01-14 10:34:26 +00:00
Thibault Delavallée 75638ffb94 [REF] link_tracker: do not let public read technical / private link data
Link tracker models are rather technical and should not be accessed as it is
by external people. Let us delegate control to controllers and lessen a bit
model accessibility.

Currently everyone can use add_click method and generate statistics. Now
statistics will be generated only through dedicated routes. It will make
statistics more reliable and ensure technical data remain private.

Next commit will update code from controllers and main methods in order to be
have a more readable click API and avoid link between non dependent modules.

This commit is linked to task ID 1904277 and PR #28242.
2019-01-14 10:34:21 +00:00
David Beguin e69b89b8fa [IMP] tools, mail : adds email normalization method in mail tools
In order to normalize email independently from the
mail.address.mixin model.
2018-11-20 11:37:05 +00:00
David Beguin fc2a8d63ee [IMP] mail, mass_mailing, mass_mailing_crm : Use normalized email in unsubscribe link
Use the email_normalized from mail.address.mixin if available to get always
a normalized email address in the unsubscribe link. That allows to simplify
the search on email address in the controllers -> Check blacklist,
send feedback, etc..

Task ID 1896677
2018-11-20 11:37:05 +00:00
David Beguin 0fe50a01d2 [IMP] mail : apply mail.address.mixin on blacklist
Apply the mail.address.mixin on blacklist mixin. So that every model
inheriting the blacklist.mixin will also inherit the address.mixin.

That simplify also the comparaison to - and the searches on - the
blacklist.

Task ID 1896677
2018-11-20 11:37:05 +00:00
gla 42c6db1ece [IMP] mass_mailing: warn when unsubscribing
Current behavior before PR:
When a lead or res.partner click in the 'unsubscribe' link in a mail that was sent to him via the mass mailing module (not via a particular mailing list), he is blacklisted from the whole mass mailing system. The only message he gets is "you have been successfully unsubscribed".

Desired behavior after PR is merged:
The user is told that he was unsubscribed, but in addition a warning is displayed telling him explicitly :
 - to which mailing lists he was subscribed
 - that he won't receive any mail from them anymore.

Purpose : Warn the user that unsubscribe via a lead or res.partner mass mailing that he won't receive any mail from the mailing lists (listed in the warning) he had subscribed, if any.

closes odoo/odoo#27678
2018-10-26 15:03:29 +00:00
Olivier Dony 2ff9b379ef [FIX] mail: fix blacklist mechanism
Several quick fixes:

- repair malformed SQL queries and injection problems
- proper token comparisons (consteq)
- better translatable terms (less context-lessplaceholders)
- basic testing of case-(in)sensitivity of blacklist
- safety check for non-implemented cases in search methods for computed
  field

More testing and review is needed for case-sensitivity and email
extraction from generic "addressing fields".
2018-09-29 04:47:44 +02:00
David Beguin e7871625f6 [FIX] mail, mass_mailing: remove user error if remove unexisting record from blacklist
In unsubscribe page, if the user try to come back
(and be removed from the blacklist)
but his email have been deleted from the blacklist,
it was leading to an error.
Instead, and in order to keep a trace of what the user asked,
if the email is not found in the blacklist, the record will be
created but archived directly.
Also, it aligns the return of both methods _add/_remove
2018-08-30 09:45:58 +02:00
David Beguin 39a628e586 [IMP] mass_mailing : review unsubscribe page + renaming blacklist creation date in form
Reviewing unsubscribe page style and button naming.
Rewritting the feedback controller to be easily readable.
Renaming blacklist creation date field in form to remove confusion.
2018-08-30 09:45:58 +02:00
David Beguin e5f490821b [FIX] mass_mailing: Feedback when multiple contacts with same email address 2018-08-29 12:13:29 +02:00
David Beguin 59b4836e8d [IMP] mail, mass_mailing : apply blacklist, opt_out per mailing list
Purpose
=======
- Apply the blacklist implementation to Improve mailing subscription to be more
  compliant with the European GDPR law. Keep a list of people who does not want
  to receive promotional emails (or mass mailing in general) anymore.
- Allows the recipient to update himself his mailing preferences

Specifications
===========
This commit is regrouping some main changes on mass mailing.
  Apply Blacklist for following models through blacklist.mixin :
    - crm.lead
    - res.partner
    - mail.mass_mailing.contact
    - mail.channel.partner
- Opt_out per mailing list instead of per mailing contact.
- Replace opt_out by blacklist in crm.lead + res.partner models
- Added 'ignored' state for mass_mailing. Ignored = blacklisted, opted-out
  Ignored email are not included into final statistics to avoid confusion.
- Unsubscribe(d) pages migrated from website_mass_mailing to mass_mailing module
  as thoses pages should work without having the website module installed

Detailed implementation
===================
Mass-mailing :
	- A blacklisted email is notified by the ban icon next to the email field.
	  (at the left of the email field for display purpose)
	- Renaming the '_get_blacklist' method that was actually
	  searching opt_out list into 'get_opt_out_list'
	- Opt out per mailing list : Add opt_out + related fields (for display and
	  ergonomy reasons) on the relational model
	- Display relational model tree view instead of mass_mailing.contact tree
	  view when clicking on mass_mailing_list in kanban view
	  -> In order to be align between contact_nbr displayed in kanban tile and
	     the content of the tree view
	  -> mass_mailing contact is accesible via the user icon in this tree view
	- Remove custom filters 'filter_contact_subscription' and
	  'filter_contact_unsubscription' as opt_out is not on mass_mailing.contact
	  model anymore
	- Add 'is_public' to mailing list
	    The name of this mailing list can be seen (or not) by recipient in
	    the unsubscription page
	    If the mailing lists used in the mass mailing are not public,
	    the user in only informed that he has been unsubscribed.
	    If the mailing lists are public, the user is informed that he has been
	    unsubscribed from the mailing lists
	    and he has the choice to modify his subscription to all the public
	    mailing list he is or was subscribed to.
	- Unsubscription Page :
		- mass_mailing_contact :
		  Opt_out per mailing list, done by email and not by id, as multiple
		  contact can have the same email
		  The recipient can add/remove himself to/from the blacklist
		  The recipient can send a feedback about why he unsubscribed
		- crm.lead + res.partner :
		  Once the recipient unsubscribe, he is automatically blacklisted
		  The recipient can 'Come back' and remove himself from the blacklist
		  if he changes his mind
		- Show blacklist button parameter added in config :
		  The idea is to enable/disable the fact that the recipient can add
		  himself to the blacklist by showing or not the 'blacklist me' button
		  Only applies for mass_mailing.contact. The recipient, once
		  blacklisted, can always, no matter the value of this parameter,
		  'come back' and unblacklist himself

crm.lead + res.partner :
	- Replace opt_out by blacklist in crm.lead + res.partner models.
	  As when a res.partner or crm.lead unsubcribe, we assume that the recipient
	  does not want to receive mass mailing anymore, at all, even if we adds him
	  to a mailing list afterwards. He is then blacklisted to avoid this.
	  With this behaviour, if a new lead is created with the same email address,
	  he won't be able to receive mail in mass_mode.
	  But he will still be able to receive '1 to 1' direct email.

Task ID 33224
Closes #25966
2018-08-10 17:46:08 +02:00
Nicolas LempereurandGoffin Simon 7703f1fb16 [FIX] mass_mailing: have unsubscribe in multi lang
Since 953a693df link not corresponding to a route are tought multilang
by default.

Thus in the mass mailing, if the user had not the default language on
the website he would have eg. a /fr_FR/unsubscribe_from_list placeholder
in the mail.

The placeholder is replaced by a real link pinpointing to the items the
given person would unsubscribe to, but having /fr_FR/ part prevented
that.

With this PR, there is a dummy route so /unsubscribe_from_list is
explicitely known as not multilang.

opw-1850696
closes #24912

Co-authored-by: Goffin Simon <sig@odoo.com>
2018-05-25 12:16:30 +02:00
Christophe Simonis 10128fa7e8 [MERGE] forward port branch saas-16 up to dc2a6c6cd2 2017-10-20 19:27:04 +02:00
Christophe Simonis 868e718e09 [MERGE] forward port branch saas-15 up to 8d0942380b 2017-10-17 15:14:47 +02:00
Nicolas Lempereur f4332118d3 [FIX] mass_mailing: unsubscribe error if contacts
If the mass mailing was to mail contacts, this could cause an error if
the recipient unsubscribed. If the mass mailing was to mailing list,
unsubscribe would not work.

This change update unsubscribe to take into account changes in 765e752
and e15372c07 that allowed mailing list / mailing list contacts to be
used separately.

opw-770473
closes #20145
2017-10-13 17:16:13 +02:00
Yannick Tivisse 51b5ee7c3c [IMP] mass_mailing: choose model among all chatter models
This commit removes the strange selection box based on a magic flag and
some strange methods returning a string. Instead just allow to send mass
mailing on all models inheriting from mail.thread using the is mail
thread flag.

Various addons are updated to remove the _mail_mass_mailing class
attribute used to determine mass mailing capability.

We consider people could send a mass mailing on every model inheriting
from mail.thread. It makes no sense to limit it to a given set of addons.
2017-09-15 15:56:23 +02:00
Xavier Morel 3824b5dcc1 [FIX] P3: fix base64 and StringIO uses
* StringIO removed from stdlib, replace with io
* try to correctly handle BytesIO/StringIO (one is for bytes the other
  is for text)
* fix base64: Python 3 removed bytes-encoding and bytes-bytes
  codecs (via #encode) so replace all calls to str.encode('base64'),
  also b64encode is a bytes->bytes conversion so attempt to properly
  handle that

issue #8530
2017-08-20 23:25:54 +02:00
xmo-odoo b4429c2a91 [FIX] Various P3-related import changes
* LDAP import: python-ldap is not python3-compatible, pyldap is

  Warning: only supported from debian Stretch (current testing)?
  https://packages.debian.org/search?searchon=names&keywords=pyldap

* implicitly relative imports
* imports of moved or removed stdlib modules

issue #8530
2017-04-28 09:06:53 +02:00
Olivier Dony 31e81e7b8f [FIX] mass_mailing: use consistent types for unsub token check
Passlib's consteq() function only works when both values are
of the same type.
`_unsubscribe_token` uses hmac.hexdigest() which always returns
byte-strings, so we need to ensure that the token passed in GET
parameters is cast to byte-string too.

In addition, _unsubscribe_token() is expected to always derive
the same token for the same list, res_id and email. It already
takes care of ID passed as strings/int, but failed to make sure
that the email can be passed as a byte-string or unicode-string.
Forcing it to unicode before deriving the token takes care of that.
2017-03-07 19:25:02 +01:00