Commit Graph
111 Commits
Author SHA1 Message Date
Olivier Dony 84af9382e2 [IMP] mail: avoid costly queries on messages
The combined domain for moderated messages used to trigger a complex
database query with two OR conditions on the mail_message table.
Unfortunately PostgreSQL seems to be unable to optimize this with
indexes, or to detect that one of the conditions is void (included `AND
FALSE`). On large mail_message tables, this significantly slows down
calls to message_fetch, e.g. 6s instead of ~70ms, while returning the
same results.

As a workaround, move the logic for generating the moderation domain to
the server side, where it can be:
 - optimized out when the user is not a moderator
 - split into 2 distinct DB queries in order to avoid the pathological
   case

After this change, calls to message_fetch with and without messages
to moderate execute in respectively ~50ms and ~150ms, instead of 6s, in
a test database with 25 million messages.

The modified message_fetch signature is backwards-compatible.

+ modified mock server used for the tests, which unfortunately
duplicates most of the business logic.
2018-09-20 12:41:03 +02:00
XavierDo 97dbdc418d [FIX] mail: keep update of subtypes in dropdown
Since saas-11.4 the subtype dropdown don't keep changes of subtype.

Before saas-11.4 the update was relying on the fact that the follower id
changes on each subtype edition. This is no longer the case.
The test is addapted to remove the hack simulating this behaviour.

The read_followers route is not called if no there is no changes
in the follower ids
https://github.com/odoo/odoo/blob/905e01921f3c3ef43ace6fc537d1d8c0d280002c/addons/mail/static/src/js/followers.js#L195
Leading to the follower list not being update

Note that the subtype update in dropdown was working fine after adding a
new follower: the read_followers will return a None as suptype when called
for a list of partner not containing the current user. Since the subtypes
was falsy, the render was not rendering the dropdown again, keeping
the value of the checkboxes. We can still create some inconsistency by
editing the subtype from the follower list. To avoid that a check is made
when updating subtypes after calling read_followers.

The chosen solution here is to keep the update on subtypes in memory.
This will avoid a call on read_followers to fetch information that we
already know, using the assumption that the operation was successfull
whish should be the case when a user edit subtypes on a record
he has access to.

Others solutions:
-force the call to read_followers with the current user, maybe by removing
it from this.follower after editing subtypes.
-call read_subscription_data explicitely

Obviously follower.js should be refactored to fix this a better way.

Task: #1886982
PR: #27093
2018-09-19 14:10:19 +02:00
Christophe Simonis 6c103589c1 [MERGE] forward port branch saas-11.3 up to ea0b3d600d 2018-09-14 14:56:51 +02:00
Christophe Simonis ea0b3d600d [FIX] mail: declare services used in forward-ported test
Only broke test with enterprise overwrite.
2018-09-14 14:05:24 +02:00
Christophe Simonis f3fa5a5ef7 [MERGE] forward port branch saas-11.3 up to 1e0a92c996 2018-09-13 19:30:33 +02:00
Christophe Simonis 826cd9b3d3 [MERGE] forward port branch 11.0 up to c3ea0a7811 2018-09-10 19:21:57 +02:00
Lucas Perais (lpe) bb12890977 [FIX] mail: activity don't loose text of feedback popover
On an activity, click Mark as done, the popover pops over
Now write some text in it, but click somewhere else, like to copy/paste something
The popover looses focus, and your text disappears

After this commit, we store the value of the popover when hiding it,
then, when when showing back the popover, the value is reinjected

OPW 1873999
closes #26315
2018-09-10 11:24:42 +02:00
Alexandre Kühn 5dcfb30fb3 [FIX] mail: no crash on opening messaging menu after receiving a needaction message
Revision on https://github.com/odoo/odoo/commit/299ebb2cdf63de2e3967da0d2f3e7effd239812b
    [IMP] mail: add moderation on channels

The commit above adds moderated channel. When a message is pending moderation,
it is not yet linked to the channel server-side, which is why there is a hack
to set `channel_ids` on the client side so that the message is visible on the
corresponding channel (only for author of message and moderator of channel).

It is only when the message is accepted that this message is linked to the
correct `channel_ids`. The server provides the updated list of channels that
this message is linked to, but it misses static channels that only make sense
on the client-side, such as "Inbox" or "Starred".

This commit solves the issue by only extending the list of channel registered
on the message when it is accepted, so that static channels are not unlinked
from the message.

