Commit Graph
956 Commits
Author SHA1 Message Date
Christophe Simonis b4e1be8ab0 [MERGE] forward port branch saas-11.3 up to b09f624f20 2018-11-22 20:06:48 +01:00
Christophe Simonis b09f624f20 [MERGE] forward port branch 11.0 up to 263b388c50 2018-11-22 17:52:57 +01:00
len-odoo 24ca67b545 [FIX] mail: execute only once when setting automated actions at record update
Fine-tuning of commit: d60f2ab0e2
Which applied when the next action was to create a new activity.
However the problem is also present when the next action is to send an email.
We extract the logic in a new private function to share the code in both cases.

opw 1904156

closes odoo/odoo#28819
2018-11-19 19:36:14 +00:00
Toufik Ben Jaa 6f7262f508 [FIX] mail: do no try to send notification to inactive users
- This commit prevent to send notifications to inactive users.
- This fixes a bug where two partners have been merged and one of its
  users is archived.

  If one of the two users is inactive the code might use its `notification
  type` preferences instead of the active user's one.

closes odoo/odoo#28730
2018-11-16 11:13:56 +00:00
Olivier Dony a103d4a43e [FIX] mail: use strict email matching for bounces
When a bounce is received, we look for matching partners in order to
increment the bounce counter. However by using [`ilike','email`] we carry
the risk of matching emails that contain the bounce email:

   ['email', 'ilike', 'john@hitmail.com´]

will also match 'random.john@hitmail.com' for example.

Using strict equality is safer, and the worst that can happen is that
we fail to count one bounce.
2018-11-16 16:35:22 +01:00
Christophe Simonis 45d33f5357 [FIX] mail: correctly handle unset mimetype on safari
See 5e3b471f4a for more info
2018-11-16 17:25:55 +01:00
Géry Debongnie 1bb15e0559 [FIX] mail: fix performance issue for activity view
Fun fact: for the subscription model in odoo production database, the
get_activity_data rpc takes 36s, and transfer 420mb (non gzipped) of
data (when looking at all subscriptions).

The main reason for that is that the get_activity_data method create a
domain with all the res_ids (so, if you have 20k subscriptions, the
domain will look like (res_id, in, [...20k ids]).  This domain is given
to read group, and the resulting groups (each with a domain key which
includes those res_ids) will be sent back to the web client.

As far as I can tell, the domain key is not used by the web client, so
we send (number of groups)*(number of records) of useless data.

This commit improves the situation in two different ways:
- we only generate the domain if there is a domain at the beginning.
  This should greatly improve the performance when there is no current
  domain
- we do not transfer the data to the web client
2018-11-15 15:26:49 +00:00
Toufik Ben Jaa 774991946e [FIX] mail: no mail sent to followers
- If the `internal` field/column on the message subtypes (table: `mail_message_subtype`) is set to null instead of false in the
  database, the notifications to the followers are not sent by mail.

closes odoo/odoo#28699
2018-11-14 18:54:12 +00:00
Denis Ledoux c41902a21c [FIX] mail: mail queue is interrupted if a recipient is not ascii valid
This is related to revision
71f188082f

This is nice to have a meaningful explanation
for the user to understand why his mail is not sent,

this is better to not interrupt the mail queue when doing so.

Because of the above revision,
when the mail queue iterated on a mail failing because
of an ASCII encoding issue,
the mail queue was interrupted,
and on the next cron call it failed again and again
on the same mail, therefore leading to the mail queue
to never be processed.

Fixes #27804
2018-11-14 17:18:34 +01:00
Christophe Simonis cc8e8237bf [MERGE] forward port branch 11.0 up to 84500c27b1 2018-10-25 13:59:45 +02:00
Nicolas Seinlet 80cef9e8c5 [FIX] mail: faster blacklist search
For the special case of is_blacklisted, and due to
the size of the tablers to handle, it's faster to
filter some records rather than searching the whole
res.partner table

closes odoo/odoo#28028
2018-10-22 12:45:17 +00:00
len-odoo d60f2ab0e2 [FIX] mail: only generate one next activity when setting automated actions at record update
Create an automated action to create a new activity on update of a record
(e.g. a CRM lead).
At update, many fields recompute may be triggered, triggering as many write.
Thus it would generate many activities.
We simply do nothing if we are in a recompute.

Coauthored by rco

opw 1904156

closes odoo/odoo#28498
2018-11-08 10:40:58 +00:00
Nicolas Seinlet 672bc57c1d [FIX] mail: access error when reading a channel
When a record inaccessible by the user is linked
to a message in a channel accessible to the user,
Avoid to raise an access error due to this linked record.

Also need an aditional query in test query_count.

closes odoo/odoo#28312
2018-11-02 08:32:50 +00:00
Christophe Simonis f2ada1560e [MERGE] forward port branch 11.0 up to 22a13073f0 2018-10-19 12:25:17 +02:00
Julien (juc) Castiaux 4c65499cca [FIX] mail: Emails are sent in reverse order
The CRON job that sends email sends them in a LIFO order instead
of a FIFO order which can lead to confusion when the order is
important.

Exemple, when updating multiple time an appointement, the last
update should be the newest mail clients receive in their mail box
which was not the case before this PR.

opw-1888601

closes odoo/odoo#27888
2018-10-18 09:24:00 +00:00
Yenthe V.G 992c4dbe38 [FIX] mail: set default _rec_name to avoid showing model with id
closes odoo/odoo#27186
2018-10-24 14:21:04 +00:00
Toufik Ben Jaa 079a3b602b [FIX] mail: add index on message_main_attachment_id
- When deleting attachments, the foreign key constraints on
  `message_main_attachment_id` are triggered which could take
  a lot of time to be computed.

closes odoo/odoo#28358
2018-11-02 11:49:43 +00:00
Christophe Simonis 5e055a2afd [MERGE] forward port branch saas-11.4 up to f6ca72b3ce 2018-11-02 10:52:55 +01:00
David Beguin c28ae53417 [FIX] mail : fix traceback while creating invalid blacklist email address
The objective of not creating the record if the email was invalid
was to avoid crash on import. But if the number of record created does not
match the number of record that would have been created (see in flush()
in models.py), this cannot work.

Also, it's necessary to tell the user that his import file has an error
and where. This is why a UserError must be returned.

Task ID 1902139
Closes PR #28011
2018-10-31 10:51:56 +00:00
Christophe Simonis a299517f83 [MERGE] forward port branch saas-11.3 up to 6136f0c02e 2018-10-29 11:56:32 +01:00
Thibault Delavallée 5494b0bc3e [FIX] mail: do not prevent record update due to automated activities
Currently creating activities assigned to user not having to the document
raises an Error as people should not have activities they cannot handle
directly on a document they cannot access.

In some cases activities are created through business flow, like automatic
activities creation when creating leave requests. Assigning an activity
to someone that has no access to the document should not prevent from
creating the leave request.

This commit therefore does not check assigned user access on automated
activities to avoid having blocked business flows.

This commit is linked to task ID 1903484.

closes odoo/odoo#28139
2018-10-25 09:29:10 +00:00
Christophe Simonis 0fcb28c97b [MERGE] forward port branch saas-11.3 up to d82a907728 2018-10-19 14:32:09 +02:00
Christophe Simonis b81c2bce84 [MERGE] forward port branch saas-11.4 up to 3c108977c1 2018-10-22 16:59:51 +02:00
Christophe Simonis e9ae419fca [MERGE] forward port branch saas-11.3 up to 0de06a4132 2018-10-17 10:54:19 +02:00
Thibault Delavallée 56596e5240 [FIX] mail: avoid concurrent update of notifications
When sending notifications by batch one notification email can be send
up to 50 people. For one mail_mail entry to handle 50 emails can be sent
as those are sent independently for each recipient.

In some cases a bounce may occur while the whole batch of recipients is
not completely mailed. In that case the mailgateway will update the
notification status to bounced. When the cron finishes to send the whole
batch of emails it tries to update the notifications of all recipients.
However as a notification has already been updated due to the bounce we
face a concurrent update, meaning the transaction is rollbacked.

Emails have been sent but notifications are not considered as sent as they
have not been updated accordingly. Next time the cron runs it will send the
same batch again, with probably the same bounce and rollback. We could
therefore face an email loop.

This commit fixes that by setting notifications to a transient exception
state. Notifications are locked, meaning bounced will have to wait for the
transaction to finish before updating them. That way the cron can run
safely on the whole batch and we avoid having emails loop. It has an impact
on query count as a search and write is performed in the send process.

This commit is linked to task ID 1893054. Done in collaboration with
@Xavier-Do .
2018-10-12 12:50:39 +02:00
Swapnesh Shah e6e0d7ae78 [FIX] base,mail: do not include field attachments in attachment_count
The _search was already excluding these attachments but not the read_group
Avoid the read_group from mail to search on all existing attachments

Fixes odoo/odoo#27673

closes odoo/odoo#27698
2018-10-17 11:38:17 +00:00
Alexandre Kühn 4531348ff0 [FIX] mail: fetch self-authored, pending moderation messages
Before this commit, when a non-moderator user posts a message in a
moderated channel and refreshes the page, he could no longer see his
messages that are pending moderation.
2018-10-16 07:29:07 +00:00
Julien (juc) Castiaux 71f188082f [FIX] mail: unicode character in email cannot be parsed
Sending email to addresses containing unicode characters
cannot be parsed by python and result in a UnicodeEncodeError.

This PR catch that specific exception and output a meaningful
error message.

Decision has been taken to not trigger any error message
client-side has it would have needed modifications on some
sensitive low-level backend code.

To reproduce:
- Configure odoo so it uses an email server
- Send an invoice to a partner whoose email address contains
some unicode characters (exemple: æøåÇÀ@example.com)

opw-1892409

closes odoo/odoo#27804
2018-10-15 13:42:58 +00:00
Christophe Simonis f6ea6ce951 [MERGE] forward port branch 11.0 up to c576800813 2018-10-09 13:55:53 +02:00
Christophe Simonis 1b5f14713b [MERGE] forward port branch saas-15 up to 0ef5cedebb 2018-10-08 18:59:03 +02:00
Christophe Simonis 0ef5cedebb [MERGE] forward port branch saas-14 up to 637e4c68fc 2018-10-08 17:29:03 +02:00
Christophe Simonis 637e4c68fc [MERGE] forward port branch 10.0 up to e88c5c1ece 2018-10-08 17:28:08 +02:00
len-odoo e88c5c1ece [FIX] mail: sudo on user name
Suppose user A creates a sale order S in company X. He then changes to company Y
Sales manager B, in company X, creates the invoice for sale order S.
Bug: the compilation of the report fails because of the user.name in the
template. Then the tracking update fails, making it impossible to validate the
invoice.

opw 1884915
2018-10-08 15:59:30 +02:00
XavierDo 356a421660 [FIX] mail: avoid sending mail when creating record from data
Before this fix the creation of task assigned to admin was leading
to the creation of mails.

This is a generic fix to avoid to notifiy a user when he is add as a
follower when creating data from odoo data files.

closes odoo/odoo#27682
2018-10-11 15:30:33 +00:00
len-odoo a9ce28bfb1 [FIX] mail, mass_mailing: remove implicit dependency on mass_mailing
Fix to commit: a1d6064dcc
Which erroneously put a mass_mailing method in mail,
as mail.mail.statistics is defined in mass_mailing.
Since it does not depend on the records, it been extracted from the
loop.

opw 1890461

closes odoo/odoo#27431
2018-10-05 08:47:49 +00:00
Thibault Delavallée c7ad31f0a0 [IMP] blacklist: sanitize search terms on email
Purpose of this commit is to make search coherent with sanitize of emails
done when storing blacklist entries. We parse search terms in order to
find something related to email field and sanitize it to avoid issues
linked to case insensitivity or formatted addresses.

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:52:33 +02:00
Thibault Delavallée 2b73bed880 [FIX] mail: correctly extract email from email field in computed blacklist fields
Purpose of this commit is to correctly extract email address from the email
field of models inheriting from the blacklist mixin. Indeed email field
could contain a formatted address like "Raoul Grosbedon <RAOUL@example.com>".
Related blacklist entry would be raoul@example.com. We have to extract
the email from the email field and lowerize it in the SQL query or the
computation in order to have a fully working blacklist mixin. This fixes
some bits left at commit 2ff9b379ef.

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:52:30 +02:00
Thibault Delavallée bbe4690066 [FIX] mail: assert email field used in blacklist and correctly use it in computed fields
This commits fixes the use of email field in blacklist mixin as it was based
on 'email' field instead of the one coming from the _primary_email class
attribute since commit 2ff9b379ef.

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:52:19 +02:00
Thibault Delavallée 5743122f60 [FIX] mail: ensure case insensitive check when (de)activating blacklist records
Now that blacklist records are set as lower case be sure all checks in
blacklist are done accordingly by using the sanitizer before comparing
email adresses.

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:52:18 +02:00
Thibault Delavallée 7b0c502d60 [FIX] mail: ensure creation of unique emails in blacklist
Currently blacklist is configured to have unique emails. Notably when creating
new entries it checks for existing records with same email to avoid crashing
about duplicate entries.

However it does not check if given values use unique emails. When importing
a big list of emails you are not sure emails are unique. This commit ensures
values given to create are correct to avoid crashing when importing a lot
of data.

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:52:18 +02:00
Thibault Delavallée 2f82b95dca [FIX] mail: insert only sanitized and lower-case emails in blacklist
Purpose of this commit is to standardize content of blacklist records and
ensure only real email addresses are stored.

We introduce a sanitize method to extract email address from string (like
Raoul Grosbedon <raoul@example.com> -> raoul@example.com) and return a
lower case version of it.

Purpose is to gradually get rid of lower() that appear a lot in the code
and speedup computation by being sure everything is always lower case.
Moreover indexing on blacklist model will be more performant is using
directly email field content instead of having to lowerize it.

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:52:18 +02:00
XavierDo 82da171fcb [FIX] mail: add translation on guidelines subject 2018-10-02 13:40:12 +02:00
XavierDo 775e8a9f2d [FIX] mail: make guideline template a qweb view
The mail template mail_template_channel_send_guidelines should only be used
from send_guidelines action. Anyway, with mail_template on activity
and all demo done to show this mechanic on contacts,
trying to render this one will generate a traceback. This fix
transforms the mail_template to qweb view so that it won't be available in
mail template.
2018-10-02 13:07:02 +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
Christophe Simonis dece365d52 [FIX] mail: avoid reading from abstract models 2018-10-02 11:12:15 +02:00
Christophe Simonis 43b63a0465 [MERGE] forward port branch saas-11.4 up to 57e387b645 2018-10-01 16:01:54 +02:00
David Beguin a8ce59ce36 [FIX] mail : Fix blacklist search method
As building a custom filter on 'Blacklist is false' is creating a filter '!= True'
instead of '= False', the assumption that operator must always be '=' is wrong.
This commit inverts the value and operator if the operator is '!='.

Fix for Task ID 33224
PR #27334
2018-10-01 14:21:19 +02:00
Christophe Simonis 998723b909 [MERGE] forward port branch saas-11.3 up to e980af9df0 2018-10-01 11:27:51 +02:00
Fabien Pinckaers feae553b98 [IMP] mail: typo, launched -> schedule 2018-09-30 15:54:41 +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