Commit Graph
11671 Commits
Author SHA1 Message Date
ramh 83594c6fde [FIX] mail: wrap long user names on direct messaging search
Before commit:

Long user names in direct messaging search are not wrapped, leading to
UI display issues.

After commit:

Resolved the issue where long user names were not properly wrapped in direct
messaging search. Now, when a user name exceeds the allotted space, it is
 truncated.

Task-3748791

closes odoo/odoo#160141

X-original-commit: eaf0e073ef8689629541de33e9bcf167f0e6b8e8
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2024-04-02 17:04:49 +00:00
Odoo Translation Bot 684745f5de [I18N] Update translation terms from Transifex 2024-03-31 00:09:16 +01:00
Levi Siuzdak (sile) dffc575725 [FIX] mail: prioritize partners with matching company in email lookup
Versions
--------
- 16.0+

Steps
-----
1. Have two companies with helpdesk teams;
2. create a contact associated with company 1;
3. create a contact associated with company 2 w/ the same email address;
4. from this address, send an email to team 2 to create a ticket.

Issue
-----
Ticket is created using company 1's contact.

Cause
-----
When searching for partners associated with an email address, it only
looks at the first one.

Solution
--------
Expanding on e1d50a404516d5b32bf01508423c5a1c880cb304 which prioritized
the current user, further prioritize based on companies matching the
records passed to `_mail_find_partner_from_email`, avoiding potential
access rights errors in multi-company environments.

Also fixes a bug in account_move where `_mail_find_partner_from_email`
was called with an `extra_domain` argument in the wrong position.

opw-3705199

closes odoo/odoo#159108

X-original-commit: 60dd5348179c9bdcc78e4ad46bd9b768a6e3ea21
Signed-off-by: Levi Siuzdak <sile@odoo.com>
2024-03-29 10:44:18 +00:00
TSO 6f12d0ad42 [FIX] discuss: fix slider values in call settings
* Adds text values for the call settings sliders.
* Replaces `onChange` events with `onInput` events so that the values
 respect the position of the sliders.
* Debounces some functions to handle the increased amount of calls
due to the swap to the `onInput` listener.
* Changes the default value of `voiceActiveDuration` from `0` to `200`
to match the minimum value of the input.

closes odoo/odoo#151028

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2024-03-28 12:19:04 +00:00
Achraf bb2e76ee12 [FIX] mail: Allow users to edit log notes in mobile
Example of steps:
	- Open any record with a chatter
	- Log a note
	- Edit it
	- Try to save

Actually it is impossible to save it, because we can not
perform a CTRL+ENTER in mobile and there is no button

This commit adds a button to save editing, using `fa-paper-plane`
icon similarly to send button.

opw-3784145

closes odoo/odoo#159092

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2024-03-26 13:35:55 +00:00
Alexandre Kühn 0aae1ae147 [FIX] mail: opening chat with deleted new message should mark as read
Before this commit, when a user of in chat posted a message and
deleted it, all other users kept the chat as unread.

Steps to reproduce:
- Connect as Admin and March Demo
- Send a message to Admin as Demo in DM chat
- Demo deletes this message
- Marc opens the chat
=> the unread counter is 1 and cannot be removed

This happens because when a message is deleted, there's still a
trace of it but the message is empty. However, empty messages could
not be candidate of setting the last message being seing by a member,
thus members were unable to mark the chat as read until someone else
posted a newer message (and did not delete it).

This commit fixes the issue by taking empty messages into account for
setting last message message of member, which allow to mark thread as
read even when newer messages have been deleted.

opw-3764410

closes odoo/odoo#158943

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2024-03-25 11:43:40 +00:00
Odoo Translation Bot 395140671f [I18N] Update translation terms from Transifex 2024-03-24 00:12:07 +01:00
Antoine (ande) 070761e31d [FIX] mail: wrong image in push notifications
Steps to reproduce:
1. Install hr_holidays
2. Connect as Admin
3. Go to the profile
4. Check Handle in Odoo in Notification
5. In a private browser, connect as Demo
6. Go to Time Off
7. Take a day off
8. A push notification for Admin pops-up
9. The profile picture is wrong

