Commit Graph
1066 Commits
Author SHA1 Message Date
tsm-odoo c9b72f09d8 [FIX] bus: fix im status not updating
Odoo periodically updates the user online status. This is
done every minute and is throttled in order to ensure it won't
be triggered more than it should.

Since [1], the underscore `throttle` function has been replaced
by the `throttleForAnimation` function. This is not equivalent:
the function won't be triggered if there is no animation which
result in an outdated user status.

This issue was highlighted by the live chat: the button does
not show up when there is no available operator.

Steps to reproduce the issue:
- Log in on Odoo with live chat installed
- Go to a web page that uses the live chat widget
- Wait more that one minute and refresh the page
- The live chat button is not shown anymore: the only
operator is considered as disconnected.

This PR fixes that issue by re-introducing the underscore
throttle function: it is robust and can be needed, not all
throttles are linked to animations.

[1]: https://github.com/odoo/odoo/pull/120437.

opw-3578517

closes odoo/odoo#142160

X-original-commit: f64a7cbad3dee3ffc365b931306b1c13c8bff536
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
2023-11-15 13:56:35 +00:00
Sébastien Theys d3b7ff500b [FIX] mail: fix race condition in load_message_order
- adapt test to ensure consistent (scroll) state at each step

The issue is hard to reproduce, so the complete resolution of the issue
is not guaranteed, but the current change should do the job, and if it
doesn't, it will help to pinpoint the issue.

Estimated issue: the thread doesn't load more messages when scrolling to
bottom because the scroll to bottom is overriden by the auto-scroll top
when clicking on pin. Adding extra wait point should solve the issue.

runbot-24512

closes odoo/odoo#141999

X-original-commit: 477b1c3aa1da7261273341338f3d37ee828715f8
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-11-14 15:16:08 +00:00
Didier (did) 4064508af5 [IMP] mail: send cache control header on avatars
Before this PR cache control header for avatar was set to no-cache which is not
the right value.
This PR mark the avatar routes response as immutable when a unique string is
present. We also use the partner write_date as unique string when possible.

task-3551636

closes odoo/odoo#141326

X-original-commit: 3de4f1f1225229cbdb0512df5790ce491f04ea7e
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-11-07 21:02:27 +00:00
Maryam Kia 546f77d1ca [IMP] mail: sharing both screen and camera tests
This commit contains the tests related to the screen sharing at the same time with camera sharing on call

closes odoo/odoo#141275

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-11-07 21:02:21 +00:00
Alexandre Kühn d68488db7d [FIX] mail: several slight messaging menu improvements
Before this commit, the Messaging Menu had the following issues:

- Header is too large;
- Header color in dark theme is too white;
- Important notifications (= needactions) are not highlighted enough
  compared to muted notifications;
- Notification body and title looked too alike;
  => title should be more visible than content
- Mouse-hovering on notification items breaks background-inherit
  style of avatar and IM status;
  => side-effect of `list-group-item-action`
- Desktop: Header items slightly move when changing selection;
  => comes from `fw-bolder`
- Desktop: mark as read button was too small and not visible enough;
- Mobile: too many borders, and they are too strong;
  => undesirable dropdown style
- Mobile: Messaging Menu had poor "New message" button link whereas
  Discuss app has nice "Start a conversation" button;
- Mobile: "Start a conversation" button is not shown on livechat tab;
- Mobile: when menu is open while Discuss app is open in background,
  it's unclear whether the messaging menu is open or not;
  => missing background highlight on Messaging Menu toggler
- Mobile: State of Mobile Discuss App was not synced properly when
  using Messaging Menu at the same time;
  => e.g. unselected tab
- Mobile: Discuss app and Messaging Menu were not properly aligned;
  => Messaging Menu did not offset position based on systray navbar
  height
- Mobile: active navbar item was not highlighted enough, especially
  in white theme;
- "OdooBot has a suggestion" is shown on all tabs instead of only
  in "All" tab like "OdooBot has a request";

This commit fixes all the above issues.
Some styling issues were also affecting the Activity Menu, such as
borders and highlighted open state. This commit applies these
few improvements on the Activity Menu too.

closes odoo/odoo#140405

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-11-07 19:32:15 +00:00
TSO bc16aae6e2 [FIX] discuss: rely on streaming state flags instead of streams
Before this commit, we used to rely on duplicates of streams and the
presence of streams to know if a session was streaming.

This commit changes this and make it so that we now use streaming
activity flags instead.

This is a prerequisite for https://github.com/odoo/odoo/pull/132153 as,
similarly to webRTC "unified plan", the SFU keeps the same streams for
the whole lifespan of a connection.

