Commit Graph
1753 Commits
Author SHA1 Message Date
tsm-odoo 66bb1d351b [FIX] {im,website}_livechat: only send guest token when available
Before this commit, live chat would fail for guest portal. In this
scenario, there is no guest token. Before this commit, the guest
token was sent anyway with `null` as value which caused a crash.

closes odoo/odoo#139585

Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
2023-10-24 18:11:31 +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
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
FrancoisGe f0efa1dca8 [FIX] web, im_livechat: click twice on a record in a x2many
Before this commit, if you click twice on a record in x2many, two dialogs
are opened containing the same record.

Solution:
=========
Prevent a record from being opened as long as a record in this x2many
is already open.

How to reproduce:
=================
Go to a form view with an x2many
Click on the first record in the x2many
Click a second time on the record of the x2many (before the dialog is opened)

Before this commit:
-------------------
Two dialogs are opened with the selected record

After this commit:
------------------
Only one dialog is opened with the selected record

closes odoo/odoo#138984

X-original-commit: 31a9b13
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Francois Georis (fge) <fge@odoo.com>
2023-10-19 14:47:29 +00:00
tsm-odoo 2b181aa97a [FIX] im_livechat: restore live chat button notification
Since [1], the notification option for the live chat button does not
work. This commit restores it.

[1]: odoo#122834
task-3555864

closes odoo/odoo#138904

X-original-commit: 2f8683d22a781fce6cc5c1c39b0018f1b531fa8a
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-10-18 07:51:40 +00:00
Alexandre Kühn 882fc6d147 [REV] website_livechat: fix tour failing nondeterministically
This reverts https://github.com/odoo/odoo/pull/138582 as it was
preventing merging anything on runbot. Another fix is planned for
this tour at a later date.

closes odoo/odoo#138980

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-10-17 21:19:06 +00:00
tsm-odoo 0c3927f4da [FIX] im_livechat: fix emoji rating size for live chats
Live chat bundle structure changed in [1]. This PR misplaced a scss
file which results in a class missing from the Odoo backend. This
PR solves this issue

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

closes odoo/odoo#138830

Signed-off-by: Didier Debondt (did) <did@odoo.com>
2023-10-17 08:53:15 +00:00
tsm-odoo ff4a9b018a [FIX] im_livechat, website_livechat: fix chatbot after reload
Since [1], the live chat button is displayed after a conversation ended.
This change introduced a bug with with the chat bot.

Steps to reproduce:
- Open a chat with the bot
- Reload the page
- Close the live chat
- Open another chat
- The bot does not start

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

closes odoo/odoo#138826

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-10-17 08:53:12 +00:00
tsm-odoo 74cc99f72c [FIX] im_livechat: error when loading a page with outdated guest
This PR fixes two issues:
- Incorrect write on `channel_member_ids` (trying to link guest instead
of channel member)
- Incorrect condition in  `livechatService.leaveSession` that relies on
the live chat to be initialized while it can acutally be called before
if the current session is outdated.

This could result in server errors in the following scenario:
- Open a live chat
- Log in
- Open a live chat from the website app
- Log out
- Reload the page

Part-of: odoo/odoo#137834
2023-10-16 12:00:02 +00:00
Brieuc-brd 538fdab99b [IMP] *: fine-tune app icons
The aim of this commit is to improve the impact and rendering of app
icons in bright and dark mode. It also reduces the size of svg files.

To achieve that, this commit updates the colors to flat colors. This
change will make the icons stand out and improve their readability.

task-3072562

X-original-commit: 667a19162b74fb6554a2389ba9c6e69de4ff5113
Part-of: odoo/odoo#138279
2023-10-16 09:21:17 +00:00
tsm-odoo 427074c03a [IMP] im_livechat, website_livechat: improve live chat bundles
This commit improves the live chat bundles:
- `core`
	- `common`: hold files that are common to every feature
	- `web`
- `standalone`: hold files for the embed live chat and is splitted
in 4 sub-bundles:
	- `common`
	- `frontend`: should only be added in the Odoo frontend.
	- `external`: should only be added outside of Odoo
	environment (e.g. support page).
	- `cors`: should only be added when the live chat
	is requested from a different origin.

This will make live chat folder structure closer than the one used
in mail and avoid code duplication.

task-3537697

