Commit Graph
2286 Commits
Author SHA1 Message Date
Lucas Perais (lpe) 13a6c13666 [FIX] web: legacy client action push state
Before this commit, the push state from client actions to the URL did
not work properly:
1. the action.params key was ignored
2. some "reserved" keys (active_id) were not handled properly
3. within a legacy client action, the call to parent.do_push_state did not work

After this commit, all of those work properly letting discuss in particular have the right URL

It is worth noting that in the full wowl stack, that the right way to push something
in the URL from a component is always to call the router service's pushState when the component is mounted

closes odoo/odoo#72408

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-21 12:37:43 +00:00
Achraf (abz) 1ca2dcc233 [FIX] web: Prevent quick create from closing after text selection
There is a function allowing to close the quick create if we click outside the element.

`RecordQuickCreate._onWindowClicked`

Except that this function is triggered in a "click" event, so if we click on the quick create element and drag the mouse outside, it will detect that we are outside and close the quick create.
This manipulation can happen when you want to select text with the mouse.

This PR prevents this behavior by detecting when a click is from the quick create

opw-2558932

closes odoo/odoo#72279

X-original-commit: 75538bf2a36aa91df8b183ac21ae99a174e1c2fa
Signed-off-by: Achraf <abz-odoo@users.noreply.github.com>
2021-06-21 08:32:14 +00:00
Michael Mattiello (mcm) 7b0193279a [FIX] web: add fields in right order in calendar
Before this commit, fields in calendar popover were added
to the $fieldsList after they were appended but appending
is async and so fields could be disordered.

Now, we add fields before the append to have the right order.

closes odoo/odoo#72262

X-original-commit: da1b85d2fdff85bee35d183a8ee4faa0897dc1b4
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Michaël Mattiello <mcm-odoo@users.noreply.github.com>
2021-06-21 06:36:39 +00:00
Lucas Perais (lpe) 0195d8e7b4 [FIX] web: view_service: store the Promise in cache, not its result
Before this commit, the result of the load_views was put in the cache, so a load_views could have been
triggered multiple times before the first of them returned

After this commit, the cahce works as expected and stores the whole Promise
We always delete from the cache Promises that are rejected (to let the user re-do it in the hope the situatuion has changed)
2021-06-18 21:31:34 +02:00
Géry Debongnie 4e308bfdab [IMP] web: properly handle errors in action controllers
Before this commit, an error in the rendering of a client action or view
would not be properly cleaned: the action container did not catch any
error, so owl would destroy the UI.

With this commit, we simply catch the error, and empty the content of
the action container.
2021-06-18 21:31:34 +02:00
Géry Debongnie 7ca9a2012b [IMP] web: introduce errorhandler and notupdatable component
This commit adds two utility components:

- NotUpdatable: a component meant to be used when a component does not
  depend on anything from its parent, so it should not be rerendered
  whenever the parent is updated.  This is an optimization.
- ErrorHandler: a component that provides a nice way to catch errors
  in the rendering for a sub component
2021-06-18 21:31:34 +02:00
Lucas Perais (lpe) 76c395d7db [FIX] web: tests: deduplicate qunit asserts
Before this commit, two versions of each custom QUnit assertion function
existed. No only one exists: the brand new one from WOWL
2021-06-18 21:31:34 +02:00
Géry Debongnie 97c88e8c06 [IMP] web: add shouldUpdate=false to some components
We add in this commit a "decorator" to make components that do not
rerender when their parent is updating them. This makes sense for some
main components that knows before hand that they do not depend on a
props change.

This commit is mostly an optimization to avoid useless work by owl, but
it also has some interesting properties: before this commit, each
dialogs would be rerendered whenever a new dialog is added. This could
be an issue if the rendering of one of them causes an error, which needs
in turn to add a dialog, ...

closes odoo-dev/odoo#970

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-18 21:31:34 +02:00
Francois (fge) ea0a718fb4 [FIX] web: add the missing views in legacy_views
Before this commit, the switch from a multiple view (list, kanban, ...)
to a custom form view was not correctly done. The form view displayed
was not the custom version but the default one.

This problem is caused by the filter applied on viewSwitcherEntries
which removes the form views because they are not a multiple view.

To solve this problem, we will add the missing form view in the
actions.views given to the legacy view.

closes odoo-dev/odoo#958

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-18 21:31:34 +02:00
Samuel Degueldre 2e35ba0260 [FIX] web: wait a microtick before starting services
That way, we ensure that all synchronously defined services are
added to the registry, i.e. if a service depends on another one,
its dependency is present, regardless the order they are added to
the registry.