closes odoo/odoo#140053

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-11-07 04:29:04 +00:00
Brieuc-brd 70f853aab9 [IMP] web, mail: adapt "Add a Reaction/emoji" icon
Prior to this commit, "Add a Reaction/emoji" and "View Reactions"
buttons had the same icon, which was confusing.

This PR adapts the "Add a Reaction/emoji" icon to make it more
recognizable.

task-3577008

closes odoo/odoo#140481

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-11-06 20:52:28 +00:00
tsm-odoo bad8d093f5 [FIX] mail: incorrect message order on previous messages load
Discuss models use relationnal fields. Since [1], the implementation
of the `unshift` method changed for `many` fields. The new
implementation is incorrect: unshifting several records results in an
insertion on the inverse order which differs from the native
implementation.

This issue broke the loading of older messages in discuss: older
messages are inserted with the `unshift` method thus in the inverse
order.

[1]: https://github.com/odoo/odoo/pull/136539

closes odoo/odoo#140747

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-11-06 12:32:00 +00:00
Sébastien Theys 06603e9dc7 [FIX] mail: show translations for emails
Due to shadowRoot, emails were not properly translated.

closes odoo/odoo#140847

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-11-03 00:49:06 +00:00
zel-odoo cf86759d1d [FIX] mail: wrong use of group_based_subscription
1. `searchPartnerSuggestions` uses`authorizedGroupFullName` to see
if the channel is public or not
2. `filteredThreads` and `getThreads` uses `hasSelfAsMember`
and `is_pinned` along with the channel type
3. search should use `displayName` otherwise the search on group
with default empty name will fail
4. fix tests.

closes odoo/odoo#140495

X-original-commit: b358c410988686610638e7ffbee1fbbbeff5f0ba
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-11-02 18:23:12 +00:00
Pierre-Yves Dufays d2f44211b9 [IMP] mail: add/modify activity client tests
We add a test that checks the rendering of the activity view and the activity
popover with activities done.

We also add a test that marks as done an activity and verify that the activity
view is updated accordingly.

And we do a correction in the test "activity menu widget: activity menu with 2
models" (assert.ok(selectContaining... was always true as an array is always
returned and [] is true in javascript).

Task-3558929

Part-of: odoo/odoo#139373
2023-11-02 13:25:48 +00:00
Sébastien Theys 2426cf369b [FIX] mail: no crash on opening non-existing channel
closes odoo/odoo#140562

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-10-31 15:54:33 +00:00
Didier (did) ceebd2e8d0 [FIX] mail: reorder direct message when opening a new one
Before this PR, newly created direct message would be added at the bottom of the
list instead of the top.
This PR fix the issues by sorting the direct messages when creating a new direct
message channel.

Task-3566728

closes odoo/odoo#139960

X-original-commit: 60cf880102615a524f2fa89c71be7f1b08d931d1
Signed-off-by: Didier Debondt (did) <did@odoo.com>
2023-10-31 10:33:49 +00:00
tsm-odoo 74f59fc59c [IMP] im_livechat: no 2 emoji icons in quick actions of message
Before this commit, messages in livechat from visitor POV show
2 emoji icons in the quick actions. This is confusing and comes
from 2 actions sharing this exact same icon: "Add a reaction"
and "View reactions".

This commit fixes the issue by reducing the number of quick message
actions to 2 for the embed live chat. In other contexts there's
"Reply-to" and "Mark as Favorite" in quick actions, so the
"View reactions" item is always in expand menu.

Note that this "dirty" fix come from 2 actions with same icon.
Eventually we should fix that by clearly making icons unique.
This solution is decent for the time being, giving us more time
to make a dedicate icon for one of the emoji actions.

task-3498446

closes odoo/odoo#140335

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-10-30 21:50:46 +00:00
Alexandre Kühn 7cf86921b4 [FIX] mail: click on messaging menu item should not rename thread
Before this commit, when opening a thread in the Discuss app and
changing to another active thread from the Messaging Meu in the
systray, the new thread was mistakenly renamed to the previous
active thread name.

This happens because the component `AutoresizeInput`, which is used
to show the thread name in the header of Discuss app, also allows to
rename the thread. The code to trigger rename was too naïve, in that
a click away was considered as a rename operation on the current
thread.

This commit fixes the issue by triggering the editing of the value
in the `AutoresizeInput` component only when the click away happens
while the input had focus. The click in messaging menu will not
trigger it as the input is not focused.

Task-3570377

closes odoo/odoo#140208

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-10-30 16:41:46 +00:00
tsm-odoo 1306635db8 [FIX] mail: fix highlight pin message from notification
Since [1], highlighting a pinned message from the notification sent
to the channel does not work anymore. This is due to a `super` call
missing. This PR fixes the issue.

Steps to reproduce:
- Go to a channel
- Pin a message
- Click on the "message" link
- Nothing happens