closes odoo/odoo#138536

Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
2023-10-16 07:58:43 +00:00
tsm-odoo 8bf49da5a7 [FIX] website_livechat: fix tour failing nondeterministically
This commit fixes the `website_livechat_chatbot_flow_tour` that was
failing in a nondeterministc way. This is due to the tour sometimes
taking more than `60` seconds which is the default timeout for python
tours.

Most of the time is consumed waiting for the user to finish its
multiline input. This issue is solved by shortening the delay to
consider the multiline input as done: from `10`s to `500`ms.

fixes runbot-24557

closes odoo/odoo#138629

X-original-commit: cdca70941dab1b20dca9bdf9d44d354327176b59
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
2023-10-13 14:14:04 +00:00
tsm-odoo 2a69035e38 [FIX] im_livechat: do not overwrite author of message format
Before this commit, the `_message_format` override of the live chat
module would overwrite the author. Since [1], values provided by the
live chat override are incomplete which result in incorrect message
display in the discuss app. This commit modify the live chat override
to enrich the author instead of totally overwriting it.

Steps to reproduce:
- Log in with mitchell admin
- Change its live chat user name in its profile
- Open a chat with a visitor
- Send a message with mitchell
- The message is incorrectly marked as sent by the visitor

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

closes odoo/odoo#138533

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-10-13 11:46:24 +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
suresh badikala b04fc2fa5a [FIX] im_livechat: fix customer ratings open wrong form view
Steps:
- Install project and live chart applications
- In project reporting then
- Customer ratings
- Click on kanban card, task form view open

Issue:
- When we click on a Kanban card, it opens the 'project.task' form view instead
of the 'rating.rating' form view

Cause:
- This problem occurs when you install the 'Live Chat' application because,
in the 'Live Chat' application, they inherit the Kanban view from the 'rating'
module and insert some actions into the inherited view. This action affects
other modules where customer ratings are required, such as the project module
and others.

Fix:
-By creating a separate view for the Live Chat customer ratings,
the problem can be solved

task-3522178

closes odoo/odoo#138276

X-original-commit: f50e6dbbd46bf0d16c8f522d4f1d9b10445d1065
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
2023-10-11 04:48:51 +00:00
Julien Mougenot 8349f8f2a8 [REF] web,*: make draggable hook builder independant from Owl
This commit removes Owl hooks from the draggable hook builder file and
introduces a new parameter attribute (`setupHooks`) to specify which
functions must be used to set up, update and tear down the draggable
hook.

This has been done to allow the draggable hook builder function to be
used in environments where Owl is not available.

Part-of: odoo/odoo#137527
2023-10-10 01:59:35 +00:00
tsm-odoo 403553aebd [IMP] im_livechat: use guest avatar for live chat visitors
task-3471571

closes odoo/odoo#137806

Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
2023-10-09 18:16:57 +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
zel-odoo 78f6b83b34 [IMP] im_livechat: add/move config to user_setting
Enable livechat language setting for operators
Move livechat_username into res_user_setting

task-3390821

closes odoo/odoo#133142

Related: odoo/upgrade#5113
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-10-06 11:21:47 +00:00
tsm-odoo ae6f6e3e5b [IMP] im_livechat: improve livechat statistics
task-3471332

closes odoo/odoo#137548

Signed-off-by: Didier Debondt (did) <did@odoo.com>
2023-10-05 10:21:56 +00:00
Jorge Pinna Puissant ef424a9dc2 [REF] *: remove owl from linter's accepted global variables
Before this commit, owl was in the linter's accepted global variables.
This allowed  direct access to owl global object.

For instance, to use xml from owl, you could do :
`const { xml } = owl;`
or you could use it directly:
`owl.xml`

Now, owl is not accepted on linter's global variables anymore, so to
import xml, now you need to use a proper import:

`import { xml } from "@odoo/owl";`

task-id 3498859

closes odoo/odoo#137517

Related: odoo/enterprise#48364
Related: odoo/design-themes#709
Signed-off-by: Samuel Degueldre (sad) <sad@odoo.com>
2023-10-05 10:21:53 +00:00
tsm-odoo 3abc5100ad [FIX] im_livechat: clean session even when leave rpc fails
Before this PR, if an error occurred when leaving the session,
the state of the livechat was not properly reset. This is an
issue since this could lead to a visitor being stuck with an
outdated session. This commit ensures the session state is reset
even if an error occurs during the session leave rpc.

This PR also fixes an issue where two `init_messaging` rpc were
sent when restoring a live chat session.

closes odoo/odoo#137518

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-10-04 20:52:40 +00:00
Alexandre Kühn b1edee9a84 [REF] mail: simplify discuss model insert code
1. simplify message reaction formatter (personas)

