Commit Graph
486 Commits
Author SHA1 Message Date
David Beguin 331d413f7a [FIX] mail: correctly find and compare blacklist email when sending mass mailing
Until now, a recipient with a formatted email like 'John Doe
<john_doe@example.com>' could be reached by email even if its email address
was blacklisted. Now when sending a mass mail using the composer, the email
is sanitized before comparing it to blacklist entries.

This commit is related to task ID 33224 (original blacklist implementation
done for v12) and its PR #25966 as well as task ID 1889703 (tests and fixes)
and its PR #27330. Done with collaboration of @dbeguin.
2018-10-02 16:53:43 +02:00
Yannick Tivisse 532d82a7a9 [IMP] mail: Make mail.compose.message code more readable
Purpose
=======

Remove the method 'render_template' in mail.compose.message as the indirection
is not useful. Call the method on the correct model (mail.template) directly.
2018-10-02 12:35:34 +02: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
Adrian Torres 3f4f77fd9d [REF] *: adapt code to new related default behaviour
This commit adapts the business code to changes introduced by
the parent commit in order to keep the same behaviour as before.

All readonly=False fields will have to be checked afterwards to confirm
that the business case requires write access to the source field.
2018-09-27 12:10:23 +02:00
Christophe Simonis 68d36512ef [MERGE] forward port branch saas-11.4 up to d78f23df84 2018-09-07 20:20:45 +02:00
XavierDo 554414b90f [FIX] mail: fix use of resend wizard when user are in failure
The user right to edit partners was handled in order to set email fields as readonly
If a user is in the failed recipient, we need to check that the urrent user also has
right to write on users
2018-09-06 10:33:59 +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
David Beguin 98ce81cac5 [IMP] mail - mail.blacklist: Not send mass_mail to recipient that does't want to
Purpose
=======
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.