Closes odoo-dev/odoo#967

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-18 21:31:34 +02:00
Aaron Bohy 8b057a7671 [REF] web: move setup_tests to env_tests
To better reflect the prod file structure in the tests.
2021-06-18 21:31:34 +02:00
Michael Mattiello (mcm) aa819f892d [REF] web: change effect service API
Before this commit, effect service provided two functions:
  create(type, params)
  rainbowMan(params)

Now, it provides one function add which is create but renamed
rainbowMan function can be called by doing:
  service.add("rainbowman", ...);

closes odoo-dev/odoo#969

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-18 21:31:34 +02:00
Francois (fge) 2d1316bfe6 [FIX] web: residual rename create to add 2021-06-18 21:31:34 +02:00
Lucas Perais (lpe) 80dec11b15 [FIX] web: mockServer: push a mock view name in fieldviewGet
In the new mockServer, we add a name to a view (field name on ir.ui.view) when the found view in `fieldsViewGet`
has an id.

In tests data, one would normally specify default views like

```js
views = {
  "partner,false,form": `<form></form>`,
}

```
In this case and from the point of view of the business code, the view doesn't really exist in DB

On the contrary, if a developer writes, in a test:

```js
views = {
  "partner,999,form": `<form></form>`,
}

```
The returned view from load_views will return that view with ID 999 and, from the business code standpoint, the view would exist
in DB. This is particularly important in studio when it has to fetch a x2m view when none has been inlined in the main view.
2021-06-18 21:31:34 +02:00
Lucas Perais (lpe) 832ce8d1f9 [FIX] web, mail: test helpers: fix legacy interactions
The new execution environment of wowl tests has to take into account that legacy objects
can be spawned below it and around it, in particular in mail tests where mail has to create
an owl environment with the right keys.

This commit aims at making this work namely by being to pass an already formed legacyEnv
to the createWebClient helper
2021-06-18 21:31:34 +02:00
Francois (fge) 2aca56f0f0 [FIX] web: doAction supports controllerState passed in option
In legacy, doAction can be passed the `controllerState` key, which contains `searchModel`
and `searchPanel`, that an AbstractController can export.

This commit re-implements this in the action service.
2021-06-18 21:31:33 +02:00
Samuel Degueldre 8a888bca8a [REF] web: move crash manager to frontend only
Previously, we removed the crash manager and moved its responsibilities
to the error service.

Because the crash manager was used in both the frontend and backend, and
because the infrastructure code required to use the error service in the
frontend hasn't been written yet, the crash manager has been moved to
the frontend assets where it is still needed in the interim. Most of the
logic of the crash manager has been moved to public_crash_manager (as it
is now the only crash manager and it doesn't make sense to keep the
inheritance hierarchy).

References to the crash manager in the backend were adapted where needed
or removed where they were no longer useful.

closes odoo-dev/odoo#943

Related: odoo-dev/enterprise#174
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-18 21:31:33 +02:00
Mathieu Duckerts-Antoine d4070495d6 [FIX] web: traceback when assets loading fails
Before this commit, if the loading of a js or a css asset would fail
(via useAssets), a traceback with an incorrect message would appear.
This was due to the fact that a promise was rejected with an event as
parameter. We correct this by rejecting the promise with a custom error.

closes odoo-dev/odoo#960

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-18 21:31:33 +02:00
Michael Mattiello (mcm) 580533ecfb [REF] web, *: change dialog service api
* iap, web_tour

This commit changes the API of the dialog service.

Before, the API gave 2 functions: "open" and "close".
Now, there is only one function "add" which is the same as "open"
but returning a callback that does the close.

closes odoo-dev/odoo#940

Related: odoo-dev/enterprise#171
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-06-18 21:31:33 +02:00
Jorge Pinna Puissant 85dfc9cf49 [IMP] web: remove the Portal from dialog
In this commit, we simplify the dialog template by removing the Portal.
The Portal is no longer used, as now we always use the dialog service to
open a new dialog.

also:

- remove the dialog container class from the webclient;
- add the dialog container class to the dialog container;
- move the management of the inactive modal class to the dialog container;
- remove the dialog manager class from the dialog container;

closes odoo-dev/odoo#947

Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-06-18 21:31:33 +02:00
Lucas Perais (lpe) c65e57e17b [REF] web: ui_service and block UI in @web/core/ui/
closes odoo-dev/odoo#925

Related: odoo-dev/enterprise#166
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-06-18 21:31:33 +02: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
Simon Genin (ges) 010bbcd9fe [REF] web: errors remove non-needed event
closes odoo-dev/odoo#953

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-18 21:31:33 +02:00
Bruno Boi 47acba560a [FIX] web: open menus in new tab
Before this commit, menus in navbar and clickable elements on the home
menu were not openable in a new tab through a ctrl-click or through the
middlemouse button.