Data was formatted to have "partners" and "guests" entries, both
of which contribute to personas.

To avoid some post-processing of data in JS, it's best to format
data to immediately include type of persona.

2. include "guestAuthor" in "author" data of message

Discuss models in JS group partners and guests into a single model
Persona, to make feature works regardless on whether user is
authenticated or not.

This commit simplifies code by removing data guestAuthor in message
formatted data, and instead author contains author data in all cases,
whether the author is a partner or guest.

3. simplify insert (remove id, redundant with preinsert)

Also rename Follower.isActive to Follower.is_active, for
even simpler Follower.insert()

closes odoo/odoo#137276

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-10-04 19:40:19 +00:00
Michael (mcm) 2fbc08a197 [IMP] *: remove legacy service mappers
This commit removes the legacy service mappers which are useless now.

closes odoo/odoo#136807

Task: 3439226
Related: odoo/enterprise#48015
Signed-off-by: Mathieu Duckerts-Antoine (dam) <dam@odoo.com>
2023-10-04 19:40:16 +00:00
Alexandre Kühn 3b251d6d66 [REF] mail: turn Composer.rawMentions into relational fields
This field contained 2 sets with partner and channel ids.
It's easier and safer to reason in terms of records rather
than properties on records.

Part-of: odoo/odoo#137341
2023-10-03 20:17:47 +00:00
Jorge Pinna Puissant 006ee1fc47 [REF] web, *: remove legacy cookie utils and cookie service
The cookie service was replaced by a utils file in core. This was done
to be able to use the cookies without the need of environment.

"Om Nom Nom Nom" - Cookie Monster

part-of task-id 3439226

closes odoo/odoo#136782

Related: odoo/enterprise#48005
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-10-03 20:17:40 +00:00
tsm-odoo bd4e418fc1 [IMP] im_livechat, mail: allow CORS livechat actions
This PR makes several actions available for the embed livechat
such as:
- calls
- message edition
- message reactions
- link previews

task-3523930

closes odoo/odoo#136618

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-10-03 19:20:10 +00:00
Alexandre Kühn b526078ae9 [REF] mail: set data immediately on discuss model relational field
With this commit, instead of `Record.insert()` before setting
relation with records, we can immediately pass record data.
For example:
```js
message.author = { id: 3, type: "partner", name: "Admin" };
thread.messages.add({ id: 10, body: "some-text-content" })
```

This is supported on all relational fields that define a target
model.

To make this work while drastically avoiding cyclic dependencies
in code, whenever data have to be inserted in relation, they are
pre-inserted with essential data, and then they are fully inserted
after being registered in the relation.

closes odoo/odoo#136539

Related: odoo/enterprise#47854
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-10-02 11:42:55 +00:00
tsm-odoo df57ab6221 [IMP] im_livechat: restrict operator assignation during call
This PR changes the operator allocation algorithm so that operators
in a call with already two ongoing chats are not prioritized over
more occupied operators that are not in a call.

part of task-2900771

closes odoo/odoo#135113

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-09-29 17:15:39 +00:00
Rémy Voet (ryv) a9dd388a11 [IMP] *: use private _read_group for efficiency/consistency.
Since https://github.com/odoo/odoo/pull/110737, it is better to use
`_read_group` instead of `read_group` in the backend. In fact, the
public method is less efficient (it computes display_name of relational
groupby, extra order, ...) and more verbose.

This commit replaces these new uses of `read_group` with `_read_group`.

closes odoo/odoo#136381

Related: odoo/enterprise#47826
Signed-off-by: Raphael Collet <rco@odoo.com>
2023-09-29 14:48:13 +00:00
tsm-odoo 0e023aff21 [FIX] im_livechat: fix missing css class on embed livechat
This commit adds the `ui.scss` file in order to provide image
related css classes to the embed livechat (`o_object_fit_cover`)
was missing.

Steps to reproduce:
- Go to the website
- Open a livechat
- Paste a link in order to display a link preview
- The image is stretched since the `o_object_fit_cover`
class is not available in the shadow DOM.

closes odoo/odoo#136656

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-09-28 01:51:25 +00:00
Alexandre Kühn 98491e3b43 [REF] mail: store all discuss models in Record.records as object
In preparation to improve insert in relational field with data, so
that there's less risk for cyclic code execution (hint: there'll be
a preinsert).

closes odoo/odoo#136308