[1]: https://github.com/odoo/odoo/pull/121418

closes odoo/odoo#139948

X-original-commit: 68992ba05eb48459800df17707741295a4f47c9c
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
2023-10-30 07:37:13 +00:00
c0b683e2f4 [IMP] web,*: improve darkmode
This commit introduces some adjustments to the dark mode color scheme
and the use of bootstrap classes in Community.

- Mini calendar contrast -

The colors were not using variables, making them non dynamic
and breaking the contrast in dark mode.

- Avoid !important rules spreadsheet -

Prior to this commit, spreadsheet top bar was using a `bg-white` class,
making it pure black in dark mode.

Since spreadsheet is designed with light colors and we don't provide a
dark mode for it, we remove that class and set a `background-color`
property using CSS in Enterprise.

- Input color -

This commit fixes the focus behavior on the searchbar in the control
panel, the `command_palette_search`, and the `start a conversation` in
discuss.

- Copy clipboard field border color -

Make use of the `text-primary` color for the copy to clipboard field
We use the o-theme-color function to avoid an undefined since primary
doesn't exist in the o-theme-text-color map in white mode.

- Web_editor toolbar variables -

The toolbar was using the `o-brand-primary` variable
which was set to a darker shade. This caused issue when activating an
option due to how vibrant the color is.

- Improve the controls on border-color -

Introducing a custom property on the border-color to allow
further control on individual components (such as the popover).

- Improve setting tabs colors use -

Prior to this commit, the colors of the settings tabs menu were kinda
inverted. The menu was light in dark mode and dark in light mode.

We fix this by changing the values associated to the CSS variables in
use.

- Make model field selector dark mode proof -

Fixing the design of the model field selector popover in both
light and dark mode. Since the popover was using custom style with
arbitrary values, it was not designed for the dark mode and had a lack
of consistency.

To improve the design, we use variables rather than custom style, and
make sure the desired render is as close as before.

- Sign colors use -

This commit aims to improve the sign module in both light and dark mode.
There were some readability issue with some `btn-light` having poor
contrasts in both light and dark mode, and the use of some classes was a
bit unexpected (e.g `card-header` to set a grey background with some
padding).

- Improve buttons design inside listview -

Prior to this commit, this button was using custom CSS to make it look
like a primary button, while it was using classes related to secondary
buttons.

We remove the custom CSS used to style it correctly and keep our button
design consistent.

- Messaging menu layout in mail -

This commit aims to improve the design of the notifications displayed
in the messaging menu. Prior to this commit, the notifications dropdown
was using custom CSS variables overriding the regular behavior
of our dropdowns.

In fact, the layout was generating some friction:

1) Marking a notification as read would turn its background into a
darker color

2) Effects like `:hover` were all based on the custom CSS variables
resulting in an inconsistent layout.

- Multi company selector adaptations -

In darkmode the multi company selection was using the btn-light which
creates a weird effect and overrides the dropdown default hover behavior

This commit uses the btn-link to display an hover effect on the
company switch and on the checkbox while blending with the background
and the default dropdown hover effect.

- Adapts default badge design -

Improve the design of the default badges in dark mode.

If you open the light mode, these badges are dark grey with a white
text. If you switch to dark mode, they are dark grey but with a dark
text, which makes them look either muted or off.

We make use of SCSS variables to handle the color of the component,
providing a good styling in both modes.

- Fix kanban cards borders inside dropdown -

Fixes the issue with the divider inside the kanban dropdown menu not
showing in dark mode.

To ensure it is visible, we assign it the `$dropdown-divider-bg`, which
is the color it should use, as the horizontal divider above uses.

- Fix tour pointer design for dark mode -

This commit aims to insert the tour pointer and its content inside the
styling we applied to our tooltip.

To do so, we make sure it uses CSS variables, allowing more control and
consistency, plus we replicate the overall look of our tooltips.

- Fix `text-primary` on action background contrast -

This commit improves the readability of our `text-primary` classes when
it's used on a `$o-component-active-bg` background.

Prior to this commit, the `text-primary` was not meeting the contrast
standard, mainly when you were using the `CMD+K` shortcut on the
app switcher.

To prevent that, we changed the background to a `$o-component-active-bg`
background with an opacity ensuring our text provides a good contrast.

- Fix input states -

Prior to this commit, the `--o-input-border-color` CSS variable was
using the `$o-form-lightsecondary` variable to define the standard color
of the `border-bottom` property of our inputs.

This was conflicting since `$o-form-light-secondary` is also used to
define the `background-color` of our table on focus.

With this commit, we separate these two element with different variables
to make sure they don't affect each others.

- Fix kanban ghost background -