In order to achieve that, we now use default behavior of <a href/> elements.

As such default behaviour would conflict with <DropdownItem/> clicks,
a global click handler is added in the WebClient constructor which stops
the click event propagation under these specific circumstances
(ctrl-click inside an <a href/> element).

Besides this work, it has been found that the <Dropdown/> root element
should not always be a <div/> as it was, but sometimes it has to be
another HTML element in order to comply with the W3C specs. E.g. a
<Dropdown/> component as a first level child of an <ul/> element must
have a <li/> root element instead of a <div/> one.

Thus, a new prop is added to the <Dropdown/> component (`tag`) allowing
the developer to choose another root element: `<Dropdown tag="'li'"/>`.

closes odoo-dev/odoo#913

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-18 21:31:33 +02:00
Simon Genin (ges) b124343d21 [REF] web: linting 2021-06-18 21:31:33 +02:00
stefanorigano (SRI) 490acfcbb7 [IMP] web: control_panel dropdown forms design 2021-06-18 21:31:32 +02:00
stefanorigano (SRI) 1fb2cd9af7 [FIX] web, *: drop o_dropdown_toggler_btnclasses
Drop `o_dropdown_toggler_btn` class in favor of `o_dropdown_toggler`.
o_dropdown_toggler_btn was initially introduced in ~13.3, but it's now
obsolete.
2021-06-18 21:31:32 +02:00
Lucas Perais (lpe) bc25afa538 [IMP] web: tests setup: check integrity of legacy global objects
Legacy tests and business code heavily use some global objects (session and _t)
Wowl tests are set to clean the execution environment at the end of each tests
while legacy tests clean their environment when the widget is destroyed

This discrepancy may introduce weird, untimely and virtually undebuggable issues
for the average Joe, because some tests may pollute the execution environment for following tests

This commit aims at limiting this risk by hardcoding a few objects and their field to be checked at the end of each test

closes odoo-dev/odoo#945

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-18 21:31:32 +02:00
Géry Debongnie 12500d8917 [FIX] web: implement missing pyjs operation
The new py interpreter was missing the subtraction of a date with a
relativedelta

closes odoo-dev/odoo#944

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-18 21:31:32 +02:00
Simon Genin (ges) 276228010e [FIX] web: fix legacy views form no id
BUG: Begin on a multi record view (list, kaban), change the url param "view_type" to form. A controller
adapter component would fail to mount and and promise would be pending for ever, freezing the webclient.

WHY: The new webclient, in the specified case described above, would set the recordId to false when switching
to the single record view without providing a record id in the url. However, the legacy views expected a value
of undefined.

FIX: In an adapter layer, the legacy views adapter, we check for the recordId being set to false. When it is,
update this value to undefined.

closes odoo-dev/odoo#933

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-18 21:31:32 +02:00
Aaron Bohy 840f914a4e [FIX] web: concurrency issue when opening form view
From a list or kanban view, quickly click multiple times on a
record or on the Create button: a lot of bad stuff could happen
from there (e.g. crashes, form view that could not be open
anymore afterward).

The reason was that we destroyed the legacy form view whereas we
shouldn't, as it was still used. In more details, when we clicked
first on a record to open it, we created an owl Component to
instantiate and wrap the form view (legacy). When we clicked a
second time, we another owl Component was instantiated and the
first one was destroyed. As an unwanted side-effect, the legacy
form view was destroyed as well, but the new controller wanted to
reuse it. From that point, anything bad could happen as we were
trying to use a destroyed widget.

closes odoo-dev/odoo#941

Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-06-18 21:31:32 +02:00
Bruno Boi aab6f88439 [MOV] web,base_automation: hotkeys from webclient/ to core/
The hotkeys feature is a core feature, not only useful for the webclient.

closes odoo-dev/odoo#942

Related: odoo-dev/enterprise#172
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-18 21:31:32 +02:00
Aaron Bohy fc7c431840 [FIX] web: actionService: handle async client actions
A client action can be a function. This function may return another
action to be executed afterwards. This function may also be async.
This is for instance the case of the studio client action. Before
this commit, the code handling it directly called doAction with the
promise as action, which could lead to unexpected results. For
instance, studio tours sometimes fail to load the studio client
action.

closes odoo-dev/odoo#935

Related: odoo-dev/enterprise#169
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-06-18 21:31:31 +02:00
Jorge Pinna Puissant ff20073b21 [FIX] web: use dialog service to close the dialogs
Before this commit, the function close on dialog trigger an event to close
the dialog. This could create an issue when the dialog is not yet mounted.

Now, the function close on dialog uses the dialog service to close the dialog.

