Commit Graph
145 Commits
Author SHA1 Message Date
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
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
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
Thibault Delavallée 0b8a409580 [IMP][FIX] test_mail: correctly simulate email send in performance tests
Commit 356a421660 introduced a hook to avoid sending emails while
installing application data. However we have to carefully re-activate email
sending in tests that depend on them especially performance tests.

This commit also update performance counters to match the current state of
counters as it was not totally updated.

Commit linked to task ID 1902307.
2018-10-23 08:44:03 +00:00
Christophe Simonis b81c2bce84 [MERGE] forward port branch saas-11.4 up to 3c108977c1 2018-10-22 16:59:51 +02:00
Christophe Simonis d4c343588f [FIX] test_mail: bump query count margin
Needed to make test pass with `mail_push` (enterprise module) installed.
2018-10-19 16:13:05 +02:00
XavierDo 8f9a767bbe [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 add test for this use case.

This commit is linked to task ID 1893054.
2018-10-18 15:49:28 +02:00
Thibault Delavallée a7b3d1697c [REF] test_mail: use odoo test helper method to create test users
Purpose of this commit is to use the newly introduced helper to create
test users in a quick way and reduce code duplication. A mail specific
helper tool function is defined based on the standard one defined in test
allowing to pass a custom context. It bypasses mailing features in order
to speedup the creation.

This commit is linked to task ID 1889703 and PR #27526.
2018-10-18 13:57:02 +00: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
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
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
Thibault Delavallée d5131fe976 [REF] test_mail: reorganize activity tests
Purpose is to separate tests related to access rights (low level), base
activity features and mixin itself. It eases understanding of tests and
prepare future addition of tests.

This commit is linked to task ID 1856417.
2018-10-02 16:05:17 +02:00
Antony Lesuisse 837c738d8b [FIX] mail_bot: Merge OdooBot and System
As we want that operations done by the system such as reordering rules be done
by him.
2018-10-01 16:37:59 +02:00
Nimesh Jethva 427ba08e0d [IMP]various: Improvement in model description
Purpose of this commit is to give description more "business oriented"
because those descriptions appears in Odoo Studio which is supposed to be used by end users, not only by developers.

Related Task ID : 37311
2018-09-21 11:45:15 +02:00
Olivier Colson 3c2a92e820 [IMP] mail: add main attachment support on mail.thread
This is done by adding a new field on mail.thread objects and setting it when posting a message with attachments on a model inheriting from mail.thread.

Was part of PR #26740
Was part of task #1880089
2018-09-14 17:29:49 +02:00
Raphael Collet c3e8fe5da1 [FIX] test_mail: count for unread notifications 2018-08-23 21:38:57 +02:00
Raphael Collet 2f7c03d9ca [IMP] base: add regular user admin as uid 2
User 1 simply becomes a technical user (inactive, no password).
2018-08-23 21:38:57 +02:00
Adrien Dieudonne e0aec7f0a4 [REF] test_mail: update counters due to enterprise ocn_client add
This commit is related to enterprise commit that replaced mail_push.
It is about:
[MOV] ocn_client: Odoo Cloud Notification for mobile push notifications
odoo/enterprise@7587be4663

Indeed counters are impacted by code located in enterprise because
those are "maximum queries" counters.
As ocn_client is an auto-install module enterprise runbot would
be broken if the counters weren't updated.
2018-08-22 11:16:14 +02:00
XavierDo 2831fa7926 [IMP] core, test_mail: improve query count assertions
-remove margin
With the spirit of making tests determinists,
we can remove margins to have a real test of query count.

-mock random on assert query count
bus gc is triggered using random. Therefore, when send_many is called,
we have 1% chance to have more query. Mocking random.random to 1
will disable gc during query count tests (not during warmup).
Could be interresting to put gc collection in a cron latter

-add more info on querycount
Adding file and line number on query count failure/info will help to update
the query counts.

-update query count based on enterprise
Update all query count with enterprise values (exactly)

-normalize query counts with enterprise
voip module add a read on activity type (during create) in enterprise,
leading to one more query but also more information in cache.
Therefore, the next assertion will need one more query to access this data
in community.
Adding an access to activity type in the first assertion will allow
to have the same cache state in community and enterprise.

Task: #1878588
PR: #26476
2018-08-21 16:56:54 +02:00
XavierDo 616fa4f6e4 [IMP] mail_bot: change Odoobot to OdooBot 2018-08-21 13:44:33 +02:00
XavierDo f83c313631 [IMP] mail_bot: improve answers, initialisation and others
1. Odoobot shouldn't talk to admin when demo data are installed
Odoobot will talk to a user on it's first connection, meaning that
a dev will see this chat window a lot. The state disabled is not a
real state but is explicit, the odoobot wont be initialized in this
case. It is still possible to test odoobot flow with demo user.

2. remove old odoobot image and update link

3. small improvements in odoobot answers
2018-08-17 13:06:43 +02:00
XavierDo b7ff3544ee [FIX] test_mail: update query count 2
Update the query count to avoid the runbot to be randomly red
Temporary fix!!!!! Will need to check with in details what is the
cause of this.
Those are the changes for the second part of test
2018-08-14 17:23:23 +02:00
XavierDo 2222a1c21e [FIX] test_mail: update query count
Update the query count to avoid the runbot to be randomly red
Temporary fix!!!!! Will need to check with in details what is the
cause of this.
2018-08-14 15:06:41 +02:00
XavierDo 2df29bcfbd [IMP] mail_bot: make odoobot statefull
The current implementation of odoobot is stateless, making him a little dummy.
Adding a state on the user allow to be sure that the user don't skip a step,
or loop back to a previous step.

States also allows odoobot to repeat the question when the user don't give the
right answer.

A quick modification asked by FP before freeze, in order to change the field
type in time.
2018-08-13 21:45:53 +02:00
Prakash Prajapati 36854d3bda [IMP] mail: allow to reschedule assigned user on automated activities
Purpose of this commit is to add possibility of rescheduling the assigned
user on automated activities. Currently rescheduling is limited to updating
the deadline. In some cases we want to be able to update the assigned
user of an automated activity.

Tests are added to avoid regression.

This commit is linked to task ID 1838956 and PR #25899.
2018-08-10 15:36:04 +02:00
Thibault Delavallée 1e7eb76c30 [MERGE][IMP] mail, mail_bot: improve Discuss onboarding and add your new best friend
Purpose of this merge is to improve onboarding of Discuss. This is done via
a wow effect and a bot to test the Discuss app; otherwise you have nobody to
talk to. Purpose is also to improve retention as "the best way to increase
retention is this: when the user invites someone, when this guy activates its
account, the user gets a push notification from the invited user that just
logged in; that way he will come back to Odoo and start discussing with its
colleagues.

Concerning your new best friend: it is not a dog but Odoobot.

See sub commits for more details. This merge is linked to task ID 1838588 and
closes PR #25075.
2018-08-10 13:43:47 +02:00
Christophe Simonis 7499b47ffa [MERGE] forward port branch saas-11.4 up to edd586002e 2018-08-10 13:37:21 +02:00
XavierDo cf505c3698 [ADD] mail_bot, im_livechat_mail_bot: add Odoobot, your new best friend
Purpose of this commit is to improve onboarding with a wow effect and a bot
to test the Discuss app. Otherwise new users have nobody to talk to. Retention
will be improved by both increasing interactions and onboarding of Discuss
features.

This commit adds a simple bot in discuss. It answers some questions, helps
users getting their hand on discuss and eases the onboarding.

In this version, the flow is quite simple, and only im_livechat adds some
logic in order to show canned response. The logic is contained in new
modules: mail_bot and im_livechat_mail_bot in order to keep everything
well separated. It also allows users to remove the mailbot if they do not
want to keep this functionality.

Odoobot will only answer if he is in the onboarding conversation (alone
with a user in a channel of type chat) or if a user pings odoobot.

Odoobot logic applies to both standard chatter / channel messages and
also transient messages (like help commands).

Specifications

 * 2 minutes after first sign in, users will receive a direct chat from
   Odoobot;
 * make Odoobot an archived partner;
 * scenario

  * Odoobot: "Hello, I'm here to help you discover chat features. Try
    answering me with an emoji :)";
  * User:  Send emoji
  * Odoobot: "Great! :) Did you notice that you can also send attachments,
    like a picture of your cute dog? Try it!"
  * Odoobot: "Not a cute dog, but you get it :) To access special features,
    start your sentence with "/" (I.E. /help)""
  * User: /help
  * Auto message then Odoobot: "Wow you're a natural! As a channel usually
    contain a lot of users, you can grab the attention with a ping. Try to
    ping me with @Odoobot!"
  * User: @Odoobot lorem ipsum

  * if Livechat installed

   * add 2 demo canned response so it does not look weird (like "Hello, how
    may I help you?" and "Have a nice day!")
   * Odoobot: "Perfect! <br> Try to type ":" to use canned responses."
   * User tries canned
   * Odoobot: "Good, you can customize your canned responses in the live chat
    application. <br><br> + réponse suivante"

 * Odoobot: "There's 3 different ways in Odoo to interact with your
   colleagues:  via this chat window, [img of chat window] via the Discuss
   application [img of Discuss app + icon on it] or via the chatter [img of
   the chatter]. Aaaaand that's it! Enjoy discovering Odoo! :)"
 * random answers to ping/bad answer

  * "Mmmmh I'm not sure what you mean.. Can you try again?"
  * "I'm afraid I don't understand. Sorry!"

 * when someone pings @OdooBot with no reason: Odoobot: Yaaaay that's me!
   [party emoji]
 * fun stuff to add for some answer

  * User: i love you / love
  * Odoobot: Aaaaaw that's really cute but, you know, bots don't work
    that way. You're too human for me! Let's keep it professional <3
  * User: Fuck
  * Odoobot: That's not a really nice thing to say, you know? I'm a bot but I
    have feelings, ok?! </3

This commit is linked to task ID 1838588 and PR #25075.
2018-08-10 13:33:28 +02:00
Christophe Simonis 7717f082c0 [MERGE] forward port branch saas-11.3 up to af35aea6b0 2018-08-09 19:33:32 +02:00
Christophe Simonis a98131d5bc [FIX] test_mail: bump query count
An extra query is made because of new group added to fields in 57ea939eda.
2018-08-09 18:52:46 +02:00
XavierDo d6a601fe3f [IMP] mail: do not subscribe inactive partners
We do not want inactive partners to be added as followers. Indeed this may
lead to unwanted notifications send as inactive partners are not easily
found in the various widgets. It also creates unnecessary data and
computation.

This commit has a small impact on performances as we choose to do it in
message_ subscribe method. Private _message_method is left untouched as
parameters given to this method are left to caller control.

This commit is linked to task ID 1838588.
2018-08-09 16:30:52 +02:00
Pierre Paridans 7309981426 [IMP] mail: Add 'Next Activity' in server action type
Purpose
=======

As a server action could add followers on a record, here the goal
is to be able to add a next activity on a record.

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

Based on the configured trigger, we can add a next activity on a record
by specifying :
- The activity type
- A summary
- A note
- A due date in x days/weeks/months
- A responsible
2018-08-08 17:35:34 +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
Thibault Delavallée df8130b2fa [REF] test_mail: update counters due to enterprise mail_push update
This commit is related to enterprise commit that updated mail_push. It is about
[REF] mail_push: optimize mail.message notification process override

It updates code of mail_push to lessen its impact on mail-related code. It
allows to change a few counters in test_mail. Indeed counters are impacted
by code located in enterprise because those are "maximum queries" counters.
As mail_push is an auto-install module enterprise runbot would be broken
if the counters weren't updated.

This commit is linked to task ID 47934 and PR #24033. No functional change
should occur with this commit.
2018-08-07 15:42:50 +02:00
Thibault Delavallée 6de76cc4f1 [REF] mail: optimize notification recipients data fetch through SQL query
In this commit we update _notify method of mail.message to fetch most data
related to notification process in a single query.  Indeed posting a
message can be a costly process, especially when involving several partners,
channels, depending on their notification status, user groups, ... Most
of the required data can be fetched in a single hand-tuned query.

Purpose is to lessen query count. Side effect of this commit is that code
is less recordset based and therefore more low-level. It is also harder to
customize the behavior through inheritance as it implies rewriting a bit
more of code.

This query is located in a private method on follower model. It takes
parameters allowing to either fetch data related to followers of a given
subtype, either related to some partners and channels. First use case is
related to the process of posting a message with a subtype that triggers
notification of followers. Second use case is related to notifying some
specific partners or channels of a given message. It takes notably into
consideration internal subtypes and active field of partners, allowing to
correctly handle corner case for deactivated followers and portal / share
partners.

Notification process is divided into two steps. First one is to compute
recipient data. Second one is to apply the result of this computation and
call the various notification mechanisms accordingly. Doing so allows to
easily re-call notification process or compute some data differently
if necessary.

API of notification methods is updated to allow passing notably the values
used to create the newly-posted message. It allows in some simple case to
avoid browsing message and partners when no notification is necessary. It
saves some queries in simple case like posting messages with specific
subtypes not often followed or logging notes without mentioning people.

This commit allows to save a few queries on several performance tests as
indicated by updated performance counters. Future commits will gradually
propagate the use of this data to further lessen query count.

This commit is linked to task ID 47934 and PR #24033. No functional change
should occur with this commit.
2018-08-07 15:42:45 +02:00
Thibault Delavallée 618c42575e [IMP] mail: remove activities when archiving records
When archiving records through the generic toggle_active methods we now
remove ongoing activities.

Purpose of this commit is to avoid having ongoing activities in the systray
linked to archived records. As archiving records means we won't work on
them anymore it makes no sense to keep related activities.
2018-08-01 10:24:36 +02:00
Thibault Delavallée 964f2dc046 [IMP] test_mail: add an active field on activity test model
It will allow to test behavior of activities with archived records in mind.
2018-08-01 10:19:57 +02:00
Thibault Delavallée 96a9e70a3a [IMP] mail: create tracking value using the insert multi
Purpose of this commit is to speedup tracking values creation by manually
creating them using the newly-introduced multi create. As tracking values
creation is already done manually as sudo when creating mail message we
just update the code to directly insert them as multi.

This commit is linked to task ID 1870656 and PR #26068. No functional change
should occur with this commit.
2018-08-01 10:15:02 +02:00
Thibault Delavallée 084b7179cd [IMP] test_mail: update counters
Commit 896e36edab added support of multi insertions when creating new
records. This had a great impact on mail-related tests involving several
followers update. This commit updates the counters to match the current
runbot state on master.

This commit is linked to task ID 1870656 and PR #26068. No functional change
should occur with this commit.
2018-08-01 10:15:02 +02:00
Thibault Delavallée 792efc8615 [IMP] mail: notify people when another user assigns them on an activity
When someone assigns an activity to another user it is a good idea to
notify this user a new activity has been assigned to him. This is done
using the message_notify method that sends a notification either in the
Inbox either by email depending on the user preferences.

This commits is linked to task ID 1854820. Closes PR #25265.
2018-07-27 17:22:31 +02:00
Thibault Delavallée 4b348c6ed9 [IMP] test_mail: improve assertNotification method
Purpose is to be able to test generic notifications, not only those
attached to some messages.
2018-07-27 17:22:03 +02:00
Thibault Delavallée 5d795d16f9 [IMP] mail: remove unused imports 2018-07-27 17:22:03 +02:00
lejeune quentin ec35eca7c6 [IMP] mail : Add possiblities to sequence tracking fields in the chatter
Fields in the chatter can be organized with a business logic.
Here fields for CRM and Website E-commerce have a tracking sequence.
For other fields/module just add "track_sequence=x" on model
2018-07-25 15:41:30 +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
Christophe Simonis 73652a0b19 [MERGE] forward port branch saas-11.3 up to 50860317cc
Note: 1aacc96262 has been ignored and will
be forward-ported later
2018-06-15 13:27:27 +02:00
Thibault Delavallée 9e811c608c [IMP] test_mail: add a tag on performance tests
It allow to easily recompute performance-related tests when working on
mail thread features. Tags are awesome.
2018-06-08 15:20:03 +02:00
Thibault Delavallée 60614d9961 [FIX] test_mail: fix timezone issue in activity test
Due to timezone difference between two test users the state of activities
depend on the time when the test is running. Indeed if user 1 plans an
activity for tomorrow this could already be today for user 2. Test
that ensure tomorrow is correctly computed should therefore be done with
users being in the same timezone. Current behavior is correct as activities
manipulate date that cannot always be timezoned back to another timezone.

How to reproduce the issue before this fix: run the activity mixin tests
between 0:00 and 1:00 in +1 TZ (Brussels).
2018-06-07 13:59:02 +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
Mathieu Duckaerts-Antoine 299ebb2cdf [IMP] mail: add moderation on channels
Purpose of this commit is to allow moderation on incoming messages in
discussion channels. On some channels on which moderation is required
messages should be in a pending moderation stage. Moderators can accept
or refuse messages as well as always allow or ban messages coming from
a given set of emails.

Channels now have an option to be moderated. Moderators can be added on
channels. They have access to a specific UI in Discuss to see and take
action on messages waiting for moderation.

Concerning mail.thread message that are pending moderation are not notified.
It means nobody receives a notification about them. Moderation process calls
the notification once the message is validated.

Various features included in this commit :

 * a model is added to store the decision about emails, allow or ban;
 * access rights are updated so that only moderators can modify moderation
   fields on message;
 * specific bus notifications are send to moderated people as well as to
   moderators on incoming emails as well as when a decision is taken;
 * options are added on channels to send explanations to moderated emails;
 * options are added on channels to write and send guidelines explaining
   why and how moderation is performed;
 * a reminder is send daily to moderators with remaining messages to moderate;
 * discuss UI is adapted and a new channel is added below Inbox and Starred
   giving access to moderation tools;
 * chanenl UI is adapted allowing to moderate directly inside channels;

This commit is linked to task ID 29521. Closes #21921.
2018-06-06 16:01:33 +02:00