Before this commit, if you created a project without any stage or element
in it, the ghost cards that act like placeholders would be pure `#000` in
dark mode, due to the `bg-white` class.

This commit replaces that class with a `bg-light`, providing a better
visual result in both light and dark mode.

- Fix new message design -

Improve the design of the new message element while
inside Discuss, using our danger color, ensuring a good visual result in
both modes.

task-3201038

closes odoo/odoo#139966

Related: odoo/enterprise#49666
Signed-off-by: Pierre Paridans (app) <app@odoo.com>
Co-authored-by: chgo-odoo <chgo@odoo.com>
Co-authored-by: stefanorigano <sri@odoo.com>
2023-10-28 10:07:53 +00:00
Rahul Prajapati 3b1d10f0f1 [FIX] mail: message author name and image pointer style tests
This commit adapts message tests to check pointer style on message author name
and author image.

closes odoo/odoo#139951

X-original-commit: 134b7cc1143faf9275683ae12c2b121ab03aed7e
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-10-27 13:02:22 +00:00
Alexandre Kühn 38d35c1ac6 [REF] mail: have author in notification formatter
So that `Message.insert()` in JS becomes trivial, as it doesn't have
to infer the author of message to current user.

closes odoo/odoo#139501

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-10-26 13:41:16 +00:00
Alexandre Kühn f97012e0ed [REF] mail: support multi-data insertion in discuss model
Before this commit, when having an array of data to insert
in a model, we had to iterate and insert data item on by one:
```js
messageDataList.forEach(data => this.store.Message.insert(data));
```

With this commit, we can simply insert the array of data to
insert:
```js
this.store.Message.insert(messageDataList);
```

This helps simplifying the business code further, less LOCs is
usually better!

Part-of: odoo/odoo#139501
2023-10-26 13:41:16 +00:00
Alexandre Kühn c0da919697 [REF] mail: discuss model html field and trusted insert
This commit allows to define html fields in discuss models,
so that when insert is trusted they are automatically markup.

By default, all model insert are untrusted. To make a trusted
insertion, we should pass 2nd parameter `{ html: true }` to
an `insert()` method. The param is intentionally named `html`
instead of `trusted`, so that it triggers ci/security for
reviewers awareness.

It's still possible to immediately assign a markup on the html
fields, like before.

This changes simplifies the code, so that we don't have to dissect
model data everytime and make sure all bits are properly markup.
The dissect operation added many LOCs and we frequently missed to
markup the data in some flows. Being able to flag html fields at
model definition and flagging an insert safe keeps the security
concern while helping properly markup-ing all the data.

Part-of: odoo/odoo#139501
2023-10-26 13:41:16 +00:00
Killian Frappart a3bab45dbe [IMP] mail: translate message from chatter
This commit introduces a new optional feature in the chatter.

Users can request translation from the Google Cloud Translation API.
Documentation: <https://cloud.google.com/translate/docs#docs>

Adding the key in settings will instantly enable the feature for all
users of the database and consumption is not measured nor limited
by Odoo as it is natively supported using the Google Cloud Console.

Translation values are stored in the database to reduce cost as
much as possible. Therefore, translation values are automatically
garbage collected every 2 weeks to prevent database pollution.

Task-3338165

closes odoo/odoo#126555

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-10-25 11:37:17 +00:00
zel-odoo 94085079f4 [IMP] mail: notification settings for channel
New fa-bell icon to manage notifications according to that channel only
Options: 
Mute (+choose time period):
​No longer see the unread status: the bold text disappears and the channel name fades out.
As if you are not a channel member anymore.
Receive messages but without sound + only need action counter (grayed).
Add a crossed-out bell icon next to the channel or user name to indicate that the channel is muted
 
All messages: all messages sound + need action counter
@Mentions: only mention sounds + need action counter
Nothing (Discord-like): No sound + need action counter

By default: all messages

task-3328665

closes odoo/odoo#136405

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-10-25 09:56:36 +00:00
Maryam Kia 687295e408 [FIX] mail: attribute with object value isn't rendering properly in owl template
closes odoo/odoo#139576

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-10-24 18:11:29 +00:00
Sébastien Theys d3b5ff1290 [FIX] mail: tests: fix "open the chatWindow of a channel from [...]"
Back-port test with `contains` from `master` and specify text present
on command before clicking it.

runbot-24981

closes odoo/odoo#138087

X-original-commit: ddc9da828ad338678bfa6e3b44461f87683b828f
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-10-24 13:55:11 +00:00
Alexandre Kühn 09592c25fd [REF] mail: replace Partner/Guest to Persona in mail.record/insert
As a step to simplify model insert from python. All data are
formatted in a way to make data insert trivial in JS models.

