Commit Graph
143436 Commits
Author SHA1 Message Date
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
Bruno Boi 5bd98883ea [IMP] web: focused command gray change
Before this commit, the $o-brand-secondary was way too dark for the web_enterprise version.

Using $o-gray-200 we now ensure the gray difference between community and enterprise is thin.
2021-06-18 21:31:31 +02:00
Samuel Degueldre ad9a322a76 [IMP] web, iap: introduce odoo.info.isEnterprise and use it 2021-06-18 21:31:31 +02:00
Samuel Degueldre 4e7187bba0 [REF] iap: adapt include on CrashManager
In iap, we want to handle InsufficientCreditErrors in a special way
(present the user with a prompt to buy more credits) instead of the
usual error handling that shows a crash dialog. Previously, this was
done by doing an include on the crash manager. In wowl, we no longer use
the crash manager in the backend, and replaced it with an error service
that allows developpers to register error handlers for these kinds of
use cases.

This commit adapts what was previously an include on the crash manager
by instead adding a handler to the error handler registry, the file has
also been renamed accordingly.

The file iap_credit.js has also been removed, as it adds an action to
the action registry that is no longer called by anything, and is dead
code.
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 99eb5760dd [REF] pos: adapt include on CrashManager to use errorService instead
closes odoo-dev/odoo#931

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-18 21:31:31 +02:00
Samuel Degueldre 6bbf814779 [REF] base_automation: convert error dialog to wowl
closes odoo-dev/odoo#924

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
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
Aaron Bohy b86a26f892 [FIX] web: adapt debug manager profiling
This commit applies [1] in the wowl branch, since [1] has been
developped in parallel of the conversion of the webclient in owl.

Note that the former implementation is still temporarily used on
the website, as it still uses the legacy DebugManager.

[1] 4c4a740e0a

closes odoo-dev/odoo#930

Signed-off-by: Géry Debongnie (ged) <ged@openerp.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
Samuel Degueldre 40fbbe2b52 [IMP] web: make startServices promise reject when missing dependencies
Previously, the promise returned by startServices was resolved when some
services were missing dependencies. The rationale was that those
dependencies could be fulfilled by bundles that might be in the page
later.

This rationale ignored the fact that bundles or scripts that are in the
same page will be executed in the same microtick.

This commit changes the returned promise from startServices such that it
will throw if after all services that were registered in the registry at
call time that could be started are started, and there are still
services registered that could not be started for lack of dependencies.
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
Simon Genin (ges) b08267a085 [IMP] web: improve stack name for debounce and throttle
closes odoo-dev/odoo#915

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
Bruno Boi 8fcdcc0b1c [REF] web: extract company service from user service 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
Jorge Pinna Puissant d73309de28 [IMP] web: use dialog service on action service
Until now, the action container opened/closed an action dialog directly
on the template, and relayed on the bus to communicate with the action service.
Now the action service opens/closes the action dialogs using the action service.
To do this, a new close method is created on the action service.
This commit also separates the code of dialog service and dialog container to
be more standard.

closes odoo-dev/odoo#900

Related: odoo-dev/enterprise#156
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-18 21:31:30 +02:00
Géry Debongnie 1092475171 [IMP] web: give proper name to memoized functions
closes odoo-dev/odoo#905

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-18 21:31:29 +02:00
Géry Debongnie c0494af680 [IMP] web: improve handling of invalid actions
Before this commit, the web client was not behaving in an
optimal way when trying to load an invalid action.

This scenario actually occurs quite frequently for developers:
- have odoo open in a tab
- drop the db, reinstall odoo with possibly different addons
- reload the tab (so, it has an action_id in the url)

Doing so would most likely lead to an invalid action_id, which in
turns displayed a traceback, because we assumed in the code that
the return value from the /action/load call is valid.

With this commit, we handle this case, and also display an empty
screen with a notification to give some feedback to the user.
2021-06-18 21:31:29 +02:00
Géry Debongnie e514576d7f [IMP] web: gracefully handles errors in service.start 2021-06-18 21:31:29 +02:00
Samuel Degueldre ee3804fdf5 [IMP] web: prefetch translations to speed up webclient startup
closes odoo-dev/odoo#901

Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-06-18 21:31:29 +02:00
Michael Mattiello (mcm) 38ae01d6b5 [IMP] web: improve error management
- Error handlers have been simplified, handlers don't returns functions
anymore and take 3 params: env, uncaughtError and originalError.
- Source maps have been reintroduced.
- The original error message and name are now concatenated to
the "wrapper" error ones.

