Commit Graph
109 Commits
Author SHA1 Message Date
tsm-odoo 29bd02e9b8 [FIX] bus: fix im status service listeners
The im status service subscribes to the `become_main_tab`,
`no_longer_main_tab` events.

Since the PR improving the multi tab service, the multi tab
itself is not an event target anymore but exposes a bus instance
that should be used to subscribe to those events.

The im status service is still based on the first version (that was
using env.bus) which means the event will never be received. This
commit fixes this issue.

closes odoo/odoo#99635

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-09-07 02:17:50 +02:00
tsm-odoo 65a9e730b0 [FIX] bus: fix display reconnect notification test
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.

closes odoo/odoo#99590

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-09-06 10:58:28 +02:00
tsm-odoo 58eade9f34 [FIX] bus: bus message dispatching
Before the websockets were introduced, longpolling coroutines were
sleeping until postgres notify. Each coroutine was then wake up and
notifications were fetched.

Since the websocket introduction, the main loop, responsible for listening
to postgres sends the notifications itself. This means, the postgres loop
is blocked during message fetch/dispatching and notifications are dispatched
in a sequential fashion resulting in a slow message dispatching.

In order to solve this issue, websocket coroutines are now responsible to
fetch/dispatch notifications, letting the main loop free to relay notifications
as they come and allowing notifications to be sent simultaneously.

