diff options
| author | Xavier Morel <xmo@odoo.com> | 2021-04-27 11:55:02 +0000 |
|---|---|---|
| committer | Xavier Morel <xmo@odoo.com> | 2021-04-28 06:49:26 +0000 |
| commit | a5b2146404da9ea0cd4752a21dcd230140822c86 (patch) | |
| tree | e2b716a319dc1ba6580ecd25e9fc1fc0f23a4fd8 /addons/web/static/src/js/chrome/menu.js | |
| parent | a8c952fe477d22f5a88696df44e63faca13cba06 (diff) | |
[FIX] web: web client boot when user has not apps available
This mostly an issue when trying to run just the tests of `web` (aka
`-iweb`) with only community modules available,
`TestMenusDemoLight.test_01_click_apps_menus_as_demo`, wait for the
ready code times out:
AssertionError: False is not true : The ready "odoo.isReady === true" code was always falsy
and the test suite fails.
The ready code simply checks that `odoo.isReady` is set. The web
client sets `isReady` when `webclient_started` is
triggered (specifically in `_onWebClientStarted`, which is the handler
for that event).
[The community web client only triggers `webclient_started` at the end
of `doAction`][0] meaning the community client is considered ready
until after the first action has executed.
[The first action is executed by `show_application`][1] whose process
is the following:
1. load and initialize the menus
2. if an action is specified in the URL, run that
3. otherwise if the user has a home action, run that
4. otherwise run the first menu's action
When installing only `web`, the only menus which could be available
are Apps and Settings, and the demo user has access to neither. This
means the demo user has no applications, and opening the first app is
a no-op ([`openFirstApp` has a case just for that situation to ensure
it does nothing][2]). As a result, `webclient_started` is never
triggered, `_onWebClientStarted` is never called, `odoo.isReady` is
never set, and the tour never runs.
Fix by updating `openFirstApp` to return *whether* it opened an
application, and in `show_application` the last fallback if even
opening the first application failed is to just declare the web client
ready.
While at it, rewrite `show_application` using ES6 facilities and
flatten and linearize it using guards. This means the code pretty much
tracks the process described above, with one step added:
5. otherwise complete the webclient's startup
[0]: https://github.com/odoo/odoo/blob/1eb474243b55f1b9e10c70d199bbe022e68b51d0/addons/web/static/src/js/chrome/action_manager.js#L174
[1]: https://github.com/odoo/odoo/blob/d1c56ec7c435c5baba8604feccc6116e4c25ca96/addons/web/static/src/js/chrome/web_client.js#L77-L107
[2]: https://github.com/odoo/odoo/blob/e24ab17d38fb049404f04112990e8b2fe1dd7727/addons/web/static/src/js/chrome/apps_menu.js#L44-L46
closes odoo/odoo#69962
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/chrome/menu.js')
| -rw-r--r-- | addons/web/static/src/js/chrome/menu.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/addons/web/static/src/js/chrome/menu.js b/addons/web/static/src/js/chrome/menu.js index 4f6ba3bd5f9..28585aa1df7 100644 --- a/addons/web/static/src/js/chrome/menu.js +++ b/addons/web/static/src/js/chrome/menu.js @@ -197,10 +197,12 @@ var Menu = Widget.extend({ return this.current_primary_menu; }, /** - * Open the first app + * Open the first app, returns whether an application was found. + * + * @returns {Boolean} */ openFirstApp: function () { - this._appsMenu.openFirstApp(); + return this._appsMenu.openFirstApp(); }, //-------------------------------------------------------------------------- |
