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>
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>
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>
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>
This commit adds the discuss message features to the livechat
threads:
- Edition/deletion of messages
- Reactions
- Replies
It also improves the history view present in the channel form view
by showing replies.
task-2742676
closesodoo/odoo#133456
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit fixes the "website_livechat_chatbot_flow_tour" which was
nondeterministic. This was due to the message service update which was
assigning data blindly based on the payload instead of handling it
properly. This is solved by enriching the chatbot step instead of
overwriting it.
runbot-24625
closesodoo/odoo#134778
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Before this commit, the livechat was still using a dedicated
route to fetch messages on page load. Since [1], visitors are
actually mail guest so they can access the classic mail route
in order to do so. This commit adapt the livechat code to use
this route instead of the custom one.
At the same time, this commit simplify the livechat service.
part of task-3332628
[1]: https://github.com/odoo/odoo/pull/129770closesodoo/odoo#133430
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Before this commit, the livechat button was not shown anymore after
closing the chat window. Since the livechat button is always present
from now on, the button is now draggable.
task-3358161
closesodoo/odoo#134513
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This PR fixes a server error when trying to test a chatbot that
appeared with the [livechat refactoring].
Steps to reproduce:
- Go to a livechat channel form view
- Click on the "chatbot" smart button
- Click on a chatbot
- Click on the "test" button
- An internal server error occurs
task-3485014
[livechat refactoring]: https://github.com/odoo/odoo/pull/122834closesodoo/odoo#134227
X-original-commit: dfc50ea4e4fb327876458afee1b807e36ce80c2b
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
When we haven't provided a custom action, the tour step runs the default
action. In the final step of the tour, when there is no `run` or
`isCheck` provided, It shows warnings of 'ignoring action (auto) of last
step' as it can lead to a race condition.
This commit resolves the warnings: `ignoring action (auto) of last step`
task-3429500
closesodoo/odoo#129239
Related: odoo/enterprise#46683
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
1. Introduce `static id` to all models, to uniquely identify
a record in a model. This allows normalizing discuss store
for all models, which helps as preparation for managing
record deletion. Can also be combined
```js
class Message {
static id = "id";
id;
}
class Thread {
static id = AND("model", "id");
}
```
2. Introduce `Model.get()` to easily get a record of model
from data that can identify the record. This prevent leaking
the way the record are stored in `records`, as now all records
are indexed by localId, and localId is technical detail.
```js
Message.get(messageId);
Thread.get({ model: "discuss.channel", id: 1 });
```
Part-of: odoo/odoo#134008
* = calendar, hr, im_livechat, mrp, project_todo, sms, snailmail,
test_mail
The parameter is too often specified with its default value to be worth
being a positional parameter.
Part-of: odoo/odoo#133717
* = calendar, im_livechat, project_todo, sms, snailmail, test_mail,
website_slides
The choice was made to have "trimmed text" check rather than "contains"
to have more robust tests, at the cost of slightly more effort to write
complete and unique asserts.
There is no direct speed improvement from this one, but it is one step
closer to removing jQuery.
Moreover, it will fix infinite loops in some situations, because jQuery
selectors would write attributes on the body, which would trigger the
mutation observer, which itself will call the selector again.
Part-of: odoo/odoo#133717
Before this commit, message edition was available when
pressing the arrow up key. This was a mistake since the
message edition route is not available yet for livechat
visitors. This PR fixes this issue.
closesodoo/odoo#133815
X-original-commit: ab7e70e809b3c7fa5044139582bd09a9e94ee377
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit improves the mail `onChange` method by adding
the support for multiple keys. This will make the code shorter
and easier to read.
closesodoo/odoo#133778
Signed-off-by: Didier Debondt (did) <did@odoo.com>
In preparation to clean code of models, e.g. by simplifying model
insertion and reducing side-effects in record insertion.
This commit moves the implementation of the `insert()` in discuss
services to the models, and drop support of the service methods
`insert()`. The only way to insert a model is through the store
entry, e.g. `store.Thread.insert()`.
closesodoo/odoo#133509
Related: odoo/enterprise#46499
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This PR adds a panel to consult all attachments of a discuss channel
easily.
task-3476444
closesodoo/odoo#132784
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
They existed solely for typedoc and wrapping `useState()`.
- Typedoc is managed by `useService()` and `services.d.ts`.
- `useState()` is a minimal code in component, and is actually
more useful as explicitly visible in component.
closesodoo/odoo#133202
Related: odoo/enterprise#46327
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
In preparation of code cleaning of models in store.
Entries in store are allocated per model, using the model name.
Records of a model can be accessed from `store[ModelName].records`.
Part-of: odoo/odoo#133202
Before this commit, discuss models were compared with object
reference, e.g. `thread_1 === thread_2`.
This is unsafe with `owl.reactive()`, because it wraps the objects
in a Proxy, and different proxies may map to a same raw object.
This commit fixes the issue by defining `.eq()` and `.in()` methods
on discuss models, which makes comparison on raw value rather than
proxy/reactive one.
This PR also introduce "not" variants, e.g. `.notEq()`, which eases
readability by having "not" and "eq" next to each other.
These "not" variants must be used without optional chaining,
otherwise this gives the opposite result. For example:
```js
const [t1, t2] = [Thread.insert()];
t1 === t1 // true (OK)
t1.eq(t1) // true (OK)
t1.notEq(t1) // false (OK)
t2?.notEq(t1) // undefined => falsy (notOk)
!t2?.eq(t1) // true (OK)
```
closesodoo/odoo#133065
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
*: auth_password_policy, bus, event, im_livechat, mail, mass_mailing,
mrp_subcontracting, point_of_sale, pos_self_order, project, stock,
survey, web, web_editor, web_tour, website, website_event,
website_forum, website_sale, website_slides, base
Historically, the web.assets_common bundle was used to contain assets
that were needed by both the frontend and the backend. In practice, this
caused a bunch of issues where people would add things in assets common
that were not needed by both, and it was also abused as a way to get
bootstrap working in unrelated places by only using that bundle's css.
Because of this, as a first step, the assets_common stop being used in
the frontend, but was left everywhere else.
This commit removes the bundle completely, and moves the files that used
to be in that bundle in the other bundles that need them, this will
allow those bundles to evolve independently going forward.
in im_livechat and mail, some of the unneeded legacy code was removed, this
allows us to avoind including all of the legacy code from web in the
livechat embed bundle and in the dicuss public bundle respectively.
closesodoo/odoo#132190
Related: odoo/enterprise#45884
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
* = hr, im_livechat
The real service works just as well, gives more guarantee on what is
actually tested, and requires less lines of code.
closesodoo/odoo#132744
Related: odoo/enterprise#46108
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>