When instructed to dispatch available notifications, the websocket coroutines
will try to acquire a cursor. Each coroutine will try up to `MAX_TRY_ON_POOL_ERROR`
times, sleeping between each try. If no cursor can be acquired, the connection is
closed with the TRY_LATER` close code.

closes odoo/odoo#98880

Signed-off-by: Antony Lesuisse <al@odoo.com>
2022-09-05 14:50:17 +02:00
Sébastien Theys 545d23888b [IMP] mail, im_livechat, *: add typing for guest and clean code
* = 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

closes odoo/odoo#98923

Related: odoo/enterprise#30760
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2022-09-01 20:21:58 +02:00
Matthieu Stockbauer 39615e3bab [FIX] bus: fix display reconnect notif test
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.

closes odoo/odoo#99160

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2022-08-29 18:40:11 +02:00
Matthieu Stockbauer fe699a241d [IMP] *: adapt client code to use websocket instead of longpolling
*: 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
2022-08-23 17:55:10 +02:00
Zelong Lin 7be59d6603 [IMP] mail: add group_public_id into mock setup
task-2957108

closes odoo/odoo#98378

Related: odoo/enterprise#30582
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-08-18 21:09:12 +02:00
tsm-odoo 15eda2d7cf [IMP] bus: prepare bus tests for websocket introduction
The bus tests rely to heavily on the underlying technology (polling).
In order to keep the test intact in the PR introducing the websockets
in Odoo, let's convert the test to be less technical.

task-2053917

closes odoo/odoo#97975

Related: odoo/enterprise#30360
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-08-12 23:37:39 +02:00
tsm-odoo 9d86827840 [IMP] bus, *: only use one mock server during tests
*: mail, web.

The pyEnv used during tests is based on the mock server to provide
server like api. This issue is that when creating multiple environments
during tests, a new mock server is created each time. This is not realistic
since in a real world scenario, multiple tabs would share a single server.
In order to make pyEnv work with multiple tabs tests (e.g. multiple env tests),
let's create a single mock server shared between js environment during a test.

task-2053917

Part-of: odoo/odoo#97975
2022-08-12 23:37:38 +02:00
tsm-odoo 1766c6997a [FIX] bus, mail: fix model definitions setup moved in wrong module
The model_definition_setup has been moved in [1] but adds some models
to be fetched that are not related to the bus module. This would lead
to error in single module builds.

closes odoo/odoo#97937

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-08-11 17:57:02 +02:00
tsm-odoo d5234c314e [IMP] bus, calendar: remove longpolling polls in tests
In order to prepare the ground/reduce the noise in the PR
introducing the websockets in Odoo, the mocks of the longpolling
route in tests is replaced by calls to sendone/sendmany.
This will allow to keep the same code while changing the underlying
technology.

task-2053917

closes odoo/odoo#97771

Related: odoo/enterprise#30244
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-08-10 14:43:41 +02:00
tsm-odoo 75007b578e [MOV] bus, *: move startServer test helper to the bus module
*: calendar, hr, hr_holidays, im_livechat, note, rating, snailmail,
test_mail, test_mail_full, website_livechat, website_slides.

Part-of: odoo/odoo#97771
2022-08-10 14:43:41 +02:00
tsm-odoo d952fbcb96 [IMP] bus: move sendNotification to mail module
The BusService class only adds the possibilty to send notifications.
This is only used in the mail module. Let's remove this unnecessary
override and move this functionnality into mail models.

closes odoo/odoo#97685

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-08-09 06:28:00 +02:00
tsm-odoo d998c54feb [FIX] mail, bus: fix mock sendone/many crash during tests
The mock of sendone/many was relying on the bus_service. Since owl.Component.env
is changing during tests setup, the bus_service was not always defined. In order
to make this more reliable, the longpolling/poll route is now mocked, returning a
promise that can be resolved by the sendone/many methods.

closes odoo/odoo#97298

Related: odoo/enterprise#30059
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2022-08-05 16:35:45 +02:00
8f2c15a719 [FIX] bus: poll different channels in different tabs
Commit b743fda doesn't seem to work properly.
Steps to reproduce:
- Open a spreadsheet A in one tab
- Open a spreadsheet B in another tab
=> the master tab should poll both spreadsheet channels but it
does not.

The condition here sheems wrong
https://github.com/odoo/odoo/blob/bf2ce0aa0c7d45c90d7ff104d5af5f99b29d59ae/addons/bus/static/src/js/crosstab_bus.js#L299
`peerChannelsBefore` is not really "before the channel was added".
It's "before outdated channels are cleared".
It already contains the new channel added to local storage by the slave tab!
Hence it wrongly returns `false` which means the poll request is not
restarted.

Additional fix required since e2aeb5f
-------------------------------------

Commit e2aeb5f broke a little more the feature.
It is assumed the ids in `channels` are matching the ids in `lastPresenceByTab`
(previously named `peers`). It was no longer true since `lastPresenceByTab`
is now managed by multi_tab service (with it's own id).
With those non-matching ids, channels from other tabs were always considered
outdated and therefore cleaned up.

Small comment on the change in the mock server
----------------------------------------------

Cross tab bus tests were not working properly.
The error message string "XmlHttpRequestError abort" was stringified
(stringifying a string), leading to "\"XmlHttpRequestError abort\"". Since the
implementation depends on the exact error message, tests didn't propely
reflect reality.
This is technically not needed anymore since bus tests are no longer using
the legacy mock server but it can't hurt to fix it. (the new mock server
doesn't have this issue)

closes odoo/odoo#97036

X-original-commit: f25f36a
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Co-authored-by: Goaman <nby@odoo.com>
Co-authored-by: tsm-odoo <tsm@odoo.com>
2022-08-03 13:45:02 +02:00
Lucas Lefèvreandtsm-odoo 3f60066283 [FIX] bus: stop listening when tab unloads
When a tab is closed (unloads), the main tab is still considered the main tab
and event listeners are not properly removed.

In practice, it's probably not an issue because the tab is killed by the browser,
but it could still potentially have unexpected and undesired side effects.
It's safer to clean everything properly.

The issue is much more visible in tests because the mutli_tab and bus services
are still "active" after we simulated a tab unload.

Part-of: odoo/odoo#97036
Co-authored-by: tsm-odoo <tsm@odoo.com>
2022-08-03 13:45:02 +02:00
tsm-odoo 71d5af4ce0 [FIX] bus, *: fix onNotification/offNotification
*: im_livechat, snailmail_account, survey, web_editor.

The callback registered by the bus service method onNotification was
not the same unregistered by offNotification. Since those method were
superfluous, they have been removed in favor of (add/remove)EventListener.

closes odoo/odoo#96684

Related: odoo/enterprise#29819
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-07-27 16:34:10 +02:00
tsm-odoo 901a43f532 [IMP] bus, *: improve multi tab service
*: calendar, im_livechat, survey.

Following @ged-odoo review, the multi tab service has been improved:
    - multi_tab_service.js has been moved to the correct location.
    - _callLocalStorage method has been removed and replaced by
      getItemFromLocalStorage/setItemToLocalStorage.
    - underscore.js calls have been removed.
    - multi_tab_service is now using function closure style  instead of class.
    - multi_tab service is now using its own bus instance.
    - service name is now in snake case as per convention.
    - tests have been added.
    - multi tab service now handles setting/removing/getting values
      shared between  all the tabs.

closes odoo/odoo#96386

Enterprise: https://github.com/odoo/enterprise/pull/29694
Related: odoo/enterprise#29694
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2022-07-27 03:34:51 +02:00
tsm-odoo e2aeb5fc23 [IMP] bus, *: introduce multi tab service
*: calendar, survey.

In order to ease the PR introducing websockets in Odoo, introduce
the multi service. Indeed, the cross tab bus won't be necessary
anymore but there will still be a need to elect a main tab: some actions
should only be triggered once. To achieve this, the code electing the main
tab has been split with the one handling the longpolling. The crosstab
bus now relies on the multi tab service to known whether or not the
current tab is the main tab.

task-2053917

closes odoo/odoo#96174

Related: odoo/enterprise#29573
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-07-18 19:55:13 +02:00
tsm-odoo 3b9a90e14f [IMP] bus: replace on/off by (add/remove)EventListener
on/off are deprecated in favor of  addEventListener/removeEventListener.
Calls to the bus service have been updated to reflect those changes.

task-2053917

closes odoo/odoo#96017

Related: odoo/enterprise#29501
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-07-18 18:41:33 +02:00
tsm-odoo 7821fdd957 [IMP] bus: introduce presence service
The code handling user presence and the one handling bus notifications
are mixed up. In order to ease the PR introducing the websocket in Odoo
and to clear this mess, the presence service has been introduced.

task-2053917

closes odoo/odoo#95981

Related: odoo/enterprise#29524
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-07-15 19:15:54 +02:00
tsm-odoo 27b472e5ed [IMP] bus, *: remove obsolete web_client_ready when using bus
*: calendar, iap_mail.

Now that the bus service is a wowl service, we don't need to wait for
the webclient to be ready before using it. Indeed, the services now
have the bus service as a dependency which means it will always be ready
in time. This also showed that the rpc service was missing as a bus service
dependency. It has been added.

Some part of the code were also checking if the bus service was in
`env.services`. Those calls have been removed as well since we now
have the guarantee that it is.

closes odoo/odoo#96002

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-07-14 16:42:19 +02:00
Matthieu Stockbauer 3ae11c87e8 [IMP] mail, *: adapt bus service to wowl env.
*: bus, calendar, iap_mail, im_livechat, project, web.

In order to ease the PR introducing the websockets in Odoo, the bus service
has to be updated to be a wowl service. This PR takes care of it.

task-2053917

closes odoo/odoo#95824

Related: odoo/enterprise#29361
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-07-14 11:42:42 +02:00
tsm-odoo 3573a7fef4 [IMP] mail, *: use wowlEnv instead of the legacy one
*: bus, calendar, hr, hr_holidays, im_livechat, mail, mail_bot, note, project,
sms, snailmail, test_mail, web, website_livechat, website_slides.

task-2582313

closes odoo/odoo#83774

Related: odoo/enterprise#26493
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-05-30 19:40:53 +02:00
+2 318cdcc0b8 [REF] *: adapt code to owl 2
Owl 2 changelog: https://github.com/odoo/owl/blob/a9f29c4caad4f32d06be1ec4780572825781cd9b/CHANGELOG.md

Part-of: odoo/odoo#80156
Co-authored-by: Aaron Bohy <aab@odoo.com>
Co-authored-by: Bruno Boi <boi@odoo.com>
Co-authored-by: Géry Debongnie <ged@odoo.com>
Co-authored-by: Samuel Degueldre <sad@odoo.com>
Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Co-authored-by: Simon Genin (ges) <ges@odoo.com>
Co-authored-by: Francois (fge) <fge@odoo.com>
Co-authored-by: Michael Mattiello (mcm) <mcm@odoo.com>
Co-authored-by: Julien Mougenot <jum@odoo.com>
Co-authored-by: luvi <luvi@odoo.com>
Co-authored-by: Lucas Perais (lpe) <lpe@odoo.com>
Co-authored-by: Jorge Pinna Puissant <jpp@odoo.com>
2022-02-10 07:46:13 +00:00
Julien Mougenot db63ff2259 [REF] web: Owl imports adaptation
In the next version of Owl, all exported terms are directly available
from the top level `owl` object. This commit aims to adapt existing
imports to this new system. This is done by importing any Owl property
used in files at the top, right after the `import` or `require`
statements.

closes odoo/odoo#82736

Related: odoo/enterprise#23609
Signed-off-by: Géry Debongnie <ged@odoo.com>
2022-01-20 11:03:01 +00:00
Julien Mougenot 65d70acdbf [FIX] base,bus: Notify bundle change on version change
Before this commit: a notification asking to reload the current window
appeared as soon as the server detected a change in one of the assets
bundles, even on first load.

To fix this problem and make the feature more meaningful, it has been
decided to only notify the client when the server version (not the
bundle version) is outdated (i.e. on database upgrades, when the changes
in the code are actually relevant).

closes odoo/odoo#82032

X-original-commit: a3b5a9d715be6a93c7f2859074b916f3249f97c3
Signed-off-by: Antony Lesuisse <al@odoo.com>
Signed-off-by: Julien Mougenot (jum) <jum@odoo.com>
2022-01-04 10:26:10 +00:00
Didier (did) 1afcc9c368 [IMP] bus, mail, *: improve longpolling bus notification format
* = auth_signup, calendar, im_livechat, snailmail_account, survey, test_mail,
    web_editor, website_crm_iap_reveal, website_livechat

The aim of this PR is to improve/fix various flaws and limitation of the current
API, to make it easier to use and more efficient.

Notification are now defined with 3 distinct parts:

- the channel determines which client(s) should receive it
- the type determines how it should be handled
- the payload determines any extra information helpful for handling it

Channel
=======

Business code
-------------

- Record channel is introduced for ease of subscribing to and sending
  notifications to specific partners, channels, documents, ...
- String channel is still supported (but it is converted internally to the tuple
  channel).
- Tuple channel is still supported without any change (but should be avoided
  whenever possible due to its complex syntax).

The channel is no longer sent to the client. When the channel was used for
business purpose, the information it contained has been moved into either the
new type, or the payload itself.

Technical note
--------------

All channels are now internally converted to the tuple (db, ...) channel, which
is necessary for the platform code (saas/sh).

Internally, the bus.bus table is not changed, type and payload are grouped
together into what was (and still is) called message.

Type
====

Type is introduced to uniformize the way notifications are sent and handled.
All existing notifications already had some kind of manually-built type in them.
This is now officially supported at the bus API.

In client code this will allow (to be done in future commits) to register one
handler per specific type, instead of having to iterate and to filter all
received notifications on every handler.

Payload
=======

Payload (ex message) did not change, it can still be anything depending on
business needs.

Few adaptations:
- When the type was included on the payload, the type has been moved to the new
  type parameter.
- When the channel was used in business code, its data has been copied into the
  payload.

task-1891151

closes odoo/odoo#79201

X-original-commit: 543af27c7d6836ffac9e80ff8490b6ddbd849221
Related: odoo/enterprise#21998
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2021-10-29 16:05:23 +00:00
Nicolas Bayet b743fda90d [IMP] bus: allow tabs to have differents channels
This commit prepares the ground for the collaborative feature.

Before this commit, it was impossible to have different channels for
each tabs. In collaboration, multiples tabs could listen to differents set
of channels.

Example:
One tab X could be subscribed to channel [a, b] and tab Y on channel
[a, b] and a tab Z on [a, c].

Before this commit, only the channels of the master tab were
listened. So in this case it was either [a, b] or [a, c] depending on
which tab is the master.

So either channel b or channel c were not listened depending on which tab
is the master.

Now, each time a tab listens or stops listens to a channel, the
master tab listen all channels for all tabs.

task-2497931
odoo pr: 75768

Part-of: odoo/odoo#75768
2021-09-06 19:42:56 +00:00
Samuel Degueldre 5ffdd92034 [FIX] web: make polling restart correctly when server is killed
Previously, when killing the server, the longpolling bus stopped but
didn't start polling again after a few seconds, this was caused by the
fact that ConnectionLostError wasn't treated like a legacy error and
remapped to an object with a message, meaning it didn't trigger
guardedCatch callbacks.

Since ConnectionLostErrors should be handled much the same way as
RPCError when interacting with legacy code this commit simply adds
ConnectionLostError in the same places we already have RPCError during
error handling of legacy errors, but delegates behaviour to the new
lostConnectionHandler when appropriate.

closes odoo/odoo#74530

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2021-08-02 11:45:55 +00:00
Xavier Morel 32062a3bbb [FIX] board, bus, web: replace deprecated test-utils calls
A number of functions from `web.test_utils` have been deprecated at
the module root and should be called through submodules.

Fix a bunch of remaining cases. Also add a few missing `await`s on
`triggerMouseEvent` calls. Don't bother rewriting the imports in
unpacking style as for most updating the imports is unnecessary. Do so
for `field_one2many_tests.js` where we have to rewrite the imports
anyway:

* recursively import controlPanel, createView, mock.patch and
  mock.unpatch
* remove the aliasing of controlPanel to cpHelpers
2021-06-29 05:34:17 +00:00
Lucas Perais (lpe) 694e3f5904 [REF] web: services register their own component
Some services are coupled with a Component. Usually the service
handles the state of the system, and the Component displays or uses it.

To enable the communication between the service and the component
while making it private, the services should add themselves their
Component in the relevant registry, with the proper means of communication
passed in props.

This mechanism relies on c1d49d494e0ae3a94b3943186eb6d1ebd7b98a6e
2021-06-18 21:31:33 +02:00
Michael Mattiello (mcm) 41e5435d97 [REF] web, *: refactor notification service
* bus, calendar

This commit changes the notification API and adapts codes that use it
Notification API before:
    - create(...): number
    - close(id: number, wait?: number)

Notification API now:
    - add(...): RemoveCallback

closes odoo-dev/odoo#908

Related: odoo-dev/enterprise#158
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-06-18 21:31:30 +02:00
Aaron Bohy a5091fee99 [REF] *: rework webclient test helpers
This commit splits the 'getActionManagerTestConfig' helper into 2:
'setupWebClientServiceRegistry' and 'getActionManagerServerData'.

The first one is now automatically called by the 'createWebClient'
helper, as it properly setups the service registry with all services
required by the WebClient component.

The second one generates a few data (menus, actions, views...) that
can be used in tests. That helper is mainly useful for action tests
(formerly ActionManager tests) in web. With this refactoring, they
are no longer generated for each test in the whole codebase that
spawns a webclient, as before this commit.

closes odoo-dev/odoo#906

Related: odoo-dev/enterprise#161
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-06-18 21:31:30 +02:00
Géry Debongnie 1b549bddd1 [REF] web: improve main_component registry API to accept props
closes odoo-dev/odoo#910

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-18 21:31:30 +02:00
+1 14bffd983e [REF] *: adapt code to new owl webclient
This commit adapts the community codebase to the rewriting of the
/web application in owl.

Co-authored-by: Aaron Bohy <aab@odoo.com>
Co-authored-by: Bruno Boi <boi@odoo.com>
Co-authored-by: Géry Debongnie <ged@odoo.com>
Co-authored-by: Samuel Degueldre <sad@odoo.com>
Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Co-authored-by: Simon Genin (ges) <ges@odoo.com>
Co-authored-by: Francois (fge) <fge@odoo.com>
Co-authored-by: Michael Mattiello (mcm) <mcm@odoo.com>
Co-authored-by: Julien Mougenot <jum@odoo.com>
Co-authored-by: Lucas Perais (lpe) <lpe@odoo.com>
Co-authored-by: Jorge Pinna Puissant <jpp@odoo.com>
2021-06-18 21:31:27 +02:00
Sébastien Theys c6716847aa [IMP] web, *: clean up notification API
task-2476867

closes odoo/odoo#67009

Related: odoo/enterprise#16760
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2021-05-27 13:47:23 +00:00
Aaron Bohy 31fcd5a0f1 [FIX] bus: prevent longpoll requests storm
Before this commit, it might happen that, in some situations,
with several tabs opened, the CrossTabBus called the longpolling
route repeatedly, thus slowing down the server, and freezing the
webclient.

The issue was tricky to reproduce. It was a race-condition that
could occur when several tabs performed simultanous calls to
addChannel, while being unloaded or becoming mastertab in the
meantime (e.g. when opening/closing/refreshing several tabs
simultaneously).

This issue has been introduced by [1] which by mistake (probably)
made each tab calling itself the localStorage to update the list
of channels when it was notified that the list of channels in
the localStorage just changed. So if several tabs had a slightly
different list of channels at a given moment (e.g. at startup),
it might happen that they in turn, undo what another tab just
put in the localStorage, and thus produced an infinite loop of
localStorage writes and longpolling request aborts/calls.

The issue could be reproduced with the OCA module [2], which
performs several addChannel at webclient startup.

This commit restores this part of the code as it was initially
written in [3].

Closes #69067

opw~2502799
maybe opw~2451865 as well

[1] https://github.com/odoo/odoo/commit/6448420
[2] https://odoo-community.org/shop/product/web-notify-2670#attr=10773
[3] https://github.com/odoo/odoo/commit/38581f67236377daa767ca2216529a26b8708b00#diff-f6eccad21ae3543606ab8f97b8b097d015412caeaee2bf8cc928eb3ccabac9f5R149

closes odoo/odoo#69777

X-original-commit: a52aa41d04330efb81090409ec7fbcbbedaca317
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-04-23 15:38:17 +00:00
8cc066173d [IMP] *: Improve assets management
This commit changes the way assets are declared in Odoo modules.

Before: assets were declared in template files. Template bundles were
generated from primary templates, so technically any qweb template could
have been called as an asset bundle, with the 't-call-assets' directive.

Being standard qweb templates, they had access to standard HTML tags
(script, link, with or without raw scripts or style definition), qweb
directives (t-call, t-raw, etc.) and could be inherited by other
templates.

Now: assets are defined in the module's manifest and generated by the
't-call-assets' directive.

More information on the new system can be found on the updated user
documentation (see the "JavaScript Reference" section).

Task: 2352566

Co-authored-by: Bruno Boi <boi@odoo.com>
Co-authored-by: Julien Mougenot <jum@odoo.com>
Co-authored-by: Lucas Perais <lpe@odoo.com>
Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Co-authored-by: Raphael Collet <rco@odoo.com>
Co-authored-by: Simon Genin <ges@odoo.com>
2021-03-31 13:57:17 +02:00
Ipsita Borisagar 4299d2233c [IMP] bus,mail: improve discuss notification design
PURPOSE

Discuss notification needs to be changed for better UI.

SPECIFICATION

Improving design of discuss notification by using bg-info instead of bg-warning.

LINKS

PR https://github.com/odoo/odoo/pull/55542
Task-2308799

closes odoo/odoo#55542

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2020-12-10 15:20:45 +00:00
Lucas Perais (lpe) 9708c6e992 [IMP] bus: notify user when assets have changed
Use case:
When the server is restarted, the python is updated,
but some users may have an ongoing session in a browser tab
This may lead to code being unsynchronized and ultimately to some
odd bugs.

Purpose:
When we are in such a case, that is, the assets were recomputed
after a update of the code and a restart of the server by the request of another user,
notify connected users that assets have changed.
Then propose them to reload the page.

Known caveats:
- This is not a developer's feature.
Since assets computing is ORM cached, they have limited
opportunities to rebuild. Namely, the feature won't trigger
each time the JS has changed, rather, it will
when JS has changed AND the cache has been reset somehow (e.g. when the server is restarted).

- This not a portal/website feature either, but only in backend.
Business clients won't be notified that the JS has changed.

- While requests debug=assets do trigger a recomputing
of the *components* of bundles, they do not save a bundle
This means that the requests that sends the notification
cannot be debug=assets.

Task 2034462

closes odoo/odoo#39875

Signed-off-by: Mathieu Duckerts-Antoine <Polymorphe57@users.noreply.github.com>
2020-08-21 12:16:25 +00:00
Aaron Bohy b4ba0fc340 [FIX] *: adapt tests to env rework
This commit adapts tests following recent changes on the helpers.
The main change is that addMockEnvironment (and all functions using
it) are now async, as they need to wait for services to be started.
2020-06-12 09:47:48 +00:00
Aaron Bohy 26fe23201b [IMP] web,*: properly define env in the frontend
*bus,mail

This commit extracts the common basis of the env to use both in
the frontend and the backend. The public env now contains most of
the features that were previously (only) in the webclient env.

Moreover, the PublicRoot no longer uses the ServiceProviderMixin,
such that services are only deployed once, in the (public) env.

Owl components can now be defined in the website, and rely on a
properly built env. Legacy widgets still works as they access
services through the PublicRoot (via trigger_up) which redirects
those requests to the env.
2020-06-12 08:04:14 +00:00
Romeo Fragomeli ee7e75d74b [FIX] bus: Notification not usable in Chrome Android
Before this commit, the Notification is used but in Chrome Mobile
we can't use it outside a ServiceWorker.

After this commit, if the Notification Object produce
an error it will fallback to the old method do_notify()

Steps to reproduce:
* Open a Odoo instance with Chrome Mobile (e.g. with Demo user)
* In Chrome Mobile, accept to receive the "Native Browser Notification"
* Put Chrome Mobile in the background of Android (don't close it)
* Open another instance of the same Odoo somewhere else with another user (e.g. Admin)
* From Admin, send a direct message to Demo
* Resume Chrome Mobile to the foreground the you will see the traceback (BUG)

GitHub issue: odoo/odoo#34714

Ref:
https://bugs.chromium.org/p/chromium/issues/detail?id=481856

closes odoo/odoo#51474

X-original-commit: ebe6731c583f9f4125272af3d8bdc4625e06de7c
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
Signed-off-by: rfr-odoo <rfr-odoo@users.noreply.github.com>
2020-05-18 15:12:34 +00:00
Sébastien Theys b59a77844e [FIX] bus: restart poll just after abort
Fix regression introduced with e0ed7b12ca

Issue without current commit:

When doing `abort` next updates from the bus are only received after the normal
timeout, which makes the interface unresponsive to updates during that amount of
time.

`abort` is for example called during `addChannel`, where it is specifically
documented that new updates are to be received immediately.

closes odoo/odoo#49355

X-original-commit: 888610e5e07794e000ef27edcb075cb45c1e2ccc
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2020-04-09 17:03:09 +00:00
Martin Trigaux d11ee78019 [IMP] bus: unescape notification message
The title of notification is the author name escaped (for security
reasons).

   if (message.hasAuthor()) {
       title = _.escape(message.getAuthorName());
   }

When forwarded to the system notification, it does not need to be
escaped though, as the system notification is not HTML based.

Without this patch, a user named "Bob's friend" sending a message was
creating a notification with the title "Bob&#x27;s friend"

Unescaping the notification body just in case but the HTML of the body
in a mail.messages should be stripped by _notifyIncomingMessage.
Unescaping will just ignored unescaped characters and should do
nothing on messages not escaped.

Fixes odoo/odoo#24846

closes odoo/odoo#44550

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-02-04 10:33:19 +00:00
Xavier Morel 0198c3e05d [IMP] core: reporting of browser logs / errors during setup
Sink handling of JS logging, exceptions and websocket timeouts so
calls other than _wait_code_ok handle them somewhat properly: the
issue fixed by odoo/odoo#41231 passed because it occurred during
module loading, which happens during initial page loading (browser_js
> navigate_to > _websocket_wait_event), which ignored logs (and
exceptions though here it's a console.error log), and as a result
reported no failure (and would simply miss that specific test as well
as every test following it).

Also since ChromeBrowser treats console.error as an exception,
important messages should be logged atomically. Merge two consecutive
console.error into a single one at the loading of modules so we don't
just get an exception "error while loading foo.bar" without any of the
useful details.

That ChromeBrowser treats console.error as exception is also why the
new method gets a flag (to suppress this behaviour): in the case of
two console.error, upon encountering the first it's treated as an
error so we try to take a screenshot, which goes through the messages
in order to get the screenshot response, which encounters the second
console.error, which gets treated as an exception, which hides the
first error.

Instead, screenshotting (and more generally _websocket_wait_id) should
treat console.error as a regular logging call, probably.

Also run JS tests in debug=assets for easier debugging (ha!) and
improve formatting of exception object when receiving an exception:
* if we can get a description on an `exception` remote object just
  print that, it's formatted to show the exception type, message &
  traceback
* otherwise format the garbage that is an "ExceptionDetails" object
2020-01-21 06:55:32 +00:00
Alexandre Kühn 6245ed2bce [FIX] bus, mail: navigate from tests with mocked bus services
Before this commit, when navigating from test environment (e.g.
page reload), it crashed with following error:

`TypeError: Cannot convert undefined or null to object`

This error comes from mocked bus services in tests: even when they
have been destroyed, they handle the window event 'unload'. They
no longer have a parented parent, so `this.call()` returns
`undefined`, hence the crash.

This commit prevents mocked bus services to listen on window 'unload'
event. Tests must always simulate this window event by explicitly
calling the handler.

closes odoo/odoo#41378

X-original-commit: fd08d04f0a24fea52e7b668b90aec48b33d349a3
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2019-12-04 14:46:28 +00:00
Olivier Donyand@alexkuhn ae82f17cc9 [FIX] bus,im_support: adapt im_support to bus changes
The im_support module was broken in 12.0 after bus refactorings between
11.0 and 12.0.

closes odoo/odoo#38838

X-original-commit: db37e0cedcd0da46bd57686a076a8165e60d6c3b
Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
Co-authored-by: @alexkuhn
2019-10-15 17:43:19 +00:00
GabbasovDinar efcf137867 [IMP] binding of context (this) to an object
closes odoo/odoo#37893

X-original-commit: fb3522b54903b19aa42cb3fe23e1a029b4ccfc14
Signed-off-by: Romain Libert (rli) <rli@odoo.com>
2019-10-03 13:53:22 +00:00