closes odoo-dev/odoo#895

Related: odoo-dev/enterprise#154
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-06-18 21:31:29 +02:00
Bruno Boi 788f1a8b8d [IMP] web: avoid useless navbar adaptations
After this commit, adaptations for the more menu behaviour are not
computed when there is no sections menu at all.
Also, before this commit, the more menu dropdown was always attached
in the dom, even if not visible. Now it is only attached when needed.

closes odoo-dev/odoo#814

Related: odoo-dev/enterprise#102
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-18 21:31:29 +02:00
Laurent Stukkens (LTU) ce275878bd [IMP] web: add the special write commands to the orm service file
This commit brings the x2ManyCommands from the legacy basic_model.js file
into the orm_service.js file in order to ease devs works as it has been done
in the Commands class in Python code.

closes odoo-dev/odoo#891

Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-06-18 21:31:29 +02:00
Géry Debongnie 9850b8e4dc [REF] web: allow services to specify async methods
This commit improves the service API to allow the service creator
to mark some methods of the service as 'async'. This is a very
important feature when we consider the fact that a component calling
such a method may be destroyed before the asynchronous work is
complete. In that case, we do not want any code from the component
to be executed. Such async method, when called in a component (i.e.
when the service was obtained with the useService hook), will be
wrapped in such a way that the returned promises will not be resolved
if the component is destroyed.

Note that it only impact method calls for services obtained from the
useService hook, not calls for the actual service obtained from the env.

closes odoo-dev/odoo#886

Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-06-18 21:31:29 +02:00
Michael Mattiello (mcm) fe7a21dfac [IMP] web: configure fake localization service
The `makeFakeLocalizationService` test helper could not be configurated.

closes odoo-dev/odoo#778

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-18 21:31:29 +02:00
Mathieu Duckerts-Antoine 80b02e833d [IMP] web: reintroduce triggerEvent helper
Writting tests in which input/select elements are involved can become quickly cumbersome
when some external libraries are used somewhere to interact with/manage them. Indeed, change some
input/select value normally triggers some event of a precise form and this has to be properly mocked
in the tests if one expect the libraries to react properly.
The present commit reintroduces the old helper "triggerEvent" (and its generalization "triggerEvents")
that should help in that kind of task.

closes odoo-dev/odoo#887

Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-06-18 21:31:29 +02:00
Mathieu Duckerts-Antoine f4160d5907 [IMP] web: allow to parse more numbers
The present commit reintroduces several number parsers that were previously defined in web.field_utils:
parseFloatTime, parseInteger, parseMonetary, and parsePercentage. Some minor simplifications in their API
have been brought. Notably, the "field" parameter has been removed. Indeed, we expect those parsers
to be used in more specific contexts than before so that the advantage of having a common API (value, field, options)
has become less important.
2021-06-18 21:31:29 +02:00
Julien Mougenot a688f13cd4 [IMP] web: improve debug Menu extensibility
This commit renames the DebugManager to "DebugMenu", changes the
structure of its registry and the signature of its hook (useDebugMenu).

In the previous DebugManager:
- the "debug" registry was flat;
- new items were declared and created with the "useDebugManager" hook;
- these items were arbitrary functions returning a set of items.

The problem with that system was its extensibility, meaning that no
external module could hook on these arbitrary functions passed to the
hook.

In the new DebugMenu:
- the "debug" registry has multiple levels:
  > root: "global" items, found in most debug menus
  > subcategories: each subcategory has a name corresponding to the
    context it's instantiated in (e.g.: the "view" subcategory will only
    contain views-related debug menu items)
- all items are pre-declared in their corresponding category, and either
return a debug menu item or null;
- the hook activates/deactivates categories, and passes a context which
will be used by the item factories (passed as argument).
2021-06-18 21:31:29 +02:00
Michael Mattiello (mcm) 4377241d8c [IMP] web: improve error definitions
This commit adds some error types to have more accurate errors.
These types can be more easily found as they have an other name
than Error.

closes odoo-dev/odoo#885

Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-06-18 21:31:29 +02:00
Michael Mattiello (mcm) b59024f6ba [IMP] web: use the error class to handle errors
Before this commit, error handlers checked the error name to know if
they should be executed.