Specifications
===========
This commit is regrouping some main changes on mass mailing.
- Added blacklist : Avoid sending mass mailing to blacklisted recipient
  (blacklisted = email address that doens't want to receive mass mailing anymore)

Detailed implementation
===================
Mail :
- Add Blacklist mechanism in mail module (NOT in mass-mailing) :
  as we can send mass-mail without the mass-mailing module
- Unicity in email -> To avoid error in import, override the create and return
  the existing record if any, else, create the record normally.
- Blacklisting is done by email address and is cross model.
  Will apply to model that inherit the blacklist.mixin.
- field 'is_blacklisted' -> computed : check if email is in blacklist
  + search method to be able to filter on is_blacklisted
- When a email address is blacklisted, it will never get mass mailings anymore.
  Even if the email address is added to another mailing lists
- Avoid sending notification to blacklisted recipients when sending email
  in mass mail mode. If the recipient is blacklisted, we should not even send a
  notification in the recipient's chatter for an email that he won't even
  receive.
- When a email address is blacklisted, it can still get 'normal' mailings.
- The blacklist shoud be accessible in
  Mass Mailing / Configuration / Blacklist
  and Settings / Technical / Email / Blacklist
  -> Renaming Settings / Technical / White / Black List config menu item
     into Channel Moderation to avoid confusion with Mass Mail Blacklist
- Add indexes to the blacklist table (on email) to make it fast for access for
  the different use cases
- _primary_email : attribute that must be overriden to specify which field must
  be used as email in the blacklist mechanism.
- Filtering the blacklisted recipient in mail composer :
  done in mail._get mail value()
  In case of real mass mailing, we need the statistics to be computed in order
  to know how many recipients were ignored in the mail.
  So we cannot avoid sending mail but instead flag the mail as canceled.

Task ID 33224
2018-08-10 17:46:08 +02:00
Thibault Delavallée 689a496f1c [REF] mail: propagate recipient data through notification process
Purpose of this commit is to avoid browsing and prefetching data about
recipients when notifying a message to partners and channels. Mail message
_notify computes all necessary data in a single query. This commit allow
to re-use this data by propagating it through the call chain.

Addons inheriting from classification methods used when sending notification
emails are updated accordingly to the API and data update.

This commit is linked to task ID 47934 and PR #24033. No functional change
should occur with this commit.
2018-08-07 15:43:06 +02:00
Thibault Delavallée 89051058f4 [REF] mail: clean code related to notification email generation
This commit cleans code about sending email notification to recipients.
Purpose of this code is to prepare notification emails, group recipients
and finally send emails. In this commit we clean and optimize a bit by

 * propagating some additional parameter to simplify code, like record
   on which the notification process runs;
 * inlining some code currently located in sub-methods. It eases code
   understanding as there are less code jumps. As those methods are not
   inherited inlining them can be done;
 * simplifying a bit notification emails preparation and computation;

It allows to save a few query by avoiding to fetch and browse again some
data that were already computed.

This commit is linked to task ID 47934 and PR #24033. No functional change
should occur with this commit.
2018-08-07 15:43:06 +02:00
XavierDo abbba35598 [IMP] mail: add mail templates on activity
This commit allows the user to link some mail template to activity type
with res_model.

When a activity has template, buttons appears in activity, allowing the user
to send mail based on templates.

Task: #1844563
PR: #25620
2018-08-01 15:26:30 +02:00
qsm-odoo d48b8593dd [REF] *: BS4, 'pull-left/right' -> 'float-left/right' 2018-07-27 12:36:54 +02:00
qsm-odoo c59380bac5 [REF] *: BS4, rename btn-default to btn-secondary
BS4 "btn-default" class was replaced with "btn-secondary", which makes
more sense.
2018-07-27 12:36:54 +02:00
Mitali Patel d8496aea2e [REM] mail: remove duplicated mass mailing action on partner
This action allowing to send a mass mailing with a default template on a
partner is defined twice in mail on same object, with same xml_id. See in
composer views for the other definition.

This commit is linked to task ID 1843361 (and 1868112) and to PR #25287
(and #25889).
2018-07-24 15:33:22 +02:00
eco-odoo d1ec3306b8 [ADD] account: onboarding panel for invoicing
Add an onboarding panel for invoicing, it appears above the invoice
list.
After going through the steps the system should be all set to send real invoices.

In the payment module, add a payment acquirer step and add it to the invoice onboarding panel.

task: 60668
2018-07-20 11:59:12 +02:00
Yannick Tivisse 9d27ee5441 [FIX] mail: avoid warning on view validation 2018-07-16 17:39:48 +02:00
Christophe Simonis 182c2c6919 [MERGE] forward port branch saas-11.4 up to 8285630ad2 2018-07-16 12:34:20 +02:00
Christophe Simonis 8285630ad2 [MERGE] forward port branch saas-11.3 up to 609491ad0e 2018-07-13 17:12:07 +02:00
Christophe Simonis f3929aa0f7 [MERGE] forward port branch saas-11.2 up to 87dadc5bc8 2018-07-13 14:32:05 +02:00
Christophe Simonis c952a11770 [MERGE] forward port branch 11.0 up to 6e6e3d4c96 2018-07-13 10:47:18 +02:00
Christophe Matthieu 6a5dc8bcd1 [FIX] mail: remove attachment feature in add followers modal
Before this fix, the attachments are don't save to the record and are
remove with the wizard. We can't add the attachments to mail.message
(like 'mail.compose.message') because it's auto_delete/unlink and the
attachments are removed before the recipient can read it.
2018-07-11 15:38:59 +02:00
Christophe Matthieu 3472a34e8a [FIX] mail: write all attachments only once
wrong indent.
2018-07-11 15:38:59 +02:00
XavierDo c8d283a592 [FIX]: mail: storing add_sign on mail message
Only the add_sign from notif_values is usefull for a resend. We can consider
that a mail on resend can be delete in every case, and we can find the
model_description from model since a resend can only be performed on
message linked to a model.

The other notif_values are now parameter in order to ease the understanding
of what can transit through this flow.

Task: #1860054
PR: #25622
2018-07-11 12:25:33 +02:00
XavierDo 62591c58f8 [FIX] mail: add ability to mark failure notification as read
The mark as read button was not working for mail failure. More than that,
we wanted a functionnality to be able to massively mark mail failure as canceled,
especially to be able to clean databases from failure after migration.

Task: #1860054
PR: #25622
2018-07-11 12:25:33 +02:00
sed-odoo f56ad6daf8 [IMP] base,*: Improve the res.partner form view UX
Purpose
=======

The Contact form is one of the most used/important view. It is quite
important to find the piece of information easily and to navigate in
a few clicks to the related views.

Specification
=============

Stat buttons
------------

- Restructure stat buttons with the following order:
Opportunities  -> sales user
Meetings    -> sales users
Sales    -> Sales users
POS Sales -> pos users
Subscriptions   -> Subscription users
Events    -> event user
Tasks -> project user
TIckets -> helpdesk user
Purchases   -> purchase user
Due -> billing: user
Invoiced     -> billing: user
Vendor Bills -> billing: user
Customer/Vendor Partner Ledger -> accounting: billing
Analytic Accounts -> accounting: billing
Credit Cards -> sales user
Direct Debit Mandates -> accounting: billing user
Publish
- Use better/more relevant icons
- Check that the proper access rights are set
- Remove the bank accounts stat buttons and replace it by a one2many
  tree on the Invoicing page.

Fields
------

Move some res.partner fields from the "Accouting" page to the
"sale & Purchase" page:
- Fiscal positions
- Payment terms

Miscellaneous
-------------

- Remove dead code.
- Display nothing instead "Please complete customer's informations and email"
  on the popup when sending an email to a contact without email address.
2018-07-04 15:43:25 +02:00
kujiu f90cf060a3 [FIX] Syntax of icons (#25577)
Description of the issue/feature this PR addresses:

Accessibility improvements forbids the use of the syntax
`<i class="fa fa-check"/> Some text`
to create a labelled icon. But, by this, some fonts are changed.

Desired behavior after PR is merged:
The old syntax can be used.
2018-07-04 09:55:52 +02:00
Christophe Simonis 49edee1f4b [MERGE] forward port branch saas-11.4 up to d54a3726ec 2018-06-29 12:46:00 +02:00
Olivier Dony bf9a4663ff [IMP] mail: improve UI text in mail resend wizard 2018-06-23 03:12:05 +02:00
Olivier Dony cab349e7e4 [FIX] mail: access related fields for resend as normal user 2018-06-23 03:12:05 +02:00
Olivier Dony c77d3e5531 [FIX] mail: line endings: DOS->UNIX 2018-06-23 03:12:04 +02:00
kujiu 9de1bc0eef [IMP] Improve compatibility with screen readers (accessibility) (#24574)
Today, Odoo is really tricky to use without seeing the screen, it must be improved to be usable.

This PR forbid to use labels without a "for" attribute, add some title, rule and aria attributes in HTML. With that, Odoo will be fully usable with a screen reader.


* [IMP] Labels must have a for attribute. Improve accessibility.
* [IMP] Better error message when trying to read a missing cached value
* [FIX] Add some aria-label and title attributes for screen readers.
* [FIX] Template name is not included in the error message in case of SyntaxError in QWeb
* [FIX] Improve the Tour failed at step error message to be more explicit.
* [IMP] Add aria-labels
* [FIX] Add missing aria-label on failing test
* [IMP] aria-hidden means hidden. Fix all bad aria-hidden and hide aria-hidden for all.
* [IMP] Color names on kanban views and many2many tags
* [IMP] Add some checks on views for accessibility.
* [IMP] Add `alt` attribute on `img` tags.
* [IMP] Add aria-label and title on non-described icons
* [IMP] Add button role to widgets with btn class
* [IMP] Translate aria and formatted attributes.
* [IMP] Remove wrong aria-labelledby
* [IMP] Add menu role on dropdowns
* [IMP] Buttons must be focusable
* [IMP] Add aria attributes on progress bars
* [IMP] Improve accessibility of basic widgets
* [IMP] Change main layout to more semantic tags
* [IMP] Add menuitem role when missing
* [IMP] Remove wrong role='presentation'
* [IMP] Improve accessibility of tab panels
* [IMP] Add aria-invalid on invalid fields
* [IMP] Add aria-sort on ordered columns
* [IMP] Add role on alerts
* [IMP] Use dialog role, header, main and footer tags for modals
* [IMP] Add labels on o_status
* [IMP] Improve accessibility of kanban view with feeds and articles
* [IMP] Add alerts in case of new messages
* [IMP] Add widget, navigation or img role to aria-labelled items
2018-06-22 21:22:21 +02:00
Pratima Gupta 1184f7872d [IMP] mail: ease the use and specification of notification emails layout
This commit proposes to ease the use and specification of layout used to
encapsulate email body when sending notification emails. This is done
through two means

 * message_post_with_template now supports the custom layout parameter
   that allows to set the layout to use when sending notification emails
   in the message_post process. We have to rely on the context as it is
   the current way of using it in the composer. It is likely to change in
   a near future;
 * composer now supports through context (as we have no other choice)
   specific notification values to give to the notification layout rendering;

This commit is related to task 51122 (and PR #24052).
2018-06-08 15:20:04 +02:00
XavierDo 133eeb1bbf [ADD] mail, mass_mailing: allow a user to resend a mail with failures
When a mail is in failure state, a red envelope appears next to the message
in a thread but it was difficult to send the mail again.
This tasks will allow users to send mail again easily, or mark notification
as cancelled if the user want to ignore this failure.
A notification will appear in sender systray while mail are in failure.

Task: #46158
PR: #24628
2018-06-07 11:46:28 +02:00
Thibault Delavallée 324ae5ed8f [REF] mail: get rid of thread_model context key
message_post and various mail.thread related code still support a thread_model
context key allowing to redirect message post on another model. Purpose of
this commit is to get rid of that context key and support model / res_id
fields coming from either the record on which we run, either parameters of
message_post. Indeed those parameter match the one used as fields on mail
message. It makes sense to support them for customization if necessary
instead of using a context key.

This context key exists since a lot of time. It is difficult to find the
source as history is quite complex when the mail was refactored in 2012.
See notably 6aa4f80b2d and 2c4ed841b9 for example.
2018-05-07 11:00:03 +02:00
Thibault Delavallée 282733cf8d [REF] mail: make notification methods semi-generic
mail.thread mixing class defines several methods used in notification process
that are not specific to mail.thread enabled models. It means some models
could override it while some other models do not even have a direct access
to that method.

When calling those methods we have to manually check for method being
available on a record or call a default implementation from mail.thread
even if the model does not inherit from the mixin.

In this commit we propose to hide this check in generic wrappers located
in mail.thread class. It checks for method existence on record and call
the model-specific implementation or falls back on standard behavior. It
allows to be sure the right method is called.

Functionally behavior should stay globally the same. However when updating
some addons code has been updated. Previous code could lead to records not
having correct alias which should not be the case anymore. This commit is
linked to task ID 47934.
2018-05-07 10:58:54 +02:00
qsm-odoo fbfd011904 [REF] *: get rid of introduced @​extend
During first scss convertion, classes called as mixins were changed to
an @​extend instruction which was the best approximation given the fact
there is no equivalent in sass to do that. The problem is that the
instruction is slowing the scss computation a lot and might also break
the style in unexpected ways because of the complex unwanted selectors
the instruction induces.

This commit removes the need of extends. This is done case per case.
Sometimes this involves adding classes in xml, sometimes to change the
style a little, ... The button rendering refactoring which was made
at the start of the LESS to SASS merge was also done in prevision of
this.

After this commit, sass computation is like 5-6 times faster than less
computation while it was like 10 times *slower* before this commit.
2018-04-18 15:59:18 +02:00
Thibault Delavallée 4451e505cd [IMP] mail: use xmlid_to_res_id instead of ref in remaining places of mail
As explained in previous commit we can use xmlid_to_res_id instead of ref()
which leads to some query gain. This commit update some other less important
places: when setting activities as done and in the composer. This lead to
a gain in tests involving activities and composer, including tracking
triggering a template. On community runbot this leads to a gain of about 1K
queries.
2018-03-28 16:57:05 +02:00
Thibault Delavallée 8a026e26c6 [IMP] mail: update _notify API
Purpose of this commit is to allow to give additional values when rendering
notification emails and to make some parameters explicit.

This commit updates the _notify API. It allow to propagate a dictionary
containing values given to the rendering of the notification template.
This allow to have more complex templates and/or to control the rendering
depending on some parameters. Indeed currently only some fixed values and
values coming form the message to notify are given to the rendering
context.

First use will be soon when pushing notification emails not necessarily
linked to documents. In this process some values will be given by the caller
and not only by the message context anymore.

This commit also moves some context key used to control the notification
process directly in values given to the _notify method. It allows to make
those parameters explicit and rely less on context.

The _notify method now takes a values dictionary that may contain

 * add_sign: add user signature to notification email, default is True.
   It replaces the ``mail_notify_user_signature`` context key;
 * mail_auto_delete: auto delete send emails, default is True. It
   replaces the ``mail_auto_delete`` context key;
 * other values are given to the context used to render the notification
   template, allowing customization.

It allows to remove some context switch notably in the composer. A values
dictionary is computed and given to message_post and then propagated to
the notification mechanism.
2018-02-20 14:32:09 +01:00
Thibault Delavallée d1ec600c43 [IMP] mail: move custom_layout context management in wizard
Purpose of this commit is to clean the use of custom_layout in context
in order to have more explicit argument.

Several mail.compose.message instances are called using the
custom_layout magic key. As this parameter is now managed directly
by message_post API we can remove its management in the notification
process and add it explicitly in the wizard's message_post call.
2018-01-29 16:35:36 +01:00
Thibault Delavallée cae1c3977f [REF] mail: rename notification methods and make them private
Purpose of this commit is to perform a light cleaning of the email
notification process. It renames method by prefixing them by _notify
in order to easily spot them. It also makes them private because they
should not be called outside of other methods. Indeed those methods
are technical and do not provide useful information to external
people.

Future commits will probably improve the notification process in order
to clean it and try to reduce its query count.

This commit perform the following renaming

 * message_get_email_values -> _notify_specific_email_values
 * message_get_recipient_values -> _notify_email_recipients
 * _message_notification_recipients -> _notify_classify_recipients
 * message_get_reply_to -> _notify_get_reply_to
2018-01-29 16:33:07 +01:00
Thibault Delavallée fc1348dd3d [REM] mail: remove unnecessary methods from mail.thread
* one dead method;
 * one unnecessary method to inline;
 * one unnecessary wrapper;
2018-01-08 15:04:56 +01:00
Richard Mathot eb61925344 [FIX] base_partner_merge: this wizard does not depend on mail anymore
We then extract the logging of the merge in a separate submethod, and
log in chatters only when available.
2017-12-21 12:59:23 +01:00
Christophe Simonis de987831da [MERGE] forward port branch 11.0 up to d70518d04f 2017-10-21 15:22:36 +02:00
Christophe Simonis 10128fa7e8 [MERGE] forward port branch saas-16 up to dc2a6c6cd2 2017-10-20 19:27:04 +02:00
Christophe Simonis 5ea0f55d65 [MERGE] forward port branch saas-15 up to bee0c11ef7 2017-10-20 17:57:21 +02:00
Christophe Simonis f3ac68ed29 [MERGE] forward port branch 10.0 up to e2532f855f 2017-10-20 16:09:28 +02:00
Lucas Perais (lpe) e3f05496b1 [FIX] mail: fix template preview wizard view
Before this commit, when on a mail.template form, click on the Preview smart button.
A wizard popped up with two buttons, as the default for form views.
First this made no sense since the wizard doesn't represent a model that can be modified
Second, the button discard was unable to close the wizard.

After this commit, only a discard button is present which does its job.
2017-10-20 09:09:34 +02:00
Prakash Prajapati e302ca7b3d [IMP] mail: display latest records first when previewing templates
And also avoid resetting the body if there is no record chosen.

Closes #18566 .
2017-10-18 13:20:39 +02:00
Hetashree Chauhan 8efecd31bd [IMP] mail: labels for sending mail to all recipients has been changed 2017-09-26 12:21:25 +02:00
Christophe Simonis 30bd5ac0e9 [MERGE] forward port branch saas-16 up to aec6248bb3 2017-08-23 16:44:58 +02:00