Related: odoo/enterprise#47777
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-09-27 13:11:58 +00:00
Alexandre Kühn bef4069195 [IMP] mail: introduce RecordList.add() in discuss model relations
This method pushes the provided record if it's not in the record
list, otherwise it does nothing. This works a bit like `add()` on
Sets.

Part-of: odoo/odoo#136308
2023-09-27 13:11:58 +00:00
Alexandre Kühn 22ed4ec268 [REF] mail: rename commands in discuss model data
Relational data in server formatter are:
- for one relation: None/false or object
- for many relations: list of objects or list of commands

The commands were:
- 'insert': to add a new item in a relational field
- 'unlink': to remove an item from a relational field
- 'insert-and-unlink': to remove an item from a relational field
- 'clear': to remove all items from relational field

There was a slight nuance between 'unlink' and 'insert-and-unlink'
at some point, but it becomes irrelevant with current code of model.
The name of the commands were hard to grasp what they actually mean
for the many relations.

This commit improves it by renaming 'insert' by 'ADD' and the 2
'unlink' commands by 'DELETE'. This makes it more apparent that
the data in 'ADD' refers to data of record to add in the relation,
while 'DELETE' refers to data of record to delete from the relation.
The 'clear' has been replaced by `False` value instead of a command.

Part-of: odoo/odoo#136308
2023-09-27 13:11:58 +00:00
Alexandre Kühn 1af1b3e96a [REF] mail: remove unnecessary getters in thread
Also turn `invitedMembers` into relational field

Part-of: odoo/odoo#136308
2023-09-27 13:11:58 +00:00
Alexandre Kühn d97ffb0dde [REF] mail, *: turn store.discuss into a model
This allows to define categories as also models, which allow
to register list of threads as relational fields, which in turn
simplify code readability and maintainability of these relational
data.

Part-of: odoo/odoo#136308
2023-09-27 13:11:58 +00:00
Alexandre Kühn 603cd70ecc [REF] mail: move service.update() to discuss models
These `update()` functions are specific to a discuss record,
so it's best to be defined in the model rather than another
service.

Part-of: odoo/odoo#136308
2023-09-27 13:11:58 +00:00
Michael (mcm) 7422eb643c [IMP] *: remove legacy rpc
This commit removes the files ajax.js and rpc.js then adapts all the
places where their exports were used. For most of the changes, it's a
replace of `this._rpc({...})` by a new `useService("rpc|orm")` like
pattern in the widgets.

closes odoo/odoo#136271

Task: 3439226
Related: odoo/enterprise#47775
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-09-27 11:33:01 +00:00
Sébastien Theys aee3cb8929 [REF] mail, *: tests: remove last occurences of jQuery in contains()
* = im_livechat, project_todo, test_mail, web

closes odoo/odoo#136425

Related: odoo/enterprise#47825
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-09-27 07:28:08 +00:00
Sébastien Theys 7a90938a70 [REF] mail, *: tests: simplify text option of contains
* = bus, calendar, im_livechat, hr, project_todo, sms, snailmail,
    test_mail, web, website_livechat

The current implementation often led to tests relying on DOM structure
to properly target the correct element with the text.

It is now easier to simply check if a parent contains some text.

closes odoo/odoo#136295

Related: odoo/enterprise#47770
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-09-23 10:33:04 +00:00
Alexandre Kühn 18078c546e [IMP] mail: properly type discuss models
- Split d.ts files in `@types` folders that are close to
  where the definitions of model & patches.
- Update jsdocs of discuss models to be fully type, including
  model patches

When defining a new discuss model or a patch, should define a
`@types/models.d.ts` file. It must make use of module `models`
to define interface with model name:

```ts
declare module "models" {
    import { Thread as ThreadClass } from "./thread_model";

    export interface Thread extends ThreadClass {}

    // necessary to propagate types to relations
    export Models {
        "Thread": Thread,
    }
}
```

When defining a patch, should also define a `@types/models.d.ts`
to augment the interface of the model at hand:

```js
patch(Thread.prototype, {
    setup() {
        this.pinnedMessages = Record.Set("Messages");
    }
});
```
```ts
declare module "models" {
    import { Message } from "models";

    export interface Thread {
        pinnedMessages: Set<Messages>,
    }
}
```