Cause of the issue:
author_id is linked to res.partner not res.users

Fix:
Backport of: https://github.com/odoo/odoo/commit/1244c9c02d6242d34a37aa27168229e9d3939cb4

opw-3684987

closes odoo/odoo#155107

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2024-03-21 19:54:30 +00:00
tsm-odoo 9a37126ad2 [FIX] mail: ptt extension race condition
The push-to-talk extension service sends a message to the extension
when starting to check if it is enabled. If the response is received
before the RTC service is started, the answer is ignored, and the
service acts as if the extension were not available. This PR fixes
this issue.

closes odoo/odoo#158252

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2024-03-20 18:29:22 +00:00
duongnguyen-viindoo c3fe38362c [FIX] mail: user_id field of model might not have type many2one
-Step to reproduce: any custom model that inherit from mail.thread then
define a field user_id but with type is char and boom error happen at
method '_message_get_suggested_recipients' because it always expect
'user_id' to be a many2one field

closes odoo/odoo#157942

-solution: need to check the type of 'user_id' also
X-original-commit: 4aaab353da1c1ddde63f2aa1232394c0b4dd6f68
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2024-03-17 00:35:02 +00:00
Odoo Translation Bot c4bc200b47 [I18N] Update translation terms from Transifex 2024-03-17 00:11:43 +01:00
zel-odoo a6746497d7 [FIX] mail: do not display false if missing email
'false' is displayed in the popover next to the recipients in the absence of an email address as well as the title of the recipients

If the partner has no email, it should show something like "[name] (no email address)]"

test added

task-3787703

closes odoo/odoo#157850

X-original-commit: 40a2df25301daaf24c123e0b67bff408eb8cd897
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Signed-off-by: Zelong Lin (zel) <zel@odoo.com>
2024-03-15 18:42:46 +00:00
Hubert Van De Walle 43c0f6ea11 [FIX] mail: reload attachments after upload from dropzone
Steps to reproduce
==================

- Go to Accounting > Customer Invoices
- Open any record with no attachments
- Drag & drop a pdf attachment on the chatter

=> The PDF viewer is empty

Cause of the issue
==================

When uploading an attachment from the FileUploader, the parent view is
reloaded.

This is not the case when uploading an attachment from the dropzone.

opw-3748853

closes odoo/odoo#157232

Signed-off-by: Hubert Van De Walle <huvw@odoo.com>
2024-03-15 17:29:50 +00:00
Martin Trigaux (mat) d0cd86bd14 [FIX] mail: harmonize computed field
Avoid accessing inconsistent data based on the user

closes odoo/odoo#157098

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2024-03-12 10:34:49 +00:00
aath-odoo 37507fbfc2 [FIX] various: domain picker rtl mode
Before this commit:
Switching to RTL mode would inadvertently revert the domain picker,
causing a disruption in the email format. The expected format is Alias@domain,
but it was displaying as domain@alias.

After this commit:
Now, the domain picker remains intact in RTL mode, ensuring that
the email format is correctly displayed as alias@domain.

Task-3624012

closes odoo/odoo#157091

X-original-commit: 26f67d4b4c5dbddd6d543949c4c6071e53c53515
Related: odoo/enterprise#58364
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2024-03-12 10:34:47 +00:00
Odoo Translation Bot 1b9fd01d46 [I18N] Update translation terms from Transifex 2024-03-10 00:13:03 +01:00
Thibault Delavallée 50f5bc4a9b [IMP] mail: migrate alias ICP at install if they exist
When adding alias domain in v17 support of configuration parameter
was dropped. We moved from singleton configuration to multi domains
using real models.

This means most of mail support lies in mail while part of it was in base
beforehand. In some cases we want to let people do some basic
configuration using base module then install mail which could migrate
this ICP based configuration into new models. This is notably the case
with odoo.sh where mail is not always automatically installed.

