Commit Graph
11381 Commits
Author SHA1 Message Date
Thibault Delavallée 5cd49fc0f8 [IMP] mail: allow to change 'alias_domain_id' in alias mixin
PURPOSE

Allow alias domains to be multiple, notably to be used in a multi company
environment where each company has its own alias domain.

SPECIFICATIONS

As 'alias_domain' is now dynamic and not based on a configuration parameter
it makes sense to be able to change it when having several alias domain.
We now allow writing on 'alias_domain_id' in 'mail.alias.mixin(.optional)'.
Users may now change the alias domain of the alias coming with the mixin
when they have write access on the record.

Task-36879 (Mail: Support Multi Domains Aliases)

Part-of: odoo/odoo#76734
2023-10-24 19:24:50 +00:00
Thibault Delavallée e8a41762ad [IMP] mail: link 'mail.alias_domain' to aliases
PURPOSE

Allow alias domains to be multiple, notably to be used in a multi company
environment where each company has its own alias domain.

SPECIFICATIONS

Add 'mail.alias.domain' information on alias model. Aliases do not use global
configuration parameters anymore. Instead they are linked to an alias domain
e.g. 'sales' linked to 'mycompany.com' alias domain: 'sales@mycompany.com'.

It is now considered as a different alias compared to 'sales@mycompany.in'
which has the same alias_name but a different alias domain.

Constraints and checks are added, as

  * uniqueness of aliases is now checked inside a given domain;
  * an alias name must not clash with its domain bounce or catchall;
  * a combination of (alias_name, alias_domain_id) must be unique;

Crm multi-company environment is also updated to match the new alias domain
behavior.

Task-36879 (Mail: Support Multi Domains Aliases)

Part-of: odoo/odoo#76734
2023-10-24 19:24:50 +00:00
Thibault Delavallée 1b16757d28 [IMP] mail: add 'mail.alias.domain' model to store alias domains
PURPOSE

Allow alias domains to be multiple, notably to be used in a multi company
environment where each company has its own alias domain.

SPECIFICATIONS

Add a new 'mail.alias.domain' model storing information previously stored
as a unique value in 'mail.catchall.domain' configuration parameter. Domains
are not completely linked to companies, allowing to have a mono-domain MC
setup, or mono-company multi-domain setup.

A main email domain is present on companies for all default domain computation
when being in that company while keeping flexibility of having other domains
defined.

Now that a new 'mail.alias.domain' model exists we move bounce and catchall
aliases definition directly on this model. Update related computation on
company model. Default_from is also moved on this model, allowing an higher
level default from computation for mail servers when having knowledge of
alias domain environment. Filtering configuration based on default_from_filter
is kept as an ICP as it is mainly used for odoo-bin with smtp-host.

Usage of 'mail.catchall.domain' will soon be completely removed to be replaced
by proposed company-based email alias domain usage.

Constraints are added so that each bounce and catchall defined on domains
do not clash with existing aliases. Sanitize of bounce and catchall is also
performed to ensure they make valid emails. This matches previous behavior
of ICP parameters. Domain name is also sanitized like alias names.

Currently only base modeling and computation is done. Their usage is about to
be gradually added in mail stack.

LINKS

Task-36879 (Mail: Support Multi Domains Aliases)

Part-of: odoo/odoo#76734
2023-10-24 19:24:50 +00:00
Thibault Delavallée f153e52e30 [IMP] test_mail: improve multi-company / server config tests
Composer tests now use the multi-company enabled model by default, allowing to
test company-dependent behavior. This has no impact on current tests, as there
is no company-dependent fields on composer model, and all tests are anyway
run into the main company (except multi-company specific tests, suffixed
by '_mc' generally).

We therefore also add some multi-company oriented tests to check notably
return-path or environment companies in various scenarios. Go until the SMTP
generation to test mail server choice, smtp_from and filtering, notifications
email.

Followup of odoo/odoo#136318 and odoo/odoo@3ffa1a0611 notably.

Task-36879 (Mail: Support Multi Domains Aliases)