Part-of: odoo/odoo#134884
2023-09-21 23:54:21 +00:00
Julien Carion (juca) 1a44537095 [IMP] mail: avatar card preview v2
This commit changes the behavior of the avatar card preview so that it
is now triggered on click instead of on hover and the previous behavior
of the click event (open chat) is therefore removed. It also adds the
functionality to the Message and Activity components of discuss so that
clicking on the avatar inside these components will also show the card.
It also makes sure that the id of the user is added to the persona even
if nothing indicates that it should.

task-3442819

closes odoo/odoo#131355

Related: odoo/enterprise#47084
Signed-off-by: Francois Georis (fge) <fge@odoo.com>
2023-09-15 16:45:50 +00:00
Alexandre Kühn 7d5442eef1 [FIX] website_livechat:tests: fix chatbot ui tour nightly build fail
Follow-up of https://github.com/odoo/odoo/pull/135378

Commit above fixed a potential issue where guests may eventually have
many livechats, so finding the livechat thread just by
`type: livechat` is not enough. To be more specific, it relies on
livechat session stored in cookie.

However, when there's no livechat session, there's no id stored in
cookie. The livechat thread uses a `TEMPORARY_ID`. Fix above forgot
to handle this part, thus the getter was failing when there's no
persistent livechat session.

closes odoo/odoo#135442

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-09-14 11:22:58 +00:00
Sébastien Theys 7ea370fce7 [REF] mail, *: tests: refactor contains to further remove jQuery
* = account, base_iban, bus, calendar, crm_livechat, hr, hr_holidays,
    im_livechat, mrp, project, sms, snailmail, test_mail,
    test_mail_full, web, website_livechat, website_slides

Add support in `contains` for most operations that we use in tests.
Remove return value from `contains`.
Move into `web` module.
Remove import/export chains, directly import from correct module.

closes odoo/odoo#134652

Related: odoo/enterprise#47064
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-09-14 11:22:47 +00:00
tsm-odoo ed020e9889 [FIX] im_livechat: fix livechat service thread getter
The livechat service thread getter relies on the thread type to find
the current livechat thread. Since guest could have many channels it
is incomplete, the id should also be checked. This PR fixes this issue.

closes odoo/odoo#135378

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-09-13 17:43:11 +00:00
tsm-odoo 0c84c4f36d [REV] im_livechat, mail: remove cors from discuss route overrides
This PR removes the livechat's discuss route overrides
that added `cors="*"` since they are not safe (different databases on our
cloud are considered as SameSite).

In the meantime, embed livechats won't work as expected since cors is
prevented and will be fixed in a following PR.

closes odoo/odoo#135260

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-09-13 16:39:47 +00:00
tsm-odoo 4775fedddf [FIX] im_livechat: fix history command
Before this commit, executing the `/history` command in a livechat
would do nothing. Indeed, the message was sent on the wrong target
through the bus so the history request was never received by the
visitor client. This commit fixes the issue by sending the notification
on the channel instead of the channel uuid.

closes odoo/odoo#135254

Signed-off-by: Didier Debondt (did) <did@odoo.com>
2023-09-13 10:55:53 +00:00
Aaron Bohy 93938cfdf3 [IMP] web,*: remove assets_backend_prod_only
This commit reworks a little bit the backend assets to remove a
bundle and thus save a call at webclient startup. The bundle
"assets_backend_prod_only" existed only to allow to add files in
production, but not in the tests (typically, the file that spawns
the webclient).

This commit introduces a new bundle "web.assets_web" that contains
"assets_backend" and the few files that we only want in production.
In the /web page, we now load "assets_web" instead of
"assets_backend" and "assets_backend_prod_only". In the /web/tests
page, we keep loading "assets_backend", which is now directly
included into "web.tests_assets".

For the sake of consistency, this commit also renames the dark
mode bundle "dark_mode_assets_backend" into "assets_web_dark".

closes odoo/odoo#135204

Related: odoo/enterprise#47316
Signed-off-by: Samuel Degueldre (sad) <sad@odoo.com>
2023-09-13 08:20:40 +00:00
tsm-odoo 4be75dd002 [IMP] im_livechat: allow visitors to receive calls
task-2900771

closes odoo/odoo#135109

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-09-13 03:37:56 +00:00
tsm-odoo be35b9f519 [FIX] im_livechat: actions on frontend messages
This commit prevent the livechat visitor from executing actions
on frontend messages (that are not known by the server).

Steps to reproduce the issue:
- Open a livechat with an operator
- A welcome message is displayed ("How can I help you?")
- Add a reaction to this message
- A crash occurs

closes odoo/odoo#134987

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-09-11 15:22:13 +00:00