Use case is: install base, do some configuration using ICP allowing notably
to setup website / server domains, main mail configuration, ... then let
people install modules on top of that configuration which generally
installs mail. With this change existing ir.config_parameters matching
pre v17 names are now used to bootstrap alias domain table at mail module
initialization.

Task-3789584

closes odoo/odoo#156654

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2024-03-07 11:40:23 +00:00
Alvaro Fuentes 084d2bcd46 [FIX] mail: correctly compute groups on trackings, depending on model
Side effect due to a combination of odoo/odoo#124182 making field_id not
required to keep trackings when removing fields, and odoo/odoo@9c9552fd20
where field is used to find model when computing groups instead of message
in case the tracking is logged on a model different from the field model
e.g. accounting.

Steps to reproduce:
1. Install project_enterprise in saas-16.4
2. Create a task and update some values for Date deadline
3. Upgrade to 17.0
4. Try to open the task in the upgraded DB.

We get an error:
```
ValueError('All tracking value should belong to the same model.')
```

The reason is that `date_deadline` field is removed during the upgrade
and thus `fields_models` is empty in
https://github.com/odoo/odoo/blob/0649134444fa6b26de1c8c25d7c4a3f70c6d64e0/addons/mail/models/mail_tracking_value.py#L120-L121

closes odoo/odoo#156571

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2024-03-05 19:21:39 +00:00
Alvaro Fuentes 0db60bf1c2 [FIX] mail: fix tracking formatting when having several models
In odoo/odoo@9c9552fd20 a support of tracking value belonging to another model
than the message has been added. In such cases the formatting method written
at odoo/odoo#124182 fails as it expects a single model for all tracking values
it receives. When field is removed 'model' is False, and we fallback on
mail_message model.

Part-of: odoo/odoo#156571
2024-03-05 19:21:39 +00:00
zel-odoo b1d403c4b4 [FIX] mail: avoid sending notif when not needed
When there is no channel members to be updated the seen status, we
should not send a notification to the channel members, otherwise it
will lead into creating a channel member with id undefined.

test case added to check that the notification is not sent when there
is no channel members to be updated.

closes odoo/odoo#156534

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2024-03-05 19:21:38 +00:00
Victor Piryns (pivi) 967e0f7982 [PERF] mail: add missing index on alias_full_name
Description:
Since https://github.com/odoo/odoo/pull/76734, the new field
`alias_full_name` is used in addition to `alias_name` to search on
`mail.alias` and route emails in `message_route`. It's also used as
a search criteria in `_search_alias_email` on `mail.alias.mixin.
optional`. The issue is that the table `mail.alias` can grow quite
large, and only the old field `alias_name` has an index on it, which
may not be selective enough, forcing Seq.Scans on the table with
possibly millions of records. The impact is noticeable on
`message_route` which is a hot path for processing incoming emails.

Adding an index on `alias_full_name` allows PostgreSQL to do an
bitmap OR scan on the two indexes, considerably speeding up search
criteria that are a disjunction between `alias_name` and
`alias_full_name`.

Benchmark:
For domain
```python
[
    '&',
    ('alias_model_id', '!=', reply_model_id),
    '|',
    ('alias_full_name', 'in', email_to_list),
    '&', ('alias_name', 'in', email_to_localparts), ('alias_incoming_local', '=', True),
]
```
with test arguments, on a `mail.alias` table containing over 2M records.

|           | Before | After |
|-----------|--------|-------|
| Timing    | 696ms  | 1ms   |
| Buffer IO | 790MB  | 48KB  |

Specially impactful as those gains needs to be multiplied by the
frequency of the searches.

Reference:
task-3724844

closes odoo/odoo#156237

Signed-off-by: Olivier Dony (odo) <odo@odoo.com>
2024-03-05 16:48:17 +00:00
Renaud Thiry 00ebf747af [FIX] mail: add selection when fetching message type
A new message type was added in stable. This is usually safe,
however in cases where there are related fields on that same selection
fetching them will raise an exception as the ORM has to fetch the translations
for the selection in DB.

We add a hack on mail.mail to update the selections in DB when fetching
the message_type field for the first time.