Part-of: odoo/odoo#76734
2023-10-24 19:24:50 +00:00
Thibault Delavallée c53aae845d [REF] mail, various: lint / reorder code bits, improve tests
Perform some code cleanup not really related to other commits notably in mail
gateway where alias domains will have some impact. Extract some processing
in sub-methods, allowing to better distinguish code purpose. This implies
notably some checks in mail gateway (write to bounce or catchall detection).

In mail.message, reorder some fields according to their usage, just to keep
definitions / section.

Also improve docstrings and/or fix some of them.

This is mainly a "reduce diff in other commits" commit. No change should occur
with this commit.

Task-36879 (Mail: Support Multi Domains Aliases)

Part-of: odoo/odoo#76734
2023-10-24 19:24:50 +00:00
Thibault Delavallée b99d16670c [FIX] base: make ir_mail_server ordering deterministic
This may have an impact when trying to find an outgoing mail server based
on from and filter, as first match wins when checking matching filter on a
bunch of mail servers.

Prepares Task-36879 (Mail: Support Multi Domains Aliases)

Part-of: odoo/odoo#76734
2023-10-24 19:24:50 +00:00
Thibault Delavallée 93f378ea4f [FIX] mail: add default recipients from composer only in email mode
When composer runs in 'rendering' mode, it is often based on a mail.template
record that gives information about recipients. When having no template
default recipients are added to be sure to contact 'intended people'.

When rewriting code in 16.2, support of batch-comment was added in addition to
mass mailing. Result is that now default recipients are also computed when
posting in batch. However when posting we consider recipients are already set
on records using followers. Adding default recipients to avoid dummy emails
is present mainly for the mass mailing mode.

Followup of odoo/odoo#107356

Prepares Task-36879 (Mail: Support Multi Domains Aliases)

Part-of: odoo/odoo#76734
2023-10-24 19:24:50 +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
Didier (did) ea0071ffc7 [FIX] mail: improve messaging menu performance
To reproduce:

* Populate mail.message as medium or more
* Open odoo and click the messaging menu
* The messaging menu take an unreasonable amount of time to open.

This PR cache the threads getter to avoid unnecessary computations

task-3551625

closes odoo/odoo#139519

X-original-commit: aa92a630d5146b7a4ee5eb5d09bb6db04c1ba146
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-10-24 15:23:22 +00:00
Thomas Josse (thjo) 560e6ed4fd [IMP] mail: adds new props and buttons to handle comment Threads
This commit adds new optional props to the Message and Thread Components:
closeThread, openThread, avatarPlaceholder and showDates.
* `closeThread` is a function that enables the user to close an active comment
  thread.
* `openThread` is a function that reopens a previously closed thread.
* `avatarPlaceholder` is a boolean that will add an avatar placeholder
  (fa-user icon) when needed. For example when using Knowledge via the portal.
* `showDates` enables us to hide the dates showed inside the Thread component,
  it may not be useful for certain comment threads.

We also added a button inside the actionBox in the Message Component and it is
only rendered if we are on the first message of the thread.
The button can trigger either of the new function props depending on what is
provided to the component.

task-3317056

closes odoo/odoo#127380

Related: odoo/enterprise#41951
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-10-24 15:23:08 +00:00
Sylvain Francis a17a271618 [FIX] Automatically open attachment box after attachments are loaded
Before this commit:
If attachments are not loaded by the time useEffect is triggered,
the attachment box is not opened

After this commit:
The attachment box opens after the attachments are loaded, if there are any
and the "open_attachments" option is set

The bug can be reproduced by adding a time.sleep here:
https://github.com/odoo/odoo/blob/saas-16.3/addons/mail/controllers/thread.py#L13
And is caused by:
https://github.com/odoo/odoo/pull/134527

opw-3532736

closes odoo/odoo#139336

X-original-commit: e6c232a2554af79b5003aaad7c3ce55126104b66
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
Signed-off-by: Sylvain Francis (syf) <syf+odoo@odoo.com>
2023-10-24 13:55:17 +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
Sébastien Theys 005b76462a [IMP] mail, im_livechat, *: simplify channel ACL
* = bus, crm_livechat, hr, mail_bot, test_discuss_full, test_mail,
    website_livechat

Now that livechat uses guest, we can write proper ACL for channel and
channel member to check if the current user/guest is a member.

