*: 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>
* = bus, calendar, crm_livechat, hr, hr_holidays, im_livechat, mail_bot,
mass_mailing, privacy_lookup, test_discuss_full, test_mail,
test_mail_full, website_crm_livechat, website_livechat, base
In preparation of splitting discuss and mail modules.
Part of task-3265211
closesodoo/odoo#118354
Related: odoo/upgrade#4553
Related: odoo/enterprise#39661
Signed-off-by: Sébastien Theys (seb) <seb@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 PR fixes the `15350`runbot issue that was due to the
websocket subscribe not being properly awaited before logging
out.When the log out occurred before the subscribe was received,
the `odoo_ws` variable was `None`.
closesodoo/odoo#118097
X-original-commit: 59af91840c3ed7253c1c3c9dd80a4919ebdee593
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>
They dates from < 2027 and are quite outdated. Favour the nl
translation instead.
n_BE is not on Transifex so it was not possible to correct bad
translations.
closesodoo/odoo#115845
X-original-commit: d04c8b7e484db8306d858c891a7a2b11885fdcd9
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
This commit fixes the shared-worker feature detection with using the
browser object alias.
Steps to reproduce:
- Log to Odoo back-end with a device without a shared-worker support
like Chrome on an Android device => traceback
link:
https://caniuse.com/mdn-api_sharedworker
opw-3198778
closesodoo/odoo#113293
X-original-commit: 4aaafd46dbe1188bf2d9c0140a916ef664d99c42
Signed-off-by: Sébastien Theys (seb) <seb@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 commit, the bus worker would not subscribe to any channel
if the `_start` method was called before the socket was closed after
calling `_stop`. This is due to the fact that the close handler is
supposed to clean the last subscription when the socket is closed.
In this case, the handler is never called and the subscription is
considered already doned which is not the case.
closesodoo/odoo#111405
X-original-commit: 9e32c900e922674b4423407089cee58848ecdea1
Signed-off-by: Géry Debongnie <ged@odoo.com>
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>
Well it is not a typo but a mini code improvement. The suggested diff
clarifies the intent of `_handle_control_frame` with regards to
`_get_messages`. Because it was `return self._handle...` we had to read
the method to determine if it was returning something in order to know
whether the message would be propagated to the rest of the websocket
routing by `_get_message`. Now it is clear that the control frames are
handled right away and that they are not propagated to the business.
closesodoo/odoo#110834
Signed-off-by: Julien Castiaux <juc@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 keep alive timeout could occur for many websockets at
the same time resulting in a burst of transaction (cursor is open when connecting,
disconnecting a websocket).
This issue was even worse because the cursor was opened even when it was
not needed: we don't need to open a cursor if there is no callback
registered for the lifecycle event (OPEN/CLOSE).
This commit fixes those issues by:
- adding a random delay to the keep alive timeout of every websocket.
- not triggering lifecycle events if no callbacks are registered.
closesodoo/odoo#110127
X-original-commit: b4fb1359021b6c882ece3037c82aaaf65cfc2e1e
Signed-off-by: Julien Castiaux <juc@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>
Previous behavior: when debugging the websockets worker, source code is always minified.
Now, if user is in `debug=assets` mode, the asset won't be minified and it will be easier to debug.
@moduon MT-1900
closesodoo/odoo#109583
X-original-commit: 6360bbdbdcc6f2c150ceaa9f7fb5b0760e0f8940
Signed-off-by: Julien Castiaux <juc@odoo.com>
Co-authored-by: Julien Castiaux <Julien.castiaux@gmail.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>
*: base_setup, hr_timesheet, mail, partner_autocomplete, web_tour
Start odoo without -d and with a --dbfilter that allows multiple
databases. Via JSON-RPC access the /web/session/authenticate route
providing a non-filtered database and valid credentials. Traceback,
`request.env` is None.
Since httpocalypse the initialization of the ORM (cursor, registry,
environment) is greedy. It means that the connection to the database is
established very early during the request routing or skip altogether in
case no dbname was known at that time. This contrast with prepocalypse
where the various ORM thingies were lazily setup the first time they
were accessed.
This changement has an important implication regarding authentication.
In prepocalypse, thanks to the lazy approache, a cursor/registry/env
would be setup on the database you just login upon using the
`request.env` for the first time. This was very nice in this regard but
had other problems.
Since httpocalypse such operation is no more possible. Devs must
initialize and use their own cursor/registry/env in case they
authenticate on another database than the one `request.cr` is (maybe)
connected to.
The `/web/session/authenticate` controller is an example of such case.
It crates its own cr/registry/environment after authentication. The
problem the controller uses `ir.http.session_info` and that not all
overrides were updated to use `self.env` (=the env created in the web
controller) instead of `request.env` (=the missing env of the request).
closesodoo/odoo#108063
X-original-commit: 7b9bd9d37731fae724dc5d91da656dab70aa9ad4
Related: odoo/enterprise#35012
Signed-off-by: Julien Castiaux <juc@odoo.com>
*: base, account, crm, hr, hr_attendance, test_access_rights
The various public methods of the ORM can be override in other models,
those overrides sometime don't implement the exact same signature as the
original method in the ORM. In this work we sanitize all the overrides
to ensure a better compatibility. The background objective is to make it
possible to call any public method using kwarg: `search(domain=[...])`.
* `search`, the first parameter was renamed from `args` to `domain` in
0e9adf7 but the overrides were not updated.
* `invalidate_models` and `invalidate_recordset`, a new `flush=True`
parameter was introduced in 9c3b9a4 but the overrides were not
updated.
* `update`, there is a clash between the `update` method responsible for
writing on a record and `update` in bus responsible to update the user
presence. The bus method has been renamed so it doesn't clash with the
ORM.
This sanitization comes with a new linter that verifies that all
overrides of BaseModel public methods share a compatible signature. The
linter has been disabled for `create`, `write` and `default_get` as too
many overrides don't respect the signature of BaseModel.
closesodoo/odoo#106999
Related: odoo/enterprise#34991
Signed-off-by: Julien Castiaux <juc@odoo.com>
Odoo sh needs the update channel event to always come first.
This PR ensures it will always be the case.
closesodoo/odoo#107971
X-original-commit: 1f29e7bec160c1fa6930b3ee8b7753150253a7e2
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#107878
X-original-commit: 5d7deacf54f37f0938b92a3c45c9f1d1325d1a9f
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Signed-off-by: Stockbauer Matthieu (tsm) <tsm@odoo.com>
Since #106454 the `isOdooFocused` variable is not updated correctly.
This commit fixes this issue.
closesodoo/odoo#106556
X-original-commit: 0e9351e7bfda370a994a4cc38383bf7d5547dac8
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Signed-off-by: Stockbauer Matthieu (tsm) <tsm@odoo.com>
Before this PR, the presence service would crash on cross-origin
iframes. This is due to the fact that accessing the parent document
of a cross origin iframe is forbidden for security concerns.
This error was introduced when trying to synchronize the website iframe
and the window focus state in #102479.
This PR fixes the issue by catching the error and fallbacking to the old
behavior given than task-3006023 has been fixed by #53143 anyway.
task-3073242
closesodoo/odoo#106499
X-original-commit: 7210c50df89dce68a554c6d685c33ce74e09d30c
Signed-off-by: Stockbauer Matthieu (tsm) <tsm@odoo.com>
Since the iOS 16.1 update, the WKWebView used in the iOS mobile app
crashes when trying to instanciate a `SharedWorker`... even if this
feature was newly added in iOS 16.0.
Safari iOS doesn't seem to be impacted.
This commit works around this issue by disabling the usage of the
`SharedWorker` in the iOS mobile app, using instead the existing
fallback to a regular `Worker`.
Steps to reproduce:
- On a device running iOS 16.1
- Open Odoo in the iOS mobile app
=> Once connected the app freezes with a gray screen
opw-3045539
closesodoo/odoo#104459
X-original-commit: afac382bd711b1a506629742456d91526cc52c53
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
Signed-off-by: Pierre Paridans (app) <app@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>
Before this PR, the last notification id known by the client
was not reset after restoring the database. This was an issue
since there can be a gap between the last notification and the
one that has been restored with the database. In this scenario,
messages are not received after restoring the database since the
client subscribes to higher notification ids that the ones that are
created.
This PR fixes this issue by defaulting to 0 if the one the client
passed is higher.
closesodoo/odoo#103311
X-original-commit: 5118da53a6e9adb94577a4f16999522a7e1e8c10
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Signed-off-by: Stockbauer Matthieu (tsm) <tsm@odoo.com>
The `ImDispatch` thread uses the `thread.is_alive` method to check
whether or not the thread should be started. The issue is that, this
method will return `False` after the start method has been called, but
before the run method is invoked leading to the RuntimeError: thread
can only be started once.
This commit fixes this issue by suppressing this error in this case.
closesodoo/odoo#103157
X-original-commit: daded0125a4ec2421b9e817aaaa725da2fd96a20
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Signed-off-by: Stockbauer Matthieu (tsm) <tsm@odoo.com>
Using patcher.start() can easily lead to incorrect cleanup.
-> after a copy paste, patcher is working, but stop is forgotten
-> stop is present, but won't be called if something fails during the
test
This commit add an utility `start(patcher)` to always have the add
cleanup.
Using a standard way to start the patcher with an automated addCleanup
should prevent this kind of mistake. This is why this commit also
replaces all valid patch.start() (followed immediately by a addCleanup)
closesodoo/odoo#102873
X-original-commit: 7d5a193d86316965a0908c65cfacfb607dc3f3ad
Related: odoo/enterprise#32618
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
Before this PR, the presence service was relying on window events
blur/focus to determine whether or not odoo was focused. The issue is
that in the website backend, an iframe is used. When this iframe is focused,
the window looses the focus and vice versa.
This commit fixes this issue by using `window.parent.hasFocus` method.
task-3003950
closesodoo/odoo#102518
X-original-commit: ce57d4494f2bc6a1504f8a7bddddca2a3d2b794b
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Before this commit, the `updateBusPresence` method could have been
called many times in a row, resulting in many `update_presence` messages
being sent through the socket. This commit solves this issue by throttling
this method in order for it to only be called once in `UPDATE_BUS_PRESENCE_DELAY`
seconds.
closesodoo/odoo#102442
X-original-commit: 0b581f5af509040928babf0e892732c0f4c873e5
Signed-off-by: Sébastien Theys (seb) <seb@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>
The session used to call this websocket route needs to have been
initiated with a call to /websocket/peek_notifications first.
closesodoo/odoo#102009
X-original-commit: 49aa391b4ef93b2de578c73a1fe852cea32abb43
Signed-off-by: Julien Castiaux <juc@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>
Since [1] when the bus service was adapted to wowl, the assets watchdog
service was imported in the frontend. Because the assets will be the
right ones on the next visited page, the notification it might trigger
is seen as degrading the website UX.
This commit removes the assets watchdog service from the frontend
pages.
Steps to reproduce:
- Visit a public page in a tab - keep it open.
- From a different browser, log in and rebuild assets.
=> Notification appears in visitor's tab.
[1]: https://github.com/odoo/odoo/commit/3ae11c87e8a395219229416c2777bcdcdacd08ac
task-2922959
closesodoo/odoo#101186
X-original-commit: d2efe6220281c00a9a6be154113ff20c0745dde6
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
The `bus_service` uses the `dbuuid` key from session in order to
know when to drop the last notification id from the local storage:
when the db changes.
The issue is that public pages don't fetch the session, this results
in undefined being added into the local storage. The multi tab service
speculates on the fact that the value stored will always be json
parsable.
This commit fixes the issue by taking into account the fact that session
dbuuid can be undefined. Moreover, the multi tab service has been
updated to return the raw value if it is not parsable.
closesodoo/odoo#100897
X-original-commit: ed992ed03456eac6be5fb802578fcc1a0fc7a732
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Signed-off-by: Stockbauer Matthieu (tsm) <tsm@odoo.com>