task-3773301

closes odoo/odoo#156235

X-original-commit: 19683173708a2b029acb4e744871772b6c248715
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Renaud Thiry (reth) <reth@odoo.com>
2024-03-05 14:22:19 +00:00
Antoine (ande) f33ead720c [FIX] mail: templates preview wrong recipients
Steps to reproduce:
1. Activate dev mode
2. Go to Email Templates
3. Create a new template
4. Applies to Task
5. Email Configuration > To (Partners)
6. {{[p.id for p in object.message_partner_ids]}}
7. Click on Preview
8. Select a record with followers
9. Look at Recipients
10. => No or not all followers/partners are included

Cause of the issue:
Caused by https://github.com/odoo/odoo/commit/cf7ae6b9d562622709e2730c1ea8c43816c169bf
In the case of partner_to being '[2,3,4]'
Split would output '[2', '3', '4]'
So after the isdigit it would be '3'
It should have been 2, 3, 4

opw-3677069

closes odoo/odoo#156307

X-original-commit: d2e473f5b2b1b0fa1eae0f2a1e3698d663af07d8
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2024-03-04 17:02:45 +00:00
Renaud Thiry 16102407f3 [FIX] mail: let auto_subscribe use up-to-date values
`_message_auto_subscribe` relies on `_get_subscription_data` to know who
is subscribed to what. This method uses a raw SQL query but doesn't flush
the relevant records beforehand.

This is not an issue in most normal cases, but if followers are edited manually
for example in order to merge existing records. It may cause issues when
assigning a user to the record after merging, as the this will attempt to add
them to the list of followers automatically, when they already were on it.

task-3713472
original issue in opw-3634410

closes odoo/odoo#155139

X-original-commit: d1b0e46f7d3034c400ba3c60f343c21c68aa011e
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Renaud Thiry (reth) <reth@odoo.com>
2024-03-04 08:11:55 +00:00
Odoo Translation Bot cb45934163 [I18N] Update translation terms from Transifex 2024-03-03 00:09:56 +01:00
Maryam Kia 7821879472 [FIX] mail: click on dropdown after changing the activity type on tour
Since PR #152893, `mail_activity_schedule_from_chatter` test was failing on some
runbot builds. The problem is, the `timeout` to make sure the activity
type input is ready (has its data) to click again, is not enough for all builds.

Instead of using timeout (which is not same for different builds), we can add an
 extra step to check if the activity id input has its data after clicking on
 dropdown, to proceed to the next steps.

fixes runbot-57738

closes odoo/odoo#156030

Signed-off-by: Maryam Kia (maki) <maki@odoo.com>
2024-03-01 12:10:32 +00:00
TSO 820852cecf [FIX] mail: prevent race conditions when a channel is removed in a call
Before this commit, there could be race conditions in which a channel
could be removed while the call was still loading, this commit prevents
this issue.

task-3660964

closes odoo/odoo#149034

Signed-off-by: Thanh Son Dodeur (tso) <tso@odoo.com>
2024-03-01 10:29:36 +00:00
Sébastien Theys 0a2bbd7b86 [FIX] mail: tests: fix race condition in call test
Not a guaranteed fix (not reproducible 1500 attempts), but applying
standard fix for `step` failing to use the new step helper.

runbot-54560

closes odoo/odoo#155925

Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
2024-02-29 17:43:08 +00:00
Pierre-Yves Dufays b09ccfc2d7 [FIX] {test_}mail: fix invalid kanban status when using activity done
How to reproduce:
- Install CRM with demo data
- Configure one activity type to keep done activities
- Go to CRM and chose a kanban column with a green status (only planned
activities for that state)
- On a lead of that column, add an activity of the type chosen above with a
deadline in the past
- When going back to the kanban view, that column has the overdue status (red)
- Mark that activity as done
- Reload the kanban view

The kanban column has still the status overdue (red) while there are no more
overdue activity in that state.

With this fix, after reloading the kanban view, the header displays the correct
status summary. In the example above, the kanban column header is green.