closes odoo/odoo#138760

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-10-23 20:07:29 +00:00
Alexandre Kühn 3cb14377c7 [REF] mail:tests: more discuss model tests
This helps spot a few bugs in the code.

Part-of: odoo/odoo#138760
2023-10-23 20:07:29 +00:00
Alexandre Kühn 416e05b210 [REF] mail:tests: add/delete on record fields with inverse
Some test coverage on model with inverses, especially on deletion
that are not frequently functionally covered by tests.

To make test coverage on very specific on models and relational
fields with inverses, store service has been refactored so we can
test the store without Persona/Thread/Message models and all related
services and behaviours.

Part-of: odoo/odoo#138760
2023-10-23 20:07:29 +00:00
Alexandre Kühn 9a127407c7 [REF] mail: rename model NotificationGroup to Failure
Name was hard to grasp what it means, when in practice it refers to
showing discuss failures in messaging menu. The "group" part just
refers to a failure being conceptually uniquely defined so that it
sometimes group notifications together as a single failure entry
in the messaging menu.

This rename will help simplifying insert flow with this model.

[REF] mail: slightly simplify Notification.insert()

Format `persona` so it can be immediately inserted in JS model.

[REF] mail: simply Notification/Failure.insert

[REF] mail: introduce computed fields on discuss models

Some models have no concept in server, so the formatted data require
specific handling to make some client-side specific models. This is
notably the case with `Failure` model, which is used to group
failure notifications per model for the specific showing in UI.

In order to simplify update so they consists to simply adding data
from server, these models should be inserted automatically depending
on changes from inserted data. Since these models come from
relational fields that must be computed outside of server data, we
add support to computed fields: such relational fields can have their
value automatically computed based on the state of the current
record.

[REF] mail: remove Record.atomically and Record.onChange

These were added to reactive seeing intermediate state in models,
which were caused by `RecordList.sort()`.

This commit removes them and adapt specifically `RecordList.sort()`
so intermediate states during sort is not exposed in the actual
value of the many field.

Part-of: odoo/odoo#138760
2023-10-23 20:07:29 +00:00
Sébastien Theys c955327c50 [FIX] account_edi, web, mail: add attachment delete in public tour
This allows better coverage of the feature and in particular its access
check.

Follow-up of https://github.com/odoo/odoo/pull/118701

closes odoo/odoo#139359

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-10-20 23:37:46 +00:00
Pierre-Yves Dufays 5f4add917a [IMP] crm, {test_}mail: allows to filter record having "done" activity
To allow to search records having "done" activity (archived) assigned to
someone, we have modified the search method of the field activity_user_id (in
the activity mixin) so that it matches also responsible of archived activities.
This field is mainly used when coming from the systray to display user
activities including "done" ones but could be also used in custom filters.

We have also modified the default domain when fetching record for the activity
view so that it matches records having at least one activity, archived or not.
This prevents to load more records than necessary to display the activity view.

We also adapt the test accordingly.

Task-3300854

Part-of: odoo/odoo#138135
2023-10-19 19:08:12 +00:00
jugj-odoo da28dc6618 [IMP] hr_attendance : Bumping counters in tests
Due to the Systray item add for attendance,
an additional rpc call will be performed for employees,
meaning that different counters have to be bumped.

closes odoo/odoo#135439

Related: odoo/upgrade#5234
Related: odoo/enterprise#47384
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2023-10-19 14:47:18 +00:00
FrancoisGe bb09cf76e3 [REF] *: remove legacy time.js
The purpose of this commit is to delete the legacy/js/core/time.js file.
We have therefore replaced all calls to time.js with the l10N/date.js utilities.

Part of task 3439226

closes odoo/odoo#138609

Related: odoo/enterprise#48918
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-10-18 08:56:06 +00:00
maad-odoo b1c7318482 [IMP] mail: fa-tasks icons as default in activity icons
Before this commit:
There were no default icon set when a new activity type is created.

After this commit:
When user will create a new activity type, 'fa-tasks' will be added as
its default icon.

task-3525592

closes odoo/odoo#136952

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-10-17 10:05:49 +00:00
luvi cc0ca70428 [IMP] mail, web: call the installation prompt from the notification area
The NotificationItem component has been modified to support a new slot
allowing to display some content at the right of the notification item.
It is used in this commit to display an additional 'Install button',
inviting the user to click on the notification. Note that the entire
notification is still clickable, it is only a visual indicator.

Once the notification is clicked, the installation process is triggered:

- In case the system supports the native installation prompt, we now
display it, and the user is free to install the PWA from there.

- On Apple devices, a custom popup is displayed to the user, explaining
the steps to install the website as an application, since iOS and macOS
don't support a native prompt, and won't be using one anytime soon, since
it's a design decision from their side.