This allows removing most sudo in code and to simplify search domains.
Remaining sudo in discuss folder have been reviewed and commented.

task-3394829

closes odoo/odoo#138330

Related: odoo/upgrade#5295
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-10-24 12:38:21 +00:00
Florian Charlier bd5a68a1a7 [IMP] mail, mass_mailing, sms: process delivery reports
Also impacts mass_mailing_sms, test_mail_sms,
test_mass_mailing

This PR adds support to receive sms delivery reports.

Before this PR, an SMS was considered 'sent' when successfully
handled by the third party. The user couldn't know if/when an
SMS was actually sent for delivery or delivered to the
recipient's device.
This was similar to the behavior for emails as delivery reports
are not commonly used (and not supported in Odoo).

With this work, the SMS `pending` state is introduced in mail,
mass_mailing, sms and mass_mailing_sms contexts although only fully
used in the latter two modules (+tests of course).

Because of the huge cost related to upgrading very large existing
databases, the following compromises were made:

1. An email and sms notification/trace SENT means DELIVERED.
  Those that are sent but NOT DELIVERED are PENDING.
  The difference between email and sms traces reinforced with this PR
  is that an email sent will be counted as "sent" ~ "delivered"
  unless an error is returned for emails while for SMS it can only be
  reached if a delivery report is received.
2. The Link between an SMS uuid (shared with trusted parties) and
  the tracking records (notifications or traces) is done via an
  explicit relationship table (sms_tracker) instead of via a new field.
  This however allowed to nicely concentrate the state update logic.

A `process` state is added to represent an intermediate
step in the sending process, such as held at IAP for SMS.

A few adjustments are also included to update for IAP api v3.
Also, adapts and includes new tests.

Task-2560666

Part-of: odoo/odoo#133392
2023-10-24 12:38:13 +00:00
Sébastien Theys d3781a0f54 [IMP] mail: improve debug views of channel and member
Add critically missing channel type, and improve various names.

closes odoo/odoo#139393

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-10-24 03:01:09 +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 39e56939fd [REF] mail: simplify naming in internal of mail records
- `__invs__`/`RecordInverses` have been renamed to
  `__uses__`/`RecordUses`, so that it's more clearly separated
  from inverse fields. While they are some overlap in concepts,
  they require different datastructures so it's best to keep
  different implementations for the time being.
- `list.__addInverse__(r)`/`list.__deleteInverse__(r)` have been
  replaced to `r.__uses__.add(list)`/`r.__uses__.delete(list)`.
  Again change of wording "inverse" to "uses" like before, but
  also it feels more natural for uses as low-level concept to
  expose function on object where the uses are tracked, i.e. on
  the record, rather than functions in RecordList like before.
- Remove useless `__` prefix/suffix and/or only keep `_` prefix
  for `store` and `__addNoInv`/`__deleteNoInv`, for improved
  code readability
- Renamed `__list__` and `__map__` datastructures to `data`,
  again for improved code readability.
- Replaced some `Map<>` to `Object<>`, so that accessors are
  easier to read in code with `[]` rather than `.set()`/`.get()`,
  especially with code formatter that produces more LOCs than
  necessary with the latter. Note that the affected dict,
  `__computes__` and `__rels__` are set up at model and record
  setup, so they do not change shape after that, so using Object
  should not be a performance issue.

Part-of: odoo/odoo#138760
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 4d63a477bb [REF] mail: Remove deadcode about Record.__atomic__
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
Xavier Morel 9ebbfdac73 [FIX] *: incorrect translations markings
Fixes a large number of cases where strings are translated then
formatted, instead of letting `_()` do the formatting internally,
which allows it to recover from incorrect translations (missing,
broken, or extra placeholders).

Also

- removes translation markers entirely when there's nothing to
  translate e.g. `_("%s - %s")` is not useful