While adding test, we have noticed that the 2 methods _read_group_groupby and
_search_activity_state were computing the activity state differently leading to
inconsistency. Actually, the newly added test was failing because the
read_group was returning 2 overdue records while only one was. We correct this
here as well by using the same computation in the 2 methods.

Technical note: archived activities were returned when grouping by
activity_state because that part was done in SQL and not taking into account
the recently added active field. While adding it in the "_read_group_groupby"
method, we also add it in "_search_activity_state" to avoid the same problem
when searching on activity_state.

Task-3732333

closes odoo/odoo#153274

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2024-02-29 16:00:28 +00:00
Khushi da287cc2f7 [FIX] mail: activity view model domain
Steps to reproduce:

- Go to activity view.
- Schedule an activity for one record. (Say 8 records are available)
- Schedule an activity for the second time. (Again 8 records are available)
- Try to schedule an activity for the 3rd time. (Only 2 records are available)

Issue:
Since 7682286, the existing props of activity model are being passed as params
while scheduling an activity. Currently, `["activity_ids", "!=", false]` is
being pushed to the domain of activity model in order to display only those
records on which activities have been set. As a result, after you schedule
activities more than once, `["activity_ids", "!=", false]` domain gets applied
and the list of records available for scheduling activity is restricted from
the third time onwards.

Fix:
This commit passes the props from searchModel as params to the 'load' method
while scheduling activity, instead of existing props, to ensure that the
existing params are applied as well as all records are accessible for
scheduling an activity, in `searchCreateDialog`
(i.e.["activity_ids", "!=", false] condition is not added as domain).

Task : 3721750

closes odoo/odoo#155700

X-original-commit: 339df084567206cff8a5487bbe9dec249671244a
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Khushi Patel (khpa) <khpa@odoo.com>
2024-02-29 10:34:23 +00:00
Yolann Sabaux 9c9552fd20 [FIX] account, mail: allow account custom sub model tracking
Steps to reproduce:
- Create an invoice and confirm it
- reset to draft
- change the account of an aml (product sales -> asset)
-> on the log note you will see the detail of the modification `Account: 400000 Product Sales -> 101000 Current Assets`
- connect with Demo
- go on the same invoice

Issue:
You will not see the details of the aml account change

This is problematic since Accountant and auditors should be able to see it.