Some tests have been added to mock and test the display of the notification.
patchBrowserWithCleanup has been adapted to also remove any BeforeInstallPromptEvent
for every tests by default. This allows to test without the risk of issues with
messaging tests reading the number of notifications, or clicking the first
notification item when the service checks whether the prompt can be shown
or not (depending the availability of a native prompt, the OS, or the
localStorage, etc.).
To test the service correctly, you need to patch the test accordingly.

task-3275275

closes odoo/odoo#135866

Related: odoo/enterprise#48968
Signed-off-by: Pierre Paridans (app) <app@odoo.com>
2023-10-16 10:39:56 +00:00
Alexandre Kühn 631ae1c4d8 [REF] mail: simplify JS discuss models further
- Remove "channel" field in thread formatter.
- Pass `type` for all persona formatters.
- Remove some snake_case to camelCase conversions.
- Add support for inverse fields in discuss JS models.

Details:

1. [REF] mail: remove field 'channel' in thread formatter

This field was used for channel-specific fields, which made
sense when there was a dedicated Channel model that was modeled
with composition with Thread.

To simplify formatter of threads, it's best to flatten props
so that channel-specific fields are immediately available on
thread model. This will improve insertion of data with Threads.

This commit also makes the following other changes:

- remove `discuss.channel/legacy_insert` to use
   `mail.record/insert` instead.

- Introduce `toData()` on record, which is helpful to have record
  in data format e.g. to pass as a JSON.stringifiable object.

2. [REF] mail: slightly simplify Message.insert from notif

The handling of `mail.record/insert` for Message was handling
transition from starred non-empty message to starred empty message.

To simplify all record insert from server formatted data, the notif
data is just inserted in Message. The adjustment of starred counter
is managed at model level.

This is a prerequisite to significantly simplify all
`mail.record/insert` handling.

3. [REF] mail: rename 'res.users.settings' notifications

Before this commit, notifications related to changes of user
settings were using named notification `mail.record/insert`.

This named notification should be only used for Discuss data that
should be inserted in models. `res.users.settings` is not integrated
in Discuss model, thus it has no reason to use this named
notification.

This commit rename the notification name to `res.users.settings` for
these specific notifications. This prepares simplification on
handling any `mail.record/insert` notifications that should simply
call `Record.insert()`

4. [REF] mail: make dedicate notif for Thread/fold_state

This was using named notif "mail.record/insert", which should
be used to immediately insert data in models. This is however
a dedicated notification to imperatively manager chat window
state based on timing of receiving thread data.

This may eventually become a `mail.record/insert` in the future,
but right now it's much simpler to define it as its own named
notification, in preparation to simplify `mail.record/insert`
notifications handling.

5. [REF] mail: remove Channel in mail.record/insert

This is replaced by `Thread`, so that these data can be
immediately inserted in Thread model.

6. [REF] mail: simplify slightly Attachment.update()

Now that data containing commands is supported, we could
just assign with the command rather than destructure and pick
the dict data part.

7. [REF] mail: introduce assignIn() utils

This function helps reduce LOCs from using the "in" conditional
in sequence:
```js
if (a in data) {
	this[a] = data[a];
}
if (b in data) {
	this[b] = data[b];
}
if (c in data) {
	this[c] = data[c];
}
```

To simply:
```js
assignIn(this, data, [a, b, c]);
```

8. [REF] mail: remove snake_case to camelCase conversion in models

They exist for the sake of keeping Python code snake_case and
JS camelCase. While it's good that each language have a community
that prefer syntax convention, when a codebase uses both languages
and they should work with the same data, it's not great to convert
snake_case to camelCase and vice-versa all the time.

Since server has authority over the data, the server chooses the
format for the keys. Most of them are snake_cased, therefore this
is usually the one we pick.

9. [REF] mail: rename Message.messageReactionGroups to Message.reactions

Easier to read, and matches relation name in JS model

10. [REF] mail: remove explicit assign of some many relations in Message

This reduce amount of custom code in insert(), in preparation to make
all models behave the same in response to inserting data.

11. [REF] mail: rename Thread.customName to Thread.channel_custom_name

To match server data field name, and avoid useless conversion in JS.

12. [REF] mail: simplify Message.insert for recipients

Have formatted data contain `type: "partner"` so it can be assigned
in relational field without adding `type: "partner"` manually in JS.

13. [REF] mail: introduce inverse field in discuss models

With this commit, fields in different models can be linked
together, so that one is mirror of the other field.

This simplifies some `onAdd`/`onDelete` that were added to
sync such fields, and this also simplifies insertion in
relational fields for discuss models that are identified
by records, such as the `MessageReactions` that is identified
by the message and the emoji.

14. [REF] mail: rename CannedResponse.name to 'source'

To make JS model and server data more alike.