- fixes a few messes which lead to only partial translatability
  (DRY is generally a bad idea when translations are involved, even
  more so when you don't make the variable part translatable)
- fixes a few nearby issues noticed at the same time
- replaces a few `"%s"` by `%r`, which should automatically quote
  strings relatively appropriately
- fixes translated strings which use `\` to escape a newline (in order
  to fill-paragraph): `\` escapes only the newline, if the
  continuation string is indented this results in a bunch of spaces
  ending in the string to translate, which is pretty garbage for the
  translator, using implicit concatenation works much better

Note: some of the updates revert f-string parameters to %, because
babel (2.9) apparently has trouble with f-strings and blows up trying
to extract them.

Not in scope:

Helping translators fix translatable strings e.g. any translation
string with more than one placeholder probably should use keyword
placeholders

- Provides more context / data to the translator to make sense of the
  sentence.
- Allows reordering the translated terms, which can be necessary
  depending on the sentence and language.

closes odoo/odoo#139314

Related: odoo/enterprise#49311
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2023-10-23 16:45:09 +00:00
TSO fc573a8d8b [FIX] discuss: prevent push-to-talk release spam on some devices
Before this commit, devices with the key-repeat feature turned on
would not work well with the push-to-talk feature.

This commit sets a minimum delay before a push-to-talk key is considered
released.

closes odoo/odoo#139396

X-original-commit: aced53322309898d060c082e3d009293123ffea0
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-10-23 13:11:24 +00:00
tsm-odoo ffb8f83159 [FIX] mail: fix public page for non internal users
Before this commit, an error occured when opening the discuss public
page as a non internal user. This is caused by a read rpc being done
while the user is not allowed to do it. This commit ensures this rpc
is only done when allowed.

Steps to reproduce the issue:
- Open Odoo with Mitchell Admin
- Go to a public channel
- Start a RTC call
- Join the channel as guest with the invitation link
- A pop up appears

closes odoo/odoo#139397

X-original-commit: c7e66f3878b451001dbe4e8e3cdd8ced9a8ed632
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
2023-10-23 09:05:10 +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
Sébastien Theys d67a3ec8e8 [IMP] mail, *: return recordset in channel create methods
* = calendar,test_discuss_full, test_mail, test_mail_full

Methods can be downgraded to channel_info when called by RPC.
This increases the simplicity to use these methods in python.

closes odoo/odoo#139341

Related: odoo/enterprise#49326
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-10-20 23:37:44 +00:00
Sébastien Theys 7e5505da06 [FIX] base, mail, website_forum: correct populate of base models
Significantly improves the usability and the result of the populate for
base models and channel/member/message.

- make populate of base models re-entrant
- adapt size to values that make sense:
  - small shows something relevant, and can be quickly ran several times
  - medium is fast enough to be usuable but big enough to highlight
    performance issues
  - large is... still not to be attempted
- avoid conflicting conditions that either make no sense or can lead to
  crashes when populating the data or running the database
- better spread of data in channel/member/messages

closes odoo/odoo#139269

X-original-commit: 73a5e322f6e250569ee1942d678f8a4f87616bd7
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-10-20 11:22:20 +00:00
tsm-odoo c5517ce86e [FIX] im_livechat: remove non-required dependencies
This commit reduces the size and avoid conflicts caused by
the embed live chat bundle: jquery, legacy libs...

At the same time, this commit fixes the emoji picker that was
wrongly positionned and scrolled up the page when opening.

Finally, this commit ensures the chat window is always at the
bottom of the screen.

opw-3539362

closes odoo/odoo#139261

X-original-commit: 1b29419e50343bfd723b41368ba38ce63b063d92
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-10-20 09:35:27 +00:00
Raphael Collet 450f9f58ac [FIX] mail: _track_post_template_finalize() is broken when the record no longer exists
Part-of: odoo/odoo#138019
2023-10-20 09:35:18 +00:00
Raphael Collet f6b7899a06 [IMP] core: use SQL wrapper in _read_group()
Part-of: odoo/odoo#138019
2023-10-20 09:35:18 +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
Pierre-Yves Dufays 725e7ffae3 [IMP] various: improve custom activity views
The following summary view of the record in the activity views have been
improved:
- project_task: task state added
- project_project: project manager added
- event_event: responsible and the dates (date_begin_located and
date_end_located) added
- account_move: total amount, customer and state added
- sale_order: total amount and the state added
- purchase_order: total amount and the state added
- crm_lead: customer and stage added
- hr_applicant (hr_recruitment): recruiter added
- survey_survey: responsible added
- maintenance.request: added equipment and responsible
- stock.picking: added scheduled_date
- repair.order: responsible, schedule_date and product_id added
- mrp.production: added responsible
- hr_leave (hr_holidays): status is added and default deadline modified see
below

Ensures that "Schedule activity" is in one line by adding a colspan.

hr_leave activity: When a time off approval activity is created as a
consequence of the creation of a hr.leave, the deadline of the activity is set
to the date_from of the hr.leave minus activity type delay_count (default 15)
except if it leads to a date anterior to today. In that case it is set to
today. That way, in the activity view, the time off approval activities are
more or less sorted by related hr.leave date_from and the cell date is an
indication of when the time off is planned.

Technical note: on most activity view, the activity record was not occupying
all the horizontal space. To solve that problem the css has been modified and
the max-width (200) that was imposed on the sub div has been removed. And as
it was impossible to impose a max-width for a flex div (which is the common
case for the activity record), the max width is imposed on each text that might
be too long using the class o_text_block. That class has been modified to
impose a max-width. That's why that class has been added in most view.
Alternativly, we could have modified the activity compiler to add that class
when the attribute full was set (not done because not sure of the consequence).

Task-3300854

Part-of: odoo/odoo#138135
2023-10-19 19:08:12 +00:00
Pierre-Yves Dufays 3f2f3c1beb [IMP] mail, various: simplify the systray
The system tray has been simplified:
- only one clickable area per activity group
- by default, a click on an activity group open the list view, except for some
model (ex.: journal entries, project, task, documents where the activity view
is opened). This can be defined per model using the _systray_view attribute on
the model.
- the clock icon providing access to the activity view has been removed. As it
is the only action, we also remove "actions" returned by systray_get_activities
in res_users.
- the KPIs are no longer clickable

The tests have been updated (for example, because we open the list view instead
of the kanban view) and one removed "activity menu widget: activity view icon"
as we only have one clickable area now and no more icons.

Task-3300854

Part-of: odoo/odoo#138135
2023-10-19 19:08:12 +00:00
Pierre-Yves Dufays b6c236df54 [IMP] {test_}mail: allow to keep done activities and improve activity view
We add the option to keep the completed activities to allow the user to keep
track of the past action, especially the uploaded files which are displayed
along the completed activities. This feature can be activated per activity
type and is disabled by default.

We also improve the activity view to give a better overview of what has been
done and what is still to be done and by whom.

We also add tests for those new features:
- check activity data for the views (server-side test)

* Details about the activity view improvements:

** Improvement of the column header:

- progressbar: previously, only visible activities were counted in the
progression bar. Now all are counted.
- activity counter: instead of displaying the total count (next to the
progression bar), we display now a ratio as 2 numbers (only if keep done is
enabled):

** Improvement of the activity cells:

- add assignees in activity cells of activity view (limit to 2 having the
activity with closest deadline, if more a + is displayed). Note: to avoid
spacing between avatar, we add the optional props noSpacing to the avatar
component.
- add done activity in activity cell popover
- increase by 50% the popover height
- display done activity cell in grey
- instead of displaying the activity count if greater than 1, we display a
ratio ongoing / activity count. Note: we don't display the denominator if all
activities are done or all are ongoing.

** Progress bar filter

The activity filter is slighly modified. Previously, when clicking on a color
of the progress bar, all cell with a different color where hidden (ex.: if we
were clicking on the green area to filter planned activities, red cell which
represents overdue activities were hidden even if there was also a planned
activities for this record and activity type). Now we also display cells with
other "color" if there exist for that record and that type an activity
corresponding to the filtered "color".

Technical note: mail_activity.get_activity_data returns now for the activity
types a list of dictionary instead of a list of list. This simplifies the
reading as we can now uses name instead of index (type[1] becomes type.name
for example).

Task-3300854

Part-of: odoo/odoo#138135
2023-10-19 19:08:12 +00:00
Zelong Lin 7efc948c99 [FIX] mail: translation for channel creation text
closes odoo/odoo#139230

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-10-19 18:02:24 +00:00
Alexandre Kühn a479a0bba6 [FIX] hr, mail: no crash on empty member.persona
Steps to reproduce:
- install `hr_homeworking`
- connect as Mitchell Admin
- make a private chat with Marc Demo
- `@mention` Marc Demo
=> crash (cannot read name of undefined (reading persona))

This happens because a spread record was inserted in model,
and in this scenario the record list in data can be the exact same
as the record list used in the model. The internal code of assigning
a many list is to `clear()` and then `push()` from data, but if the
data mutates from the `clear()`, then the `push()` does nothing and
the resulting relation is emptied.

This commit fixes the issue by keeping a copy of collection before
`clear()` so that push applies on original data that is intended by
insert.

This commit also adapt code in hr to not use spread record to insert
Persona. While it works with the fix, it's simpler to just update the
appropriate field and also more efficient, because spread a record
has to process all fields as an insert, wasting CPU time.

closes odoo/odoo#139143

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-10-19 17:01:15 +00:00
Alexandre Kühn 86c713117b [FIX] mail: do not save command 'ADD.noinv' during rel insert
Before this commit, some relational fields in records had
the command `[["ADD.noinv"]]` as value. This is a command and
it should have been feed by a model (pre)insert, but the
resulting value of the field should never be a command: it's
always a RecordList (one-size RecordList when a Record.one).

This happens because the RecordList tracks the owner, i.e. the
record that owns the RecordList value in the relation, but the
owner was not properly proxified.

Indeed, all models are wrapped in a proxy, so that they managed
delete/get/assign on relational fields. To feed command like
"ADD.noinv". the receiver MUST be the proxy in order to be feed
properly, otherwise the assignment with command sets the command
as the actual value on the field. This is precisely what happens.

This commit fixes the issue by properly passing the proxified owner
to the RecordList, so that `ADD.noinv` command works as expected.

---------------

This changes unveiled some mishandling of the inverse, notably
during deletion of the record: the deletion must not insert record
with `ADD.noinv`, otherwise the inverse record is added, and this
is prone to infinite loops. To properly managed deletion, a new
internal command `DELETE.noinv` is used to delete the record without
syncing the inverse field, again to prevent infinite loops like with
`ADD.noinv`.

Part-of: odoo/odoo#139143
2023-10-19 17:01:15 +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
Didier (did) 00c2f50019 [FIX] mail: add missing inverse on channel member thread
task-3546165

closes odoo/odoo#139017

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-10-18 13:39:20 +00:00
Victor Piryns (pivi) 4892b879e6 [PERF] mail: speed up partner suggestion in chatter/discuss
Issue:
Typing '@' in a chatter and waiting for the partner suggestions can
sometimes be really slow for some users, even freeze some users
browsers.

Analysis:
Since 12152279a5 the sorting on
partner suggestions has been generalized to take an arbitrary amount
of functions to apply sequential filtering. One particular of those
is `partnerCompareRegistry['discuss.recent-chats']` which makes a
call to `getRecentChatPartnerIds` which makes multiple checks for
each pair of partners in the thread to order them based on their
`lastInterestDateTime`. This property is actually quite heavy, as it
involves deserializing datetime objects and making calls to libs and
regex matches, creating a lot of garbage memory in the process.
The complexity of this machinery is atrocious:
- First `sortPartnerSuggestions` loops over all the current partners
  we fetched from the backend, and in a `sort` callback we call
  *each* filtering method (we shortcut on the first filtering that
  succeed). So we call at worse each filter `O(n*log(n))` times.
- Since `partnerCompareRegistry['discuss.recent-chats']` is the
  lowest sequence in the filtering array, we will *always* go
  through it for those partners `O(n*log(n))` times, inherently calling
  `getRecentChatPartnerIds`.
- This function in question gets it's list of partner from the
  thread in the store, and sorts those partners with a callback
  again. So again we have `O(m*log(m))` callbacks. This callback makes
  8 calls to `lastInterestDateTime`, which as mentioned previously
  is actually an expensive function if called frequently as it
  generates a lot of garbage.
- All this garbage that is generated triggers multiple calls to the
  browser GC, and it's being frequently called, either stalling the
  browser for a few seconds, and for some users (as the problems
  scales over quadratic for the number of partners in the
  suggestions/thread) completely halting it.

Solution:
- Correct implementation of `getRecentChatPartnerIds` to not call
  `lastInterestDateTime` so frequently, it was unnecessary.
- Dependency inject the call to `getRecentChatPartnerIds` outside of
  the initial sorting callback, as it's independent of the sorting
  parameter and can be hoisted outside of the routine and injected
  into the filter.

Reference:
task-3556235

closes odoo/odoo#138988

X-original-commit: ba31d252c0738811cfe80a70bbbd7d489a45cf03
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-10-18 13:39:13 +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
Thibault Delavallée 84e6596fa1 [REF] mail: improve link preview code (and perf)
Improve link preview code

  * remove useless code indirections;
  * improve performance of link creation, cleanly support batch-creation (could
    lead to 98+5 URLs to the same domain creation within default 10 seconds
    instead of 98+1 but we feel it's ok);
  * name methods according to ORM;
  * use tools for html empty;

Also cleanup link preview tests: concatenate tests when possible, improve
setup, use real-life scenarios (using 'message_post' notably), remove useless
data creation.

Task-3557985 (Mail: Message cleanup (shortcode, link))
Prepares Task-36879 (Mail: Support MultiCompany Aliases)

Part-of: odoo/odoo#138938
2023-10-18 07:51:43 +00:00
Thibault Delavallée 2bf4ad912f [REM] mail: remove useless link between message and shortcodes
There is a o2m / m2o link between mail.message and mail.shortcode. However
this link is not used: 'messages' (m2o from shortcode to message) is never
set. Anyway there is no usage of this link: shortcodes are replaced in
message body and that's it.

Task-3557985 (Mail: Message cleanup (shortcode, link))
Prepares Task-36879 (Mail: Support MultiCompany Aliases)

Part-of: odoo/odoo#138938
2023-10-18 07:51:43 +00:00
Thibault Delavallée f6ca054238 [FIX] mail: lessen recompute on res.company model
'email_formatted' on 'res.company' model depends on its formatted catchall
and its underlying partner formatted email. However we do not need to
give 'partner.id.email_formatted' trigger in the compute methods as it is
not stored and thus do not need to recompute it for every change of linked
partners in DB; it is valid for the current transaction. It allows to lessen
invalidation of computed fields.

Task-3557985 (Mail: Message cleanup (shortcode, link))
Prepares Task-36879 (Mail: Support MultiCompany Aliases)

Part-of: odoo/odoo#138938
2023-10-18 07:51:43 +00:00
Zelong Lin 7ac121b54d [FIX] web,mail: correspondent can be null
Correspondent in thread can be null and lead into crash
when getting thread action and im status.

Replace correspondent with chatPartner when type is chat.

The fix is to solve the problem so that it is not blocking
systray and chatWindow tests related.

Also, this fix small issue of systray overflowing issue.

closes odoo/odoo#138913

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-10-18 07:51:41 +00:00
zel-odoo 2dee324384 [IMP] mail: remove link from creation notification
Previously, a link was included when creating a channel,
but this was unnecessary since there is no way to see the link
when you are not in the channel.
This commit removes the link while keeping the notification
to show the author and time of channel creation.

closes odoo/odoo#138668

Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
2023-10-17 10:05:52 +00:00
TSO 2bba00dd69 [IMP] discuss: add fields required for the SFU server implementation
Related PR: https://github.com/odoo/odoo/pull/132153

task-2765922

closes odoo/odoo#138581

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-10-17 10:05:50 +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
Julien Mougenot 1c56280382 [IMP] web,*: status bar auto-resize
Before this commit, the status bar field could be displayed in 2 ways:
- in small screens: as a dropdown
- in larger screens: as an inline list of buttons

This commit centralizes both of these approaches into a dynamic display
that fits the available space:
- the current stage is always displayed;
- previous stages are displayed behind or contained in a dropdown if not
enough space;
- next stages are displayed behind or contained in a dropdown if not
enough space.

Task 3336856

closes odoo/odoo#124267

Related: odoo/enterprise#48706
Signed-off-by: Mathieu Duckerts-Antoine (dam) <dam@odoo.com>
2023-10-16 10:39:53 +00:00