closes odoo-dev/odoo#936

Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-06-18 21:31:31 +02:00
Michael Mattiello (mcm) 866f0e8c37 [REF] web: refactor command service API
Before this commit, service command exported 2 functions:
registerCommand and unregisterCommand.

Now, it exports only one function "add" which is calls registerCommand
and returns a callback which calls unregisterCommand
The add function's signature is different from registerCommand:

- registerCommand signature:
registerCommand(command: Command): number
interface Command {
    name: string;
    action: () => void;
    category?: string;
    hotkey?: string;
    hotkeyOptions?: any;
}

- add signature:
add(
    name: string,
    action: () => void,
    options?: Options
): () => void
interface Options {
    category?: string;
    hotkey?: string;
    hotkeyOptions?: any;
}

closes odoo-dev/odoo#923

Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-06-18 21:31:31 +02:00
Michael Mattiello (mcm) 37a73aaf7a [REF] web: change hotkey service API
Before this commit, service hotkey exported 2 functions:
registerHotkey and unregisterHotkey.

Now, it exports only one function "add" which is calls registerHotkey
and returns a callback which calls unregisterHotkey
2021-06-18 21:31:31 +02:00
Mathieu Duckerts-Antoine 9c05de391e [IMP] *: remove makeFakeUIService helper
The behavior of some components like the Dropdown component depends on the ui service that records
(among other things) what is the "active" element in the page. For instance a dropdown can close/stays open under
certain circumstances if it is in the active element or not. The fake ui service created by makeFakeUIService
was not managing properly the active element. Since we want to avoid code duplication and that there was no real
need for a fake ui serice, we simply drop the helper makeFakeUIService and use the real ui service everywhere.
2021-06-18 21:31:31 +02:00
Samuel Degueldre 83781d3de5 [FIX] web: empty SERVICES_METADATA when clearing the services registry
Previously, we added the option to declare service methods as async so
that we can protect them from resolving their promise after a component
has been destroyed. To that end, we have created a SERVICES_METADATA
object to hold this data. However, due to an oversight, these metadata
were not being saved and cleared before tests, and restored after,
causing issues when add a mock service that does not expose all methods
exposed by the real service.

This commit fixes that.
2021-06-18 21:31:31 +02:00
Lucas Perais (lpe) 8a530b153b [IMP] web: debugManager: re-implement "Open view" 2021-06-18 21:31:31 +02:00
Jorge Pinna Puissant 5437fb98ca [IMP] web: close action service dialog using the 'x' button
Until now, if a dialog was opened using the action service with an
on_close callback, this callback wasn't called if the dialog was closed
without using the action "ir.actions.act_window_close".

Now, the on_close callback is called after the dialog is closed.

closes odoo-dev/odoo#929

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-18 21:31:31 +02:00
Jorge Pinna Puissant 774ca5571a [FIX] web: close, already closed dialog
Before this commit, when trying to close an already closed dialog, an
error is raised.

closes odoo-dev/odoo#928

Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-06-18 21:31:30 +02:00
Jorge Pinna Puissant 22bb866588 [REF] web: move parseMonetary to currency
closes odoo-dev/odoo#926

Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-06-18 21:31:30 +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
Michael Mattiello (mcm) 2384ebc689 [REF] web: refactor popover
This commit refactors the popover to make it imperative.
Popover cannot be used in templates anymore.

closes odoo-dev/odoo#914

Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-06-18 21:31:30 +02:00
Géry Debongnie f4bb46cd29 [REF] web: update systray registry to take Component/props 2021-06-18 21:31:30 +02:00
Aaron Bohy 2e2d6a166e [IMP] web: userService: add hasGroup function
This commit adds the 'hasGroup' function to the user service. This
function holds a cache s.t. we never do twice an rpc for the same
group. This is the equivalent of 'user_has_group' in session, in
the legacy codebase.
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
Aaron Bohy dd489c34e7 [IMP] web: qunit: better log failing modules 2021-06-18 21:31:30 +02:00
Jorge Pinna Puissant 60d3f7400b [IMP] web: add is_system on the mocks
closes odoo-dev/odoo#909

Related: odoo-dev/enterprise#157
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-06-18 21:31:30 +02:00
Bruno Boi 1cec4e0888 [IMP] web: allow user to select multiple company
Before this commit: when user selects company from company switcher, page is
reloaded, what if user wants to select multiple companies from dropdown, he
have to wait for page reload and need to do same process again.

After this commit: when user selects company from company switcher, page
will not reloaded as soon as user toggles checkbox, user will given time to
select another item or unselect other item from dropdown, so user can select
multiple companies or unselect multiple companies.

task-2467747

closes odoo-dev/odoo#875

Related: odoo-dev/enterprise#148
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-18 21:31:30 +02:00