15. [REF] mail: remove assignDefined in Persona model

So that eventually all model inserts use `Object.assign()`.

16. [REF] mail: remove 'last_message_id' from channel_info

At some point it was used to display last message in messaging menu.
This is already covered by `channel_fetch_preview` when opening the
messaging menu for the 1st time, so passing `last_message_id` in
channel_info is obsolete.

closes odoo/odoo#137750

Related: odoo/enterprise#48484
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
2023-10-13 11:46:13 +00:00
Pierre-Yves Dufays 35d5342887 [IMP] {test_}mail, various: generalize activity plan + activity batch schedule
Generalize the hr.employee activity plan to any model, allowing to create
activity plan that can be launched on any model.

The activity can now be created in batch by selecting multiple record in the
list view and then clicking on a "clock" icon in a row similarly to the batch
records update (selecting multiple records allows to change for example their
name in batch in the list view). We implement also that functionality for the
plan, allowing to launch a plan on multiple records at once.

We also centralize the launching of activity or activity plan through either
the  "Activities" button in the chatter or the "clock" button in the view list.

Scheduling activity is now taken in charge by a wizard that can schedule a
single activity as well as a plan. We add/update tests for checking that the
wizard is launched with the right record selection (on a single record or a
batch) and add tests for checking the wizard itself.

The plan can be defined through an added menu in the technical admin menu but
also through configuration menu added in the module crm, project.

Technical notes:
In the added wizard, to determine that there is a error, we introduce the
has_error field because we cannot use easily the error field for that. Indeed,
to determine that there is no error, we have to compare it to "<p><br></p>"
(more precisely &lt;p&gt;&lt;br&gt;&lt;/p&gt;) which is not handy and may
change in the future. This is because when we write False on field error and
read it after, we get "<p><br></p>". Instead, we centralize this weird
comparison in the model in the compute method of has_error.

The ActivityListPopover still displays the activity of the record on which it
has been triggered but the button to schedule activity will launch a wizard
that create activities in batch for the selected records if more than one was
selected. For that, the ActivityListPopover component receives now an
additional prop: resIds (selected records) on top of the resId prop (record on
which the popup has been triggered). Note that when the line that trigger the
popup is not selected, the batch mode is disabled to avoid confusion.

Test are updated because the wizard is opened instead of the activity form to
schedule a new activity and as the form view is only used to edit already
existing activities, default_res_id and default_res_model are no longer passed.

We defines date_deadline and date_plan_deadline in the schedule wizard because
those date are managed differently (default value, required or not, ...).

Task-3390865

Part-of: odoo/odoo#137969
2023-10-12 16:12:09 +00:00
Romeo Fragomeli 8699142f65 [IMP] mail: remove legacy code in patch_ui_size
As the comment says:
> This function must be removed when the WOWL env will be available in
> the form_renderer.

This code seems not needed anymore.

closes odoo/odoo#135273

Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2023-10-10 11:07:47 +00:00
Louis Wicket (wil) a9ca779a1f [IMP] mail: voip refactoring
Adds useful fields to models needed for VoIP to work.

closes odoo/odoo#115689

Related: odoo/enterprise#38339
Related: odoo/upgrade#5021
Signed-off-by: Louis Wicket (wil) <wil@odoo.com>
2023-10-10 01:59:33 +00:00
Didier (did) fd68c7d343 [FIX] mail: allow empty message edition
Before this PR, it was not possible to edit a message that has an empty body.

Task-3387170

closes odoo/odoo#137996

Signed-off-by: Didier Debondt (did) <did@odoo.com>
2023-10-09 20:31:50 +00:00
Didier (did) fa64a23f1c [FIX] mail: load gif category properly
Before this PR the showFavorite status was not properly updated after clicking
on "back".
This cause the categories to use the favorite route when scrolling instead of
the category route.

Task-3504566

closes odoo/odoo#136932

Signed-off-by: Didier Debondt (did) <did@odoo.com>
2023-10-09 13:25:29 +00:00
Thibault Delavallée 0c1f83a6a1 [MOV] (test_)mail: reorganize tests and tours
Purpose is notably to regroup some tests into a single file (notably tours
in their matching unit tests file), rename some tests / tours, ... and
globally try to lessen test file split.

Task-3535845 (TestMail: Reorder tests tours / files)
Prepares Task-3527752 (Mail: The Pre-Major Freeze FixImpLint)

Part-of: odoo/odoo#137895
2023-10-09 10:48:48 +00:00
tsm-odoo a97abef2d2 [IMP] im_livechat, mail: allow livechat visitors to upload attachments
Since [1], live chat visitors are using the mail guest system for
authentication. With this change, visitors are allowed to reach the
attachment upload routes (even if nothing allows it in the frontend
for now). This commit restricts attachment upload for guest and portal
users with the `allow_visitor_upload` field that can be toggled.

