Commit Graph
163 Commits
Author SHA1 Message Date
Christophe Simonis 8d7ee39213 [MERGE] forward port branch saas-11.3 up to 8a0e819d0b 2019-05-29 14:06:12 +02:00
Christophe Simonis 8a0e819d0b [MERGE] forward port branch 11.0 up to 3e12f2ff56 2019-05-29 11:10:34 +02:00
Nans Lefebvre c52b9dfc37 [FIX] mail: fix mail template onchange
The stable behaviour of the mail composer is the following:
- if a template adds new attachments, the composer only has this list
- if a template doesn't add attachments, the list is unchanged
- if no template is set, the list is cleared up
In the case of templates, we also check that both static and dynamic attachments
are added to the list.

We clean up after c6d718f211 and subsequently 516f22c398 which failed to take
into account the fact that the attachement list could be a blend of commands
and ids.
Transforming that is taken care of by _convert_to_write, which semantics was
changed by c6d718f211.
To keep the second behaviour, we thus need to add a (5,) command.

opw 2003197

closes odoo/odoo#33707

Signed-off-by: Nans Lefebvre (len) <len@odoo.com>
2019-05-28 18:19:26 +00:00
Christophe Simonis cffd147cfd [MERGE] forward port branch 11.0 up to a20a31486c 2019-05-28 15:52:00 +02:00
Christophe Simonis 37bca6ae50 [FIX] test_mail: bump again query count
Enterprise make more queries...
2019-05-17 11:48:43 +02:00
Christophe Simonis 8f6c7c20d6 [FIX] test_mail: bump query count
Oversight of previous forward-port.
2019-05-17 10:51:13 +02:00
Nans Lefebvre 4c3698aa3f [FIX] mail: add all attachments at template onchange
Fine-tuning of 516f22c398.
This commit missed attachments that are linked to a mail.template,
which should be added to every mail sent using the template.

To make sure that we both fix the duplicates and the generation issue,
we add a test.

opw 2000515
opw 1998782

closes odoo/odoo#33653

Signed-off-by: Nans Lefebvre (len) <len@odoo.com>
2019-05-24 13:45:50 +00:00
Christophe Simonis e9068c290b [MERGE] forward port branch 11.0 up to 0196a6feb5 2019-03-25 16:47:05 +01:00
Christophe Simonis 2d824a5b7a [FIX] test_mail: bump expected query count
The prefetch hell patch [1] generate one more query.

[1] a07a076c45
2019-01-08 15:35:34 +01:00
Christophe Simonis 11b1e12cde [MERGE] forward port branch saas-11.3 up to e9068c290b 2019-03-25 18:28:16 +01:00
XavierDo 49db3d92e7 [FIX] mail, test_mail: don't notify inactive users
We don't want to notify inactive followers,
especially in the case of oddobot that was considered
as a inactive partner in _notify_compute_recipients.

The computed recipient data for odoobot are
(pid:2 active:False pshare:True notif:None)

It was considered as a partner and notified by email.
This fix simply removes inactive partner from partner to notify.

closes odoo/odoo#31734

Signed-off-by: Toufik Benjaa (tbe) <tbe@odoo.com>
2019-03-11 12:50:05 +00:00
Julien (juc) Castiaux 988e769073 [FIX] mail: non translated field when posting emails from crons
1) Configure both an incoming mail server and an outgoing one.
2) Install CRM.
3) Create a sale team, use the incoming mail address as mail alias.
4) Add a user with a valid email as follower of that team in the
   chatter.
5) Enable developer mode, become super user via the developer tools.
6) Change the language of the super user to french.
7) You may want to modify the default gather/post time interval.
   to receive/post email more regulary in the scheduled action.
8) Using an external mail client, send a mail to the incoming mail
   address.
9) Let the two scheduled actions run by themselves.
10) The mail sent to the user has the "Lead/Opportunity" in english
    wheras the rest of the email is in french.

opw-1917993

closes odoo/odoo#31034
2019-02-15 12:41:50 +00:00
Lucas Perais (lpe) a46138cb01 [FIX] mail: create partner from template in right company
Before this commit, when creating a partner automatically when creating
a message with a template, the company on the partner was wrongly set

After this commit, we try to retrieve the company from the model on the template

OPW 1934392

closes odoo/odoo#30893
2019-02-06 16:48:23 +00:00
Christophe Simonis b42cd64ace [FIX] mail: do not try to send email to partners without email
As `formataddr` only accept strings as arguments, an exception was
raised when trying to notify a mailing list channel with followers
without email.

closes odoo/odoo#30492
2019-01-23 19:22:00 +00:00
Nicolas Martinelli 0687f17622 [FIX] mail: model description
Do not use the model `_description` field which cannot be translated. Use
the `display_name` of the corresponding model instead.

Moreover, `<t t-esc="'%s' % model_description or 'document'"/>` gives
`'None'`, while `'document'` is expected.

This adds a query to some tests, which is expected since `display_name`
requires information stored in the DB, while `_description` is defined
at the Python level.

opw-1908420
2018-12-10 11:59:03 +00:00
Christophe Simonis 61df7749cc [FIX] test_mail: bump expected query count
e88c5c1ece uses `sudo()` to get user name,
which lead to more queries due to cache miss.
2018-10-09 19:04:59 +02:00
XavierDo 136fee6fcf [FIX] mail_bot: only display odoobot once in mention suggestions
Before this commit odoobot was appearing twice in mention
suggestions when talking to odoobot.

The initial need to be able to ping odoobot from everywhere led to the
override of channel_fetch_listeners. This is not usefull anymore.

This fix simply removes this override to avoid this problem since we
don't have a real use case where we need to ping odoobot in another
channel.

Task 1907142

closes odoo/odoo#28791
2018-11-28 11:35:12 +00:00
Alexandre Kühn 9df8e88046 [FIX] mail, test_mail: make mail_tour work
This tour was broken since the following refactoring:
https://github.com/odoo/odoo/commit/cd34f6de727d5b3858420cff3c9d3c5995c4e75c

With this commit, mail_tour should work correctly, and
is automatically run on runbot.

Note that the tour is automatically run in the module `test_mail`,
so that the tips are not displayed by installing Discuss.

Task-ID 1912730

closes odoo/odoo#29040
2018-11-26 16:26:34 +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
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