Note that it is necessary to update `channel_ids` of the message,
because there could be "relay" channels. In other words, when the moderated
message is accepted, there could be more channels that contain this message.
2018-06-29 12:57:05 +02:00
Christophe Simonis c8bb02141d [MERGE] forward port branch saas-11.3 up to 3cdcbce93c 2018-06-28 19:01:52 +02:00
Christophe Simonis 40836194c2 [MERGE] forward port branch saas-11.2 up to 12ddec3a76 2018-06-27 13:41:00 +02:00
Aaron Bohy ffe9bb501b [FIX] mail: test utils: mock is_odoo_focused
In the mocked version of the longpolling bus used in tests, the
is_odoo_focused function should be defined to prevent crashes when
we simulate incoming messages.
2018-06-21 13:55:10 +02:00
Alexandre Kühn b74d1e90ef [FIX] mail: warn user on record reload before post message
Before this commit, the user could lost some unsaved changes in a record when
posting a message in the chatter.

This is due to reloading the data on the record, which is necessary because
a `message_post` may make some changes on the record [1].

With this commit, a dialog will warn the user that the record will be reloaded
in the following cases:

    a) posting a message in the basic composer that will reload the record
    b) opening the full-composer when the record is dirty

Indeed, any operation after opening the full-composer will always refresh the
record (even closing the dialog).

Known issues:

    - a record is not considered as dirty if we only make changes in its
      description from a pad.

      > the content of the pad will be erased without any warning...

[1] https://github.com/odoo-dev/odoo/commit/803d5cf04835fcf8e7ddb143e1ab140408beef93

opw-1825005
2018-06-15 17:46:32 +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
Prakash Prajapati d8a5141c17 [FIX] mail: Add a mark as read option on systray message dropdown
- 'Mark as Read' icon will be shown by moving the mouse over the message
- if it's channel then make it Mark as Seen
- if it's inbox notification then mark all message as read
- The inbox notification icon has been changed

This commit is related to task ID 1817646
2018-06-06 17:01:26 +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
Barad Mahendra 4a59f93d15 [IMP] mail, calendar: add today meetings in systray
Purpose of this commit is to display today meetings in the systray. This will
help people in their daily job to have quickly access to their meetings.
It is displayed along with activities and reminders to have all current work
to do in the same place.

Displayed meetings are ongoing or not yet started ones of the current day.
All-day meetings of the current day are also shown. Done meetings are not
displayed to lessen noise.

Clicking on the systray will open the calendar view of meetings in a day
mode. This is done by a small modification in the calendar view allowing
to choose the display mode from context in addition to the mode attribute
of the action definition.

This commit is linked to task ID 60593. Closes #24438. Thanks to @ged-odoo
for quick reviewing.
2018-05-31 16:49:56 +02:00
Mahendra Barad 642970494e [REF] mail, note: rename systray method giving data for web client
As it becomes used to display more things than just counting activities let
us rename the method. Future commits will add new features in the systray
like meetings.

This commit is linked to task ID 60593.
2018-05-31 16:45:51 +02:00
Christophe Simonis f36e6917bd [MERGE] forward port branch saas-11.3 up to 37eed7c509 2018-05-29 17:34:43 +02:00
Géry Debongnie d01787c19d [IMP] web,mail: improve search view for mobile devices
With this commit, we introduce a better screen to manipulate the search
view in a mobile device.

Note: most of this work was initially done by suh-odoo, then was adapted
and moved to community by myself.