At the same time, this commit enables file upload when authorized
on the frontend and for cross origin live chats.

[1]: odoo#129770

task-3332628

closes odoo/odoo#137574

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-10-06 18:18:29 +00:00
Didier (did) f1abc4e4f3 [FIX] mail: selfFollower should be included in the followers
Before this PR, the current user was not considered has a follower, regarding
the mention suggestions.
This lead him to be lower than other entries.
This PR fix the issue by adding him back to the follower list.

Task-3531111

closes odoo/odoo#137583

X-original-commit: 50a785fedc5b5c7fd826548e52385bdf458c97a2
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Signed-off-by: Didier Debondt (did) <did@odoo.com>
2023-10-06 06:14:04 +00:00
Thibault Delavallée e147d35590 [REF] mail: rename 'field' to 'field_id' on tracking value
PURPOSE

Simplify 'mail.tracking.value' model and code. Remove unnecessary fields and
computation. Make code easier to handle and more batch-enabled.

SPECIFICATIONS

Rename 'field' to 'field_id' on tracking model. It better indicates it is a
many2one and not a char field holding a field name for example.

Task-3345979 (Mail: Simplify tracking model)

Part-of: odoo/odoo#124182
2023-10-06 06:13:55 +00:00
Thibault Delavallée b2d7f03398 [REF] mail: remove 'monetary' values from tracking value, use float
PURPOSE

Simplify 'mail.tracking.value' model and code. Remove unnecessary fields and
computation. Make code easier to handle and more batch-enabled.

SPECIFICATIONS

Remove 'old_value_monetary' and 'new_value_monetary' fields on tracking model.
Float fields can be used instead as anyway what is important is the type
of value stored, not their actual purpose.

Task-3345979 (Mail: Simplify tracking model)

Part-of: odoo/odoo#124182
2023-10-06 06:13:55 +00:00
Thibault Delavallée 6aa0a25df7 [REF] mail: remove 'field_{desc/type}' from tracking value
PURPOSE

Simplify 'mail.tracking.value' model and code. Remove unnecessary fields and
computation. Make code easier to handle and more batch-enabled.

SPECIFICATIONS

Remove 'field_desc' and 'field_type' from 'mail.tracking.value' model. Those
can be retrieved when necessary, as it is mainly used for frontend display
in Chatter.

Task-3345979 (Mail: Simplify tracking model)

Part-of: odoo/odoo#124182
2023-10-06 06:13:55 +00:00
Thibault Delavallée 11289fd128 [REF] mail: cleanup 'mail.tracking.value' model code
PURPOSE

Simplify 'mail.tracking.value' model and code. Remove unnecessary fields and
computation. Make code easier to handle and more batch-enabled.

SPECIFICATIONS

SPEC 1: prepare all tracking values at same code place

Delegate all computation of tracking values into the 'create_tracking_values'
method. Curently part of it (currency field) is done in the caller. Better
split code per feature.

Method is also made private, as it is not required to expose it.

SPEC 2: cleanup tracking value formatting methods and calls

Code used to display tracking value can be simplified: remove unnecessary
wrappers, make code easier to read, avoid composition of field name but
use a mapping instead (easier to grep 'old_value_char' when it is effectively
used).

Ensure code always calls '_tracking_value_format' to ease future improvements
and have all formatting code being batch-enabled.

SPEC 3: simplify Chatter formatted value structure

'fieldType' is currently added in old and new values. As it is a field
property it can be moved higher in the formatting result to be included
only once. Also add 'fieldName', the column name, to the formatted results
as it will soon help various tool methods. Moreover it makes sense to have
the source of the tracking as the real column name, in addition to its
string and type.

Task-3345979 (Mail: Simplify tracking model)

Part-of: odoo/odoo#124182
2023-10-06 06:13:54 +00:00
Zelong Lin 69fe16d42d [IMP] mail: make mentions in chatter full composer
Before this commit, it was not possible to send messages in
full composer containing user mentions. Even whe the mentions were
added in the small composer and then continuing composing the message
in the full composer.

With this commit, we can now make user and channel mentions in the
full composer, by typing `@` and `#` like in the small composer of
Discuss.

When composing a message in small composer and then switching to full
composer, the mentions are preserved.

task-3470060

closes odoo/odoo#132701

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-10-05 16:49:04 +00:00
Didier (did) e3d68312fa [IMP] mail: improve escape key usage in discuss app
This PR introduce multiple usage of the escape key:

- Channel selector can now be closed using the escape key
- Using the escape key will focus the composer automatically

Task-3456518

closes odoo/odoo#135031

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-10-05 13:37:50 +00:00