Cause:
Sub-model tracking is not supported. Although we override this constraint in accounting (refer to https://github.com/odoo/odoo/blob/f56de22f10d09e6e34b25cbff04bbb6bf0823e54/addons/account/models/account_move.py#L5058-L5071), it remains inaccessible for users other than base.system. This is because we attempt to locate the account_id field on the model account.move defined in tracking.mail_message_id.

opw-3632295

closes odoo/odoo#155034

X-original-commit: 20f00a73cb280fd9a3636122c4a8a316abcee0d0
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Yolann Sabaux (yosa) <yosa@odoo.com>
2024-02-29 10:34:18 +00:00
tsm-odoo 440e6a5b86 [FIX] mail: fix non deterministic bus subscription test
Before this PR, the `bus subscription is refreshed when channel is
left` test was sometimes failing. This actually reveals a real issue:
if a channel is joined a leave very quickly, the bus subscription is
not updated.

This occurs because we rely on the last subscription made and the one
that should be made to detect if channels differ. Since the
`updateBusSubscription` method is debounced, we can miss information.

This PR replaces the complicated `updateBusSubscription` method by a
`onAdd/onDelete`. This is much more reliable and more efficient since
there is no need to walk through every channel to detect changes.

This PR also remove a test that was redundant that the failing one.

fixes runbot-55292,57645,56232

closes odoo/odoo#155720

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2024-02-28 19:49:13 +00:00
Pierre-Yves Dufays 821156ce90 [FIX] {test_}mail: remove activity assignation check
How to reproduce:
- Install hr with demo data
- Create a user without access to hr and turn it into an employee
- Create a user for Abigail
- Assign Abigail as manager of the new user
- Click on "onboarding plan" in the chatter of the new user
- Then in the dialog, click on "Schedule" button

You get the error "Assigned user test has no access to the document and is not
able to handle this activity." because the new user has no access to the record
employee on which those activities are scheduled.

As activities for which the user has no access to the underlying record are now
displayed in the systray (with no access to the record), we remove the check
that prevent assigning an activity to a user on a record he has no access to.

Technical note: before odoo/odoo#149965, activities scheduled manually were
created with the flag "automated" set to True and when this flag is set the
check that ensures that the user has access to the record is skipped. With
odoo/odoo#149965, as the "automated" flag is set to False when scheduling
activities manually, an error is trigerred if the user has no access to the
underlying record. Here we always skip that test and mark the method as
deprecated because the user can see the activity no matter the access he has on
the underlying record.

Task-3598836

closes odoo/odoo#155576

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2024-02-28 19:49:07 +00:00
zel-odoo aa87b65dc8 [FIX] mail: thread search works for all channels
1. channel mention should work for channels, chats, and groups, even if
there is a group restriction for the channel.
2. channel mention in livechat is disabled because the visitor can't get
access to the channel.
3. remove the fetch and search for channel mentions in livechat so that
there is no extra rpc call for unuseful data.
4. add a test for the channel mention in thread.

closes odoo/odoo#155380

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2024-02-27 17:40:52 +00:00
Rahul Prajapati 96debc0764 [FIX] mail: squashed transient message has date
Before this commit:

Squashed transient messages had date displayed in the sidebar of the message.
This was introduced by this commit: 631ae1c

After this commit:

Squashed transient messages would not have date in the message sidebar.

closes odoo/odoo#154594

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2024-02-27 14:41:45 +00:00
Thibault Delavallée 7c6d5394fb [FIX] mail: improve alias domain usability
Ease understanding the purpose of main fields on alias domains. Set bounce,
catchall and default_from available in debug mode as those are advanced
configuration bits that should be displayed (and modified) with care.
Add tooltips on fields to ease understanding the field usage.

Task-3696224

closes odoo/odoo#150401

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2024-02-26 11:41:54 +00:00
Odoo Translation Bot 4f4ca50e8d [I18N] Update translation terms from Transifex 2024-02-25 00:13:04 +01:00
tsm-odoo 60dc936be1 [FIX] mail: fix missing identifying field in record insert
When a message is posted, the server sends a `mail.record/insert`
notification to update the related channel pin state. In order to
recognize the thread, the client needs its id and its model.
Currently, only the id is passed so the thread pin state is not
updated. This PR adds the model to the notification.

closes odoo/odoo#155150

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2024-02-23 16:43:33 +00:00
Sébastien Theys 6ac4cd7d7b [FIX] mail: cache access to newestPersistentNotEmptyOfAllMessage
Store in variable in sort instead of accessing many times (less proxy
get).

closes odoo/odoo#155068

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2024-02-23 15:13:53 +00:00
Sébastien Theys 93078feeab [FIX] mail: cache access to message_unread_counter
Store in variable in sort instead of accessing twice (less proxy get)

Part-of: odoo/odoo#155068
2024-02-23 15:13:53 +00:00
Sébastien Theys 551e98e9c3 [FIX] mail: cache access to needactionMessages.length
Store in variable in sort instead of accessing twice (less proxy get)

Part-of: odoo/odoo#155068
2024-02-23 15:13:53 +00:00
Sébastien Theys 0681c5b779 [FIX] mail: cache thread isCorrespondentOdooBot
This value is accessed often during sort of messaging menu, so it's
better to not compute it each time on the fly.

- make it a compute
- access correspondent2 to avoid extra indirection
- store in variable in sort instead of accessing twice (less proxy get)

The performance impact is more visible for subsequent sorting, as the
first one benefits less from the cache (when it still has to be built).

Part-of: odoo/odoo#155068
2024-02-23 15:13:53 +00:00
Sébastien Theys 805713d4b7 [FIX] mail: cache the compute of newestPersistentNotEmptyOfAllMessage
This is a complex compute that is better not done every time we need its
value.

Part-of: odoo/odoo#155068
2024-02-23 15:13:53 +00:00
Sébastien Theys b903eb531f [FIX] mail: cache the compute of message datetime
Avoid doing this process every time the datetime is accessed.

It looks like it is already cached with `_datetime`, but it's not
efficient because there are still many proxy get access (which are
costly).

3 proxy access before: getter itself, reading _datetime twice
1 proxy access after: the field itself

Part-of: odoo/odoo#155068
2024-02-23 15:13:53 +00:00
Rémy Voet (ryv) bb7f0c86ae [FIX] mail: avoid unbatched read of activity's deadline
__getitem__() of BaseModel, reset the prefetch set of the recordset.
Fix _compute_activity_date_deadline, to batched the reading of
activity's deadline.

closes odoo/odoo#154860

X-original-commit: ef7226aaa2f0ad135133fe27bdf1414b7ebf2a92
Signed-off-by: Rémy Voet (ryv) <ryv@odoo.com>
2024-02-23 13:09:57 +00:00
Sébastien Theys 786112af3d [FIX] mail: fix performance of channel is_member search
Part 1: _search_is_member
-------------------------

Separate query to fetch candidate channels because the sub-select that
`_search` would generate leads psql query plan to take bad decisions.
When candidate ids are explicitly given it doesn't need to make
(incorrect) guess, at the cost of one extra but fast query.

It is expected to return hundreds of channels, a thousand at most, which
is acceptable.

A "join" would be ideal, but the ORM is currently not able to generate
it from the domain.

`sudo` is added as well because the rules for the member don't need to
be checked as no information is leaked.

Part 2: clean rules
-------------------

The rule for reading "self" is included in the rule for reading other
members. It can be disabled for "read" to avoid duplicate.
It also checked is_member again, but is_self necessarily implies it.

Part 3: clean tests
-------------------

The opportunity is taken to fix the tests. The tests where considering
as "access error" when there was an assert error inside the test (for
example not finding the channel or the member), but those needed to be
considered as failure regardless of expected outcome of access check.
Extra mute loggers are added to clean the test output.

closes odoo/odoo#153697

Signed-off-by: Olivier Dony (odo) <odo@odoo.com>
2024-02-22 17:46:52 +00:00
tsm-odoo 49fa5c1f3e [IMP] im_livechat, *: show live chat channels as sidebar categories
*: mail.

This PR removes the live chat sidebar category. From now on, each
channel will have its own category. This is a first step towards
providing an efficient way for operators to join/leave a live chat
channel.

part of task-3640730

closes odoo/odoo#154755

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2024-02-22 16:23:59 +00:00
Sébastien Theys df8484e833 [FIX] mail: fix performance issue with im status tracking
Move compute of `imStatusTrackedPersonas` to its inverse field. Doing
the compute on the "One" side of the relation prevents from looping and
computing all values whenever there is a change in any of them.

In practice, this reduces the "compute" time of the message fetch (which
also fetch persona as authors of messages), reducing by approximately
half the time it takes to insert these messages (depending on the number
of persona it had to loop through).

For example from 60ms to 30ms on my machine for message insert in
"partner_1_125" (populate medium).

closes odoo/odoo#154918

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2024-02-21 17:27:50 +00:00
Zelong Lin 1ae849a7e2 [FIX] Activities: "Cancel" hotkey conflicts
Since 17.0, the `Cancel` button in the `mail_activity_schedule_view_form` uses the hotkey `z`, which conflicts with the other button.

Change the hotkey into `x`.

closes odoo/odoo#154727

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2024-02-20 14:57:33 +00:00
Zelong Lin aed6e24e8d [FIX] Activities: add "Cancel" button when launching an activity plan
Restore the "Cancel" button when selecting a plan from the activity wizard.
When we introduced the plan feature in v17, the "Cancel" button was forgotten. The only way for users to cancel the action is to click on the "X" button at the top right. 

task-3754897

closes odoo/odoo#154678

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2024-02-20 14:57:28 +00:00