task 31464
2018-05-23 10:48:36 +02:00
Christophe Simonis 644f0959d0 [MERGE] forward port branch saas-11.2 up to 1655202924 2018-05-17 14:23:37 +02:00
Alexandre Kühn 93f9131450 [REVERT] "[IMP] mail : display mentions in green color in edit mode"
This reverts commit c778de44c7.
2018-05-16 15:06:39 +02:00
Christophe Simonis 7f707200ad [FIX] mail: adapt test to altered dom.
See c265e47a63
2018-05-14 19:01:08 +02:00
Christophe Simonis 5a751fa200 [MERGE] forward port branch saas-11.2 up to aae54ecc15 2018-05-09 15:45:20 +02:00
Christophe Simonis ac63dfc8f4 [MERGE] forward port branch 11.0 up to 8dade01e2c 2018-05-04 16:10:50 +02:00
Akash Bhavsar 8b7fb9a764 [FIX] mail: Do not close chat widnow if ESCAPE key is pressed on document viewer and keep focus on chat window input when document viewer is closed (#22741)
If document viewer is opened from chat window and when document viewer is opened then focus 
remains on it's modal, pressing escape should set focus back to chat window's input element,

if file selecor dialog is opened and if user press ESCAPE on file selector dialog to cancel file selector 
dialog then it should not close chat window instead it should set focus on chat window input and on 
second ESCAPE key chat window should be closed
also increase z-index of document viewer dialog so image remain on top of cht window

OPW: 1777937
2018-05-03 15:16:56 +02:00
Géry Debongnie 3b3f6cc069 [FIX] mail: update test broken by forward port
The _mockMessageFetch method was changed in the mockserver in saas11.2.
The forward port then obviously broke this test, which depended on the
fact that it returns an empty list.
2018-04-24 14:37:14 +02:00
Christophe Simonis 1f22b81203 [MERGE] forward port branch saas-11.2 up to 7113b70762 2018-04-23 19:36:25 +02:00
Christophe Simonis e8bf128318 [MERGE] forward port branch 11.0 up to 3ab25b60bc 2018-04-23 18:15:25 +02:00
Martin Trigaux 82de88b066 [FIX] mail: cover more cases for URLs
Transifex URLs have an original scheme using #lang, followed by the module or
'$' (for any module) and the searched text can be quoted

Before this commit the link was cut after
https://www.transifex.com/odoo/odoo-11/translate/#fr/, making the link not
clicable

Closes #24346
2018-04-20 15:45:08 +02:00
Alexandre Kühn f2ba1cc843 [FIX] mail: no crash when clicking on systray inbox notification not linked to a document
Before this commit, when we have a notification in the messaging menu (systray)
that comes from a message in inbox which isn't linked to a document
(e.g. a task), clicking on it result in a crash.

This issue comes from a typo of a recent js mail refactoring [1]

Although this is only a 1-line fix, there are no tests on the messaging menu
widget in the systray. Therefore, this commit also introduces some basic tests
of this widget, in addition to the test related to the fixed issue.

[1] https://github.com/odoo/odoo/commit/02ec09cb1c3e2d7bc7968f40c18f2208d7f3f498
2018-04-20 12:13:51 +02:00
Géry Debongnie dc35d740a6 [FIX] mail: prevent race condition in discuss
The discuss application starting process is strongly asynchronous.
However, it relies implicitely on the fact that the widget is not
destroyed in its starting process.  For example, if the widget is
detroyed before the updateChannel method is called, then any call to the
chat manager service will return undefined and the widget will crash.

When discuss is destroyed exactly between the start and the end of the
creation of its search view (which is asynchronous), then it is possible
to have a crash, because the search view will be destroyed when the
do_search method is called.

Note that we had to fix discuss mobile as well:
The _setChannel method is supposed to return a deferred, but the mobile
override did not return it.  As a result, a test in the mobile suite
failed because this.alive takes a deferred in argument.
2018-04-13 17:16:11 +02:00
Géry Debongnie 1d8466ab54 [FIX] mail: prevent race conditions in discuss
The discuss application starting process is strongly asynchronous.
However, it relies implicitely on the fact that the widget is not
destroyed in its starting process.  For example, if the widget is
detroyed before the updateChannel method is called, then any call to the
chat manager service will return undefined and the widget will crash.

When discuss is destroyed exactly between the start and the end of the
creation of its search view (which is asynchronous), then it is possible
to have a crash, because the search view will be destroyed when the
do_search method is called.

Note that we had to fix discuss mobile as well:
The _setChannel method is supposed to return a deferred, but the mobile
override did not return it.  As a result, a test in the mobile suite
failed because this.alive takes a deferred in argument.
2018-04-13 17:14:49 +02:00
Thibault Delavallée 3f7c75ef1f [IMP] mail: display white background for user notifications in chatter
User notifications are defined as
 * notes;
 * pushed to user Inbox or email through classic notification process;
 * not linked to any document, meaning model and res_id are void;

When pushed in user's Inbox they are currently displayed with a gray
background like all notes. However UX experts think it should use a white
background to be easier to spot in chatter. This commit makes it work.
From now on discussion and user's notifications are displayed using a white
background. This commit is related to task ID 1829872.
2018-04-10 17:15:26 +02:00
Dharmang Soni 807c4c3f5e [REF] mail, note: move reminder feature from mail to note
This commit refactors f488dc58c3 that added reminder feature in activities.
After merging it was suggested specifications were not correct and it has
been decided to move the whole reminder feature in note.

Reminders are now notes instead of activities. Now when having note appµ
systray proposes to create a note / reminder. A note.note record is created
with info given by the user. If a date is given in the systray quick create
then an activity is scheduled on this note.

This means user can create records in activity systray that are not
activities but notes used as reminders. Those will use the first availableµ
note column for the user.

As reminders are now notes the support of activities not linked to any
document is removed, as well as archiving activities and tests linked to
that behavior.

This commit has been not carefully tested nor in-depth reviewied. It is
considered as too important for the upcoming freeze. This closes task ID
1833628. Closes #24129 . Many thanks to @dpr-odoo for its quick development
and good work on this task.
2018-04-09 14:35:06 +02:00
stefanorigano 6e12372f95 [IMP] mail: attachments list design
With this commit, the attachments displayed in a thread (typically a
chatter) are properly styled.
2018-04-06 14:14:32 +02:00
Alexandre Kühn fef6d7967f [FIX] mail: various discuss test fixes
This commit fixes two issues with discuss tests (JS):

    1. Improved mocked `message_fetch` rpc

        Some tests were incorrectly mocking the `message_fetch` rpc.

        With this commit, the mock server correctly mock this route,
        so that tests should simply pass the records as data, and the
        mock server correctly handles this rpc.

    2. Patch `_.debounce` and `_.throttle`

        The test "older messages are loaded on scroll" failed with
        Google Chrome right after destroying the widget discuss.
        This is due to a debounced function that called its inner
        function at this moment.

        With this commit, any discuss test patch `_.debounce` and
        `_.throttle` so that the inner functions are executed
        immediately and synchronously.
2018-04-05 14:57:49 +02:00
Dipalee Bhalodia 1fa8f67926 [FIX] mail: click on unstar all button should reset the starredcounter
Before this commit:
Clicking on 'unstar all' button removes all messages from starred channel
but it only decreases the counter as many as there are displayed messages
on screen.

For example, if there are 40 messages starred, only 30 messages
are on screen (default limit) but unstar all will decrease counter
only for those messages instead of 40.

After this commit:
clicking on 'unstar all' button will correctly take in account all
fetched messages and not only displayed messages.
So now, after clicking on 'unstar all' button will update the starred
counter to 0.

task-ID: 33958
2018-03-30 16:42:59 +02:00
dbhandAaron Bohy ea97fa3ac6 [IMP] mail: Discuss: load older messages automatically
After this rev., in Discuss, messages are automatically loaded when
the user scrolls to the top of the channel.

Task 33958

Co-authored-by: Aaron Bohy <aab@odoo.com>
2018-03-30 15:30:37 +02:00
f488dc58c3 [IMP] mail: allow to use stand alone activities as reminders
This commit allows to create personal reminders and to manage them using
activities. It is done using activities not necessarily linked to a record
but only to a user. Reminders can be used for example as a personal todo
list.

Technically we choose to model a reminder as an activity related to no
record. This means having a void res_id and model. An activity type is
added to classify reminders in it.

Settings reminder as done is not done like classic activities. Indeed classic
activities are unlinked and a message is logged on the related document.
As there is no document for reminders those are archived instead. It means
an active field is added as well as an override of toggle_archive to update
systray counter.

Activities systray widget is improved to display reminders in activities
list. This entry leads to a kanban view of activities allowing their
management. It is also possible to create them directly from the systray
allowing a quick creation of reminders.

This commit is related to task ID 41745. Closes #22143 .

Co-authored-by: Dharmang Soni <dpr@odoo.com>
Co-authored-by: Xavier Dollé <xdo@odoo.com>
2018-03-27 13:26:41 +02:00
Mehul Patel 78d681d14f [IMP] mail: composer / chatter new followers email address tooltips
Before this commit, many2many email tags showed the recipient's name
and email address. Most of the time, the text was cut off in order to
fit in the maximum length of a many2many tag, so the email address was
usually not visible.

With this commit, many2many email tags now show only the recipient's
name. The recipient's email address is displayed when hovering on the
tag.

Task-ID 36677
2018-03-16 09:48:13 +01:00
Thibault Delavallée b4ecbcfaa3 [REM] mail: remove o_mail_note class in chatter
Purpose of this commit is to clean a bit various classes and conditions.

First clean is the removal of o_mail_note class in activities less. It comes
from first implementation of activity widget and is not used anymore in
activity widgets rendering.

Second clean is the removal of o_mail_note class when displaying messages.
Only o_mail_discussion is used currently in chatter to make a different
background depending on whether the message is a discussion or not. All
we have to know to differentiate message display is whether it is a
discussion done by an user or not.

Tests have been updated to use o_mail_discussion class triggered by
the message being a discussion, aka a comment posted by an user.
2018-03-14 11:06:32 +01:00
Christophe Simonis 0f57bdba72 [MERGE] forward port branch saas-11.2 up to 42659dc70c 2018-03-09 16:25:58 +01:00
Aaron Bohy 6b9632effe [FIX] mail: adapt forwardported tests
The ChatManager has been refactored in saas-11.2 to make it fully
(and more easily) testable. This means that tests involving
messaging stuff written in previous versions need to be slightly
adapted when being forwardported to saas-11.2. In particular, the
3 tests adapted in this commit broke because of an include done in
the voip addon. Those tests have been added in 3809fc891.
2018-03-09 09:27:52 +01:00
Christophe Simonis 7d66953d17 [MERGE] forward port branch 11.0 up to bfe88c50e2 2018-03-08 14:06:54 +01:00
Aaron Bohy 3809fc891f [FIX] web,mail: always reload widget mail_activity
Before this rev., the field widget 'mail_activity' kept an internal
cache of fetched activities (like the 'mail_thread' and
'mail_followers'). However, for activities, this cache may cause
issues.

For instance, create a new lead in 'My pipeline', schedule a
'Meeting' activity on that lead (it opens the Calendar view so
that real meetings can be created), create a meeting 2 weeks from
now, go back to the lead form view: the activity still diplays that
the meeting is today (when the view is refreshed, the correct date
is displayed).

This rev. removes the internal cache for this field widget, as the
activities can easily be updated in business flows (unlike messages
or followers).

This rev. also fixes a bug in the BasicModel, where the res_ids of
a list datapoint was altered in place to return a list of x2many
commands instead of the list of ids when being stringified. This
caused a traceback when opening a lead with activities, as soon
as the internal cache had been removed.
2018-03-08 12:39:21 +01:00
Alexandre Kühn 60bbce2e53 [FIX] mail: nocontent helper discuss (inbox & starred)
Revision on https://github.com/odoo/odoo/commit/a87d761fdbf345ada5dc93e0a686b08a0f5a0417

From the UX/UI changes above, we also changed the style for empty
inbox and starred in Discuss.

There are two issues with the empty boxes message:

    1. The text is not centered at all (one word per line,
       and everything is stuck on the left-side of the screen)
    2. The style is inconsistent with nocontent message on search

In this commit, inbox and starred use the same style as the no_content
message from a search. The style of the nocontent from a search has been
slightly changed to mimick the intended style for inbox and starred:

    - centered text
    - title is in bold 125% font size
    - other text is not in bold, 115% font size.
2018-03-08 09:30:37 +01:00
Alexandre Kühn 3c821d4035 [FIX] mail: no traceback with attach/detach (discuss mobile)
Revision on https://github.com/odoo/odoo/commit/02ec09cb1c3e2d7bc7968f40c18f2208d7f3f498

From the refactoring above, some snake_case attributes have been
converted into camelCase. That was the case in discuss.js, but
we missed to propagate the changes in discuss_mobile.js.

This commit fixes the traceback that came from the mistake above.
2018-03-07 15:11:01 +01:00
Alexandre Kühn 72b75028d7 [FIX] mail: tests: correctly destroy with createDiscuss helper
Before this commit, when using createDiscuss and performing
discuss.destroy, the parent widget was not destroyed.

This is an issue, because the mocked environment is attached
to the parent widget of discuss. Any call to this.getSession()
is mocked by the addMockEnvironment, and this mocked behaviour
is removed only when the corresponding widget is destroyed.

This commit overrides discuss.destroy(), so that the parent
widget is also destroyed, so that it removes the side effect on
this.getSession() from the mocked environment.
2018-03-06 15:19:49 +01:00
Christophe Simonis a0d7763e09 [MERGE] forward port branch saas-11.2 up to 932e641be1 2018-02-23 17:20:52 +01:00
Alexandre Kühn 1753017255 [FIX] mail: prevent crash when focusout emoji button
Before this commit, on a clear session, there was a traceback
after focusing out the emoji button next to the composer.

This is due to a DOM element that exists only after clicking on
the emoji button, and it was wrongly assumed that focusout cannot
occur without a preceding click. Indeed, we can press TAB to move
between focusable elements, so that we can have the focus in/out
on the button without clicking on it.
2018-02-22 14:23:04 +01:00