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.
closesodoo/odoo#139585
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
* = 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
closesodoo/odoo#138330
Related: odoo/upgrade#5295
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
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
closesodoo/odoo#139261
X-original-commit: 1b29419e50343bfd723b41368ba38ce63b063d92
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
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
closesodoo/odoo#138984
X-original-commit: 31a9b13
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Francois Georis (fge) <fge@odoo.com>
Since [1], the notification option for the live chat button does not
work. This commit restores it.
[1]: odoo#122834
task-3555864
closesodoo/odoo#138904
X-original-commit: 2f8683d22a781fce6cc5c1c39b0018f1b531fa8a
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
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/138536closesodoo/odoo#138830
Signed-off-by: Didier Debondt (did) <did@odoo.com>
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/134513closesodoo/odoo#138826
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
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
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
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
closesodoo/odoo#138536
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
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
closesodoo/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>
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/137276closesodoo/odoo#138533
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
- 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.
closesodoo/odoo#137750
Related: odoo/enterprise#48484
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
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
closesodoo/odoo#138276
X-original-commit: f50e6dbbd46bf0d16c8f522d4f1d9b10445d1065
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
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
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
closesodoo/odoo#137574
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
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
closesodoo/odoo#137517
Related: odoo/enterprise#48364
Related: odoo/design-themes#709
Signed-off-by: Samuel Degueldre (sad) <sad@odoo.com>
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.
closesodoo/odoo#137518
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
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()
closesodoo/odoo#137276
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit removes the legacy service mappers which are useless now.
closesodoo/odoo#136807
Task: 3439226
Related: odoo/enterprise#48015
Signed-off-by: Mathieu Duckerts-Antoine (dam) <dam@odoo.com>
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
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
closesodoo/odoo#136782
Related: odoo/enterprise#48005
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This PR makes several actions available for the embed livechat
such as:
- calls
- message edition
- message reactions
- link previews
task-3523930
closesodoo/odoo#136618
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
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.
closesodoo/odoo#136539
Related: odoo/enterprise#47854
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
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
closesodoo/odoo#135113
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
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`.
closesodoo/odoo#136381
Related: odoo/enterprise#47826
Signed-off-by: Raphael Collet <rco@odoo.com>
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.
closesodoo/odoo#136656
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
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).
closesodoo/odoo#136308
Related: odoo/enterprise#47777
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
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
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
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
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
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.
closesodoo/odoo#136271
Task: 3439226
Related: odoo/enterprise#47775
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
* = 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.
closesodoo/odoo#136295
Related: odoo/enterprise#47770
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
- 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
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
closesodoo/odoo#131355
Related: odoo/enterprise#47084
Signed-off-by: Francois Georis (fge) <fge@odoo.com>
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.
closesodoo/odoo#135442
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
* = 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.
closesodoo/odoo#134652
Related: odoo/enterprise#47064
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
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.
closesodoo/odoo#135378
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
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.
closesodoo/odoo#135260
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
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.
closesodoo/odoo#135254
Signed-off-by: Didier Debondt (did) <did@odoo.com>
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".
closesodoo/odoo#135204
Related: odoo/enterprise#47316
Signed-off-by: Samuel Degueldre (sad) <sad@odoo.com>
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
closesodoo/odoo#134987
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>