Now, they check the instance type of the error to be more accurate on which
error an handler deals with.

This commit also changes `emptyRejectionErrorHandler` sequence number
because it had more priority than `rpcErrorHandler` and `lostConnectionHandler`.
2021-06-18 21:31:29 +02:00
Jorge Pinna Puissant 45aaaf40dc [REF] web, web_tour: refactoring of dialog api
This commit, refactor the dialog api (dialog.js), to easier the creation
of dialog subclasses; force the use of dialog subclass when calling the
dialog service; forbid the use of dialog itself and promotes the use of
dialog subclasses.

closes odoo-dev/odoo#871

Related: odoo-dev/enterprise#151
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-18 21:31:29 +02:00
Samuel Degueldre ff870d8d15 [REF] web: replace use of other hooks with useEffect
closes odoo-dev/odoo#883

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-18 21:31:29 +02:00
Samuel Degueldre 328190f735 [IMP] web: add useEffect hook
This commit adds the useEffect hook, inspired by React. This hook
replaces the onMounted, onWillPatch, onPatched and onWillUnmount hook.

The idea behind useEffect is to unify the way we add side-effects to the
components lifecycle, while also making it easier to clean up those side
effects when needed. A lot of the time, when you want to do something
once the component is mounted, there is also a good chance you would
like to do it again when the component's state or props changes, in that
case you may also want to clean up things that you did on the previous
render. useEffect covers all these use cases and more.

The API is like that of React, with an important difference: the
dependencies of the effects is a function returning an array instead of
a plain array. This is because in React, hooks will run on every render
while in OWL, hooks are only run once during the component setup phase.
This means that in React, dependencies are computed on every render, and
doing that in owl requires having a callback to recompute them. Because
computing your dependencies can be expensive, the dependencies computed
by the callback will be passed to the effect function so that it doesn't
have to recompute them. (In React, since you're writing in the render
function, the dependencies are already in the effect's closure).
2021-06-18 21:31:29 +02:00
Bruno Boi 79d0923df0 [REF] web: simplify dropdown components
This commit adds jsdoc and typings to the dropdown components
and also rearranges a bit the code so it is cleaner and simpler.
Most part of the diff is about the keynav feature.

closes odoo-dev/odoo#802

Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-06-18 21:31:29 +02:00
Bruno Boi f05ab3cb43 [REF][IMP] web: tidying up core/l10n/dates
- file is now ordered by clean sections
- `confirm()` helper has been renamed to something more appropriate
- `strftimeToLuxonFormat()` was manually cached. It now uses `memoize()` from `core/utils/functions`
- memoization of `stripAlphaDupes()` because it is prone to get called really often with same arguments.
- no more export `parseSmartDateInput()` as it is never imported elsewhere.
- remove unecessary `setLocale` call in `luxon.DateTime.prototype.toJSON` patch

closes odoo-dev/odoo#867

Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-06-18 21:31:29 +02:00
Samuel Degueldre 8daff40725 [IMP] web: add support for custom handlers for ir.actions.report
closes odoo-dev/odoo#873

Related: odoo-dev/enterprise#144
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-18 21:31:29 +02:00
Géry Debongnie ba9fd57592 [IMP] web: improve registry.get api with default value
closes odoo-dev/odoo#870

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-18 21:31:28 +02:00
Francois (fge) 1d1b59530b [IMP] web: throw error when a domain is invalid
closes odoo-dev/odoo#787

Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-06-18 21:31:28 +02:00
Michael Mattiello (mcm) fe39f3c952 [IMP] web: improve code of popover
Popover services:
  - move bus from file scope into the service scope
  - add "specializeForComponent" to add some logics when component is
    unmounted
  - parameters passed to the manager isn't stored in state anymore to
    prevent props to be proxified.

Popover tests:
  - remove a todo comment
  - prettify template strings
  - fix "Recompute position" test

Popover services tests:
  - extract PseudoWebClient creation to lighten tests
  - add test related to "specializeForComponent"

Doc updated
2021-06-18 21:31:28 +02:00
Julien Mougenot d2985c033e [IMP] web: use original router service in tests
Before this commit, the router service used in tests was almost
entirely mocked and some of the mocked features didn't correspond to
their original counterparts.

Now, the actual router service is used in tests and the browser object
is mocked instead, allowing to correctly test the routing features.
2021-06-18 21:31:28 +02:00