As a step to simplify model insert from python. All data are
formatted in a way to make data insert trivial in JS models.
closesodoo/odoo#138760
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
[1] tried to remove nondeterminism from bus tests. However, several
issues remain:
- the asset watchdog bundle is added to the registry during bus tests.
Websocket tests wait for the `connect` event after starting the environment.
This `connect` event can be triggered sooner than expected since the asset
watchdog services starts the bus.
- a the random delay is added to the reconnection attempts.
- `nextTick` is kept when waiting for a client to leave the worker.
This commit fixes those issues.
[1]: https://github.com/odoo/odoo/pull/138221closesodoo/odoo#138639
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit makes bus tests more robust by implementing
functions that wait for some events instead of relying
on `nextTick` that might or not be sufficient.
fixes runbot-23097
closesodoo/odoo#138221
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
This commit cleans the bus tests by:
- flattening the tests structure by putting tests outside
of the `QUnit.module` function.
- removing unnecessary `assert.expect` calls.
- adding an helper to add common bus service to the registry
Part-of: odoo/odoo#138221
* = 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>
* = 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>
Before this commit, the "subscribe to single notification"
test failed in an nondeterministic fashion. This commit
solves this issue.
fixes runbot-24033
closesodoo/odoo#134243
Signed-off-by: Didier Debondt (did) <did@odoo.com>
Before this commit, avatar url of author of message always had
style `.o_object_fit_cover`, which makes a nice crop when
ratio of image does not match ratio of the `img`.
When the author of message is a company, it shows the logo of the
company, and it doesn't look nice to crop it.
This commit fixes the issue by using `.o_object_fit_contain` for
avatar of company, so that the logo is fully visible.
When displaying the avatar of a partner whose `is_company` is
undefined, the data is group-fetched, in order for models to
eventually know the value of `is_company` and use the correct
desirable showing.
Task-3381748
closesodoo/odoo#133311
X-original-commit: 48194366f2364e2eb9d99dc4fb71e2de83d8f7a2
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit removes almost all exports of the module services/core.js
(only the bus is left) and adapts the module that imported it.
task 3439226
Part-of: odoo/odoo#133153
Before this commit, the current user was cleared after every
test. This is an issue since we can still interract with the
page after the test is done when in debug mode. This commit
fixes the issue by clearing the current user at the beginning
of each test instead of the end.
closesodoo/odoo#132801
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
*: bus, calendar, im_livechat, web, website_livechat.
This PR adds the possibility to set the current user during tests as
well as the mail guest. This will be used to test mail guest page and
livechat once the visitors will be treated as guests.
part of task-3332628
closesodoo/odoo#130811
Related: odoo/enterprise#45331
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
Before this PR, the user during livechat embed tests was the admin partner while
it should be the public partner. This commit fixes the issue.
part of task-3332628
closesodoo/odoo#130429
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
In the commit [1], the patch has been refactored to support the
native keyword `super`. The current commit just adapts the codebase
to that change.
task 3410198
[1]: 19ea1ac08043e22a811630968e44715cc3bfc495
Part-of: odoo/odoo#125716
luxon and moment are both used in the solution,
but these two libraries facilitate the manipulation
of dates. It was decided to replace all uses of
moment with luxon so we can then remove
moment.js from the code and lighten the assets.
task-3391739
closesodoo/odoo#128752
Signed-off-by: Bruno Boi (boi) <boi@odoo.com>
Before this commit, a new unread message could contribute to unread
counter of conversation twice.
Steps to reproduce:
1. Log in as Demo and start a conversation with Mitchell Admin
2. Log in as Admin: if this is the first message in the conversation,
counter is correct and shows (1)
3. Log out as Admin
4. Send another message to Admin
5. Log in as Admin and notice that the counter is doubled
6. If the conversation was still open, counter is correct!
This happens because some notification are pending dispatch before
fetching messaging state initially. The counter at init_messaging
fetch takes into account the notification. However, when handling
the message notifcation, it's wrongly considered as a new
notification, thus incrementing the counter when it shouldn't.
This commit fixes the issue by fetching the last bus notification
when fetching init_messaging. Doing so allow to determine whether
a notification is newer or older than init_messaging state.
This helps deciding whether the counter should be incremented or not.
Task-3357960
closesodoo/odoo#124767
X-original-commit: 081ab772dece86f1b5a5d4b3f6227b4b311d9206
Signed-off-by: Stockbauer Matthieu (tsm) <tsm@odoo.com>
*: calendar, iap_mail, im_livechat, mail.
Until now, one had to subscribe to the global "notification"
event of the bus service and to loop through each notification
to handle the one that was targeted.
This PR introduces the `subscribe` method on the bus service
in order to subscribe to a single notification type.
closesodoo/odoo#120893
Related: odoo/enterprise#40848
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Since [1], some bus tests were failing in a non-deterministic
way. This PR fixes the issue.
[1]: https://github.com/odoo/odoo/pull/119525
Fixes runbot errors: 20755, 20756, 19933.
closesodoo/odoo#119807
X-original-commit: c52670c9e91c369410422afacfbd9080d432e8bd
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Signed-off-by: Stockbauer Matthieu (tsm) <tsm@odoo.com>
Before this commit, the bus service was starting worker at page
load, regardless on whether the user interacts with chat features.
This commit starts bus worker only when it's really useful, e.g.
when adding a new channel to subscribe. Functionally, on livechat,
the worker does not start before the livechat is open.
Task-3266973
closesodoo/odoo#119528
Signed-off-by: Stockbauer Matthieu (tsm) <tsm@odoo.com>
* = base_geolocalize, calendar, website_crm_partner_assign
Oversight of discuss refactoring. Code is restored into bus module as it
does not depend on any mail or discuss feature.
closesodoo/odoo#119243
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit converts almost all odoo module by native module.
The goal is to deprecate odoo.define in favor of native module and then
simplify boot.js by removing the regexp that finds module dependencies.
task id: 3162300
closesodoo/odoo#117305
Related: odoo/enterprise#39118
Signed-off-by: Géry Debongnie <ged@odoo.com>
`PartnerRoot` is a confusing name for what is in fact what everyone call `odoobot`
closesodoo/odoo#116823
Signed-off-by: Debondt Didier (did) <did@odoo.com>
Before this commit, the bus service test "tabs share message from a
channel" was sometimes failing. This is due to the fact that it was
only waiting a `nextTick` to receive the message but the message is
not guaranteed to arrive within a tick. Indeed, the message is first
sent from the worker `MessagePort` via `postMessage` then triggered
on the event bus via `dispatchEvent`.
closesodoo/odoo#113008
X-original-commit: a8d25a89a9fbdb9d51926df2c33c1f4b5eba9b3f
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Signed-off-by: Stockbauer Matthieu (tsm) <tsm@odoo.com>
Before this PR, the bus service's `SharedWorker` sometimes failed
to initialized with data url. This error only occurred on some devices,
on chrome and in incognito mode.
While the specifications specify that `SharedWorker` constructor should
handle data url properly [1], there is no way to tell whether or not the
user browser supports it.
This commit solves this issue by introducing a fallback on simple `Worker`s
since they seem to handle data url correctly in this case [2].
[1] https://html.spec.whatwg.org/multipage/workers.html#dom-worker
[2] https://chromium.googlesource.com/chromium/src.git/+/9801daec162285a1f2c6695682ace5d508ea9b7f
opw-3146671
closesodoo/odoo#112921
X-original-commit: 99ac9538d6ba49161be37318fca541c7e51603f9
Signed-off-by: Stockbauer Matthieu (tsm) <tsm@odoo.com>
Before this commit, late close events were not handled properly. This
could have led to non-reconnecting websockets. The problematic scheme
is the following:
- Close the socket (eg. upon the reception of an `offline` event), let's assume that
the other end will not perform the closing handshake, the connection will be
closed once the browser presumes it is dead.
- Create a new socket (eg. upon the reception of an `online` event)
- The browser assumes the connection is dead and dispatches a `close` event,
the worker switches to the `reconnecting` state and expects an `open` event to
update its state to connected. Since there is already a running socket, the worker
won't open a new one and will never receive the `open` event.
- Server closes the connection (eg. `KEEP_ALIVE_TIMEOUT`)
- The close handler is called but since it is in the `reconnecting` state, it assumes
it shouldn't do anything thus, no reconnect attempt is made.
This PR fixed this issue by ignoring events linked to outdated sockets.
closesodoo/odoo#112456
X-original-commit: a2454739156d8742f7606f090126f32735fb15df
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Before this PR, recovering from an offline/online switch could
take up to 20mn. Indeed, WebSocket are based on TCP that uses
FIN packets to close the connection. In case of a sudden loss
of internet connection, the client is unaware of the already
dead TCP connection. It is up to the browser to assume the
connection is dead after some time.
This commit solves the issue by closing the connection properly
upon the reception of the offline event. When the client is back
online, the connection is opened again thus allowing an almost
instant recovery.
At the same time, this PR increases the default keep_alive_timeout
for websocket connections. Indeed, those re-connections lead to cursor
usage bursts and are not required so frequently.
closesodoo/odoo#111274
X-original-commit: d3a3792e5247cc41a58b47d148d4adf4fb0e4631
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Before this commit, the dbuuid was added to the session info in order
to reset the last known notification id.
This is not necessary since #103025. Indeed, if the last notification
passed to the server is superior to the last one, the last notification
default to 0.
This commit removes this information from the session info.
closesodoo/odoo#111154
X-original-commit: 80c2d32009e07bef05cce0b53221c6a8ca024fb0
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
*: calendar, im_livechat, mail.
Before this commit, the legacy session was a dependency for the bus
service. This was problematic since one would need to import a bunch
of legacy files to fulfill this dependency in order to use it.
This commit removes this dependency. In order to pass parameters to
the `bus_service`, the `bus_parameters` service is now used.
closesodoo/odoo#110247
Related: odoo/enterprise#35974
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Before this commit, the bus service would fail to initialize its worker
when loaded from a different origin than the worker script URL.
Moreover, the websocket URL was assumed to be on the same domain that
the bus service.
This PR fixes both issues:
- When the bus service is loaded from a different origin than the worker
script URL, create a data URL and use "importScripts" inside the worker
since it is not restricted to same origin scripts.
- Pass the websocketURL to the worker during its initialization.
opw-3118394
closesodoo/odoo#109701
X-original-commit: c1a480bb9ec133b9f94a5bb505380216a7f9c4ce
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Before [1], the bus was started lazily: either as a consequence of
the addition of a channel to listen to or by manually calling the
`startPolling` method.
Before this commit, the websocket would have been started as soon as
the bus service starts which degrades performances.
This PR fixes the issue by re-introducing the same mechanism as before
that is by starting the websocket either by calling manually the `start`
method of the bus service or automatically when adding a channel.
[1]: odoo#75510
closesodoo/odoo#108741
X-original-commit: 800e175c5bc5d8ba23265c69c5c2cab6957fc73a
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit fixes two things:
- The owl compatibility layer adds an `on` and `off` method on owl's
EventBus so that it can keep being used as it used to in owl 1. To do
this, it needs to keep track of the the callbacks that are attached to
it and by whom. To do this it keeps a Map where the "owners" are keys.
When calling `off` to remove event listeners, we remove the callbacks
but did not remove the owner from the Map, causing the EventBus to
always hold a strong reference to any object that was given as the owner
to the `on` method, preventing the item from being garbage collected.
Objects that do this are typically components, and components hold a
reference to their owl application that contains the entire tree of
components. This was particularly problematic in tests where components
are created and destroyed at a rapid pace.
- The mock websocket creates a MessageChannel so that it can mock the
server side of the websocket, but it never closes that MessageChannel's
MessagePorts, which can cause garbage collection to be slow to happen
[1] (in practice it looks like these are basically never garbage
collected unless closed). This commit registers a cleanup to close the
message ports after the execution of the current test.
[1]: https://html.spec.whatwg.org/dev/web-messaging.html#ports-and-garbage-collectionclosesodoo/odoo#108309
X-original-commit: 4facc396a4e8036592a473002253d5a5daf41a19
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Aaron Bohy <aab@odoo.com>
Before [1], the bus was started lazily: either as a consequence of
the addition of a channel to listen to or by manually calling the
`startPolling` method.
Before this commit, the websocket would have been started as soon as
the bus service starts which degrades performances.
This PR fixes the issue by re-introducing the same mechanism as before
that is by starting the websocket either by calling manually the `start`
method of the bus service or automatically when adding a channel.
[1]: odoo#75510
closesodoo/odoo#107878
X-original-commit: 5d7deacf54f37f0938b92a3c45c9f1d1325d1a9f
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Signed-off-by: Stockbauer Matthieu (tsm) <tsm@odoo.com>
Some of our current bus notification only insert data in the models system. We
can now simplify the way we handle them by using a generic `mail.record/insert`
handler.
closesodoo/odoo#102863
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
*: bus, calendar, hr_holidays, im_livechat, note, rating, snailmail,
website_livechat.
The mail mock server is getting bigger and bigger. As a consequence,
navigating/keeping it up to date is quiet inconvenient.
This commit solves this issue by splitting it by model/controller.
closesodoo/odoo#98374
Related: odoo/enterprise#32314
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Before this PR, a websocket would wait for the server to close
it with a `SessionExpired` close code to be refreshed after the user
logged in/out. Indeed, the server is responsible to check for outdated
sessions on incoming/outgoing messages.
This is problematic: a user logging in with more than one tab opened,
would have to wait to receive its messages. This PR solves this issue
by refreshing the connection immediately in this scenario.
closesodoo/odoo#102420
X-original-commit: 225f80882a130ae63af193adef412e6b993f2c11
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Signed-off-by: Stockbauer Matthieu (tsm) <tsm@odoo.com>
Before this commit, loosing the websocket connection would
have resulted in a toast being displayed. This toast is seen
as degrading the UX experience and is redundant with the already
existing "Connection Lost" toast. This PR removes it.
closesodoo/odoo#101501
X-original-commit: a26c8aa18ad6c4f52a4526e20d570ca1bc4123f2
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Signed-off-by: Stockbauer Matthieu (tsm) <tsm@odoo.com>
The original goal here is to remove the warning of the google page
speed but it actually is really better to use 'pagehide' as it is fired
more reliably than the 'unload' event and does not prevent Chrome and
Firefox to use the bfcache (browser optimization that enables instant
back and forward navigation).
The persisted property of the pagehide event is checked before
disconnecting from the worker. As for the presence/multi_tab case, it
was chosen to also consider page freezing as it seems more accurate that
what was done before (the main tab could be throttled/frozen which was
an issue).
Some resources to explain why this is better:
- https://web.dev/bfcache/#never-use-the-unload-event
- https://developer.mozilla.org/en-US/docs/Web/API/Window/pagehide_eventclosesodoo/odoo#101309
X-original-commit: e043891d5074ca04ee1bbed421ae5efe5f2f8b88
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Co-authored-by: qsm-odoo <qsm@odoo.com>
Debugging websockets is cumbersome, this commit adds debug
messages to the websocket worker in order to ease debugging.
closesodoo/odoo#101172
X-original-commit: 1abb6c45b06d83b602358a58f351e86b27f3f0c7
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Before this PR, the `_mockIrWebsocket__updatePresence` route of the
bus mock server could lead to errors when no im status ids were
provided. This commit fixes this issue by ensuring im status ids
were passed before calling `_mockIrWebsocket__getImStatus` method.
Moreover, old longpolling routes were still present on the bus mock
server. This commit removes these routes.
closesodoo/odoo#100583
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
*: bus, hr_holidays.
The `/bus/im_status` route polls the server every minute in order for
the user im_status to be up to date. This commit removes this poll
by sending the im_status on the bus when updating the current user
presence.
Moreover, before [1], the user bus presence was updated on each poll.
When the user didn't poll for 50 seconds, we assumed the user was
disconnected. Since [1], the bus presence is updated each 30 seconds
by the `im_status` service. This is too frequent: there is no need
to update the user presence so often.
In order not to overhelm the server with unnecessary requests, the update
presence interval as well as the delay to be considered disconnected
have been updated: the former from 30 to 60 seconds, the later from
55 to 65 seconds (assuming that a user that has missed an update
presence tick is disconnected).
[1]: odoo/odoo@a5623d2closesodoo/odoo#100249
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Before this commit, the `channels subscription after disconnect` bus
test failed randomly. This occured when the websocket reconnection
happened before the first subscription. Indeed, the first subscription
is made only if the resulting channel list differs from the last one
we sent.
This commit fixes the issue by wating for the first subscription
before disconnecting the websocket.
closesodoo/odoo#100391
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Before the websocket were introduced, the last notification id was
persisted in the local storage in order to use it even after a page
reload.
The last notification id is now stored on the `SharedWorker` which
means this information is lost if the last opened tab is reloaded.
This commit fixes this issue by storing this information by the mean of
the localStorage. Since the localStorage is not accessible from the
worker global scope, the bus service will store this information and
relay it to the worker when starting. The worker will now wait to
receive the last notification id before subscribing.
closesodoo/odoo#99621
Related: odoo/enterprise#31124
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
The `displays reconnect notification` bus test relies on a `nextTick`
to assert that a notification is present after the websocket
disconnection.
The issue is that we can't be sure that the notification will be
displayed after this tick. Indeed, we need to wait for: the `postMessage`
to reach the bus service, the notification to be added, the notification
to be added in the DOM.
This commit solves this issue, by waiting for the next render after the
`simulateConnectionLost` method to occur.
closesodoo/odoo#99590
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
* = bus, hr_holidays, test_discuss_full
- use channel member instead of partner for typing
- use channel member instead of partner for all other return values from server
- remove temporary partner hack in livechat and keep public partner
- remove some obsolete convert data
- adapt format methods accordingly
task-2664853
closesodoo/odoo#98923
Related: odoo/enterprise#30760
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
The bus test "display reconnect notification" sometimes fails because
the notification is removed before the assertion occurs. Let's block
the start method of the worker to block the reconnection until the
assertion is made.
closesodoo/odoo#99160
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
*: bus, calendar, hr_attendance, iap_mail, im_livechat, project, snailmail,
snailmail_account, survey, web, web_editor, website_livechat.
This commit is part of the websocket integration in Odoo.
This bus service now communicates with a shared worker in order to provide
a single websocket connection for multiple tabs. It is designed to
be used as a websocket except that events are slightly different,
re-connection is handled automatically. If the browser does not support shared
worker (Safari), the service fallback on a simple web worker.
Available events are:
- connect : fired upon a successful connection.
- disconnect : fired upon reception of the websocket close event.
The close code and reason are given to the listeners callback.
- reconnect : fired upon a successful re-connection.
- reconnecting : triggered when the worker starts to try reconnecting.
- notification : fired upon the reception of notifications.
Since multiple tabs are now handled by a worker, the cross_tab bus is no longer
required and has been removed.
Part-of: odoo/odoo#75510