Commit Graph
143154 Commits
Author SHA1 Message Date
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
Jorge Pinna PuissantandLucas Perais (lpe) 36e03d1b98 [FIX] web: take into account the view flags
Co-authored-by: "Lucas Perais (lpe)" <lpe@odoo.com>
2021-06-18 21:31:28 +02:00
stefanorigano (SRI) ce4e6bd4b1 [REF] web: date-picker design revamp 2021-06-18 21:31:28 +02:00
stefanorigano (SRI) 8c55713dcc [FIX] web: tempusdominus lib assets order
Allow to customize tempusdominus's default variables moving its assets
at the end of the bundle.
2021-06-18 21:31:28 +02:00
stefanorigano (SRI) abab4685dd [REF] web, base: settings page, design adaptations
Use predefined variables rather than arbitrary values, fix minor
alignment issues.
2021-06-18 21:31:28 +02:00
stefanorigano (SRI) 09dbf43a63 [FIX] base, web: settings page, use breadcrumb for title
Use .breadcrumb class to ensure that the page title design will match
all the other pages.
2021-06-18 21:31:28 +02:00
stefanorigano (SRI) 3798dd0ccd [REF] hr_holidays: minor design adaptations 2021-06-18 21:31:28 +02:00
stefanorigano (SRI) 8b00422ab8 [REF] web: pivot_view, design adaptations 2021-06-18 21:31:28 +02:00
stefanorigano (SRI) f720585557 [REF] web: calendar_view, design adaptations 2021-06-18 21:31:28 +02:00
stefanorigano (SRI) bc26f6c5ec [REF] web: 'o_status' dropdown design
Design using native classes and increase size if rendered into a
form_view.
2021-06-18 21:31:28 +02:00
stefanorigano (SRI) e59f6dbbd9 [REF] web: list_view design adaptations
Adjust border and text colors, improve the 'selection box' using native
classes.
2021-06-18 21:31:28 +02:00
stefanorigano (SRI) b66ccbd341 [FIX] web: control_panel, design minors
Use $border-color rather than an arbitrary value.
Decrease navigation buttons horizontal gap and adjust margins.
2021-06-18 21:31:28 +02:00
stefanorigano (SRI) 298d8bbfbd [FIX] web: form view, hide empty statistics data
Hide empty statistic fields to avoid forcing a "two lines layout" when
it's not necessary.
2021-06-18 21:31:28 +02:00
stefanorigano (SRI) dca874b2bf [REF] web: form_view design adaptations
Style using as much as possible predefined variables rather than
arbitrary values. Review status arrow buttons design and increase
overall text's contrast.
2021-06-18 21:31:28 +02:00
stefanorigano (SRI) 23f26c240e [REF] web: kanban_view design adaptations
Style using as much as possible predefined variables rather than
arbitrary values. Adjust cards ':focus' state to match other
components and avoid misleading shadows.
2021-06-18 21:31:28 +02:00
stefanorigano (SRI) 50f22a2b24 [REF] web: review custom backgrounds and custom 'btn-link' design
Drop custom 'bg-X-full' classes since we can now achieve the same visual
result using default 'bg-X' classes (it was not the case with prev.
bootstrap versions).

Ensure text readability for both 'bg-X-light' and 'btn-link' classes.
2021-06-18 21:31:28 +02:00
stefanorigano (SRI) d9a0877096 [REF] web, mrp: drop custom text decoration classes
Drop custom text decoration classes in favor of default bootstrap ones.
2021-06-18 21:31:28 +02:00
stefanorigano (SRI) 1971bf3981 [REF] web, website: refine and simplify dropdown design
Prior to this commit, Bootstrap dropdowns, jQueryUI dropdowns and Odoo
dropdowns where styled independently leading to visual inconsistencies
and code repetition.

This commit will customize and improve the Bootstrap design using as
much as possible predefined variables. Then it will simply '@extend'
owl/jQueryUI classes in order to visually match the bootstrap ones.

Since dropdown classes are used in the top-menu (and its design is
partially shared with frontend apps), this commit provides the necessary
adaptations for this component as well.
2021-06-18 21:31:27 +02:00
stefanorigano (SRI) b389d38a36 [REF] web: optimize scss variables declaration
Mirror web_enterprise variables declaration to ease enterprise's
overrides. Reorganize variables in order to keep a consistent assignment
structure across versions.

This commit will also add '!default' flags in boostrap_overidden.scss,
allowing enterprise to reuse customization already defined in community.
2021-06-18 21:31:27 +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
Samuel Degueldre 2587a16835 [FIX] hr_timesheet: convert include on AbstractWebclient to service
In timesheets, which widget should be used to display durations depends
on the company's unit of measurements.

Previously, this was done by overriding the webclient's init method,
where we could check the company's UOM and insert the appropriate field
widget in the field widget registry.

In wowl, the extension mechanism that was used (include on webclient) no
longer exists, as such, this is now done in a service that is started by
the webclient during it's initialization, and as such, happens
essentially in the same part of the webclient lifecycle, but no longer
needs to patch the webclients internals.
2021-06-18 21:31:27 +02:00
Samuel Degueldre a3c69db9ef [FIX] board: replace include on ActionManager with override on view
When opening the dashboard in form view, some of the view options should
always have a certain value (in particular, the target should be inline,
and the form view should not have action menus or a control panel).

Previously, this was done through an override on the action manager when
executing a window action. In wowl, the action manager has been replaced
with an action service and its methods cannot be overriden.

This commit solves the same problem with a different approach, by
overwriting these options before trying to extract the view params from
the action.
2021-06-18 21:31:27 +02:00
Bruno BoiandFrancois 3a4f1c31de [IMP] web: add hotkey and command services
Co-authored-by: Bruno Boi <boi@odoo.com>
Co-authored-by: Francois (fge) <fge@odoo.com>
2021-06-18 21:31:27 +02:00
+1 0573acae23 [REF] web: rewrite the webclient in OWL (phase 1)
This commit is the first phase of the conversion of the web/ JS
codebase to the owl framework. The impact of this commit is two-fold.

First, it rewrites the framework part of web with a new system of
services and registries. Services allow to execute code (e.g. do rpcs,
setup things) before launching the application. They can also expose
an API to be used by other parts of the application (e.g. a notification
service would expose a function to display notifications). Services are
often a good extension point for external modules that want to execute
code at webclient startup. Registries offer another way to extend the
application. They provide well designed extension points to add
elements/behaviors from the outside (for instance, to add a systray item,
an error handler...).

Second, this commit initiates the conversion of the webclient to owl
with a top-down approach, around those notions of services and registries.
The root of the web application is now an owl application. Among others,
the WebClient, ActionManager, Navbar, UserMenu, DebugManager, Dialogs,
services (e.g. notification, ajax...) have been converted to the new
framework/architecture.

Legacy views and client actions are still supported (and used). They
will be converted in the next months, and at some point, the support
will be dropped.

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
Simon Genin (ges) 8d57a5cde9 [ADD] web: prettier and eslint tooling
Provide an opt in js tooling system by adding a node env with prettier and eslint configured.
3 bash scripts are provided: enable.sh, disable.sh and reload.sh.

Enable.sh: add to the community root (and optionaly to the enterprise root) the env.
Disable.sh: remove the env.
Reload.sh: disable then enable.
2021-06-18 21:31:27 +02:00
Aaron Bohy 84a4859570 [REF] web,*: move legacy files
To prepare the rewriting of the webclient in owl, we move all
current js files of web in a legacy/ folder. This folder will
eventually be removed, as soon as each file it contains will be
converted to owl and moved to the proper place in the new file
structure.
2021-06-18 21:31:27 +02:00
Aaron Bohy 2e30e4237a [REF] web: manifest: simplify assets_backend 2021-06-18 21:31:26 +02:00
Anh Thao Pham (pta) c047c85208 [FIX] base,web: fix display of images of contact's children upon change
Scenario:
- Go to Contacts
- Open a contact
- In "Contacts & Addresses" tab, add a child and configure its image
- Once child form is saved, image of the child is not displayed in the
kanban view used for children
It will only appear once the main contact form is saved.
The same issue occurs when editing a child image.
The new image will only be shown once the main contact form is saved.

The issue at the creation is due to the fact the function retrieving
the URL of the image tries to generate the URL from record id, which
is not set.  It should use raw data of image in this case.

For the edition, it is due to the fact that the child form is changing
image_1920 field while the kanban view used for children is displaying
image_128 field.  image_128 is a related field to image_1920, but it
does not appear in the child form.  It is therefore not recomputed (by
onchange) when image_1920 is modified.  Adding it in the child form view
solves the issue.

opw-2516188

closes odoo/odoo#72375

X-original-commit: 7eac23573c77415c84cb9c234c8063d4c68be425
Signed-off-by: Anh Thao PHAM <kitan191@users.noreply.github.com>
2021-06-18 16:38:08 +00:00
Nicolas Lempereur 4aa89f146e [FIX] website_slides: can edit frontend enroll message
The frontend enroll message was display as a `<small/>` tag, but it
seems that lxml HTMLParser parse it wrongly, for example:

  html.tostring(html.fromstring('<small data-oe-model="test"><p></p></small>'))

returns:

  '<div><small data-oe-model="test"></small><p></p></div>'

So branding attributes like data-oe-model that are on small tag are not
found on root node that has become a `div` tag after parsing => this causes
a traceback error when saving a change in this part.

Fix: use small as wrapper for `<div/>` tag that is treated correctly by
HTMLParser (span is also treated correctly but div makes more sense
here).

opw-2573955

closes odoo/odoo#72315

X-original-commit: 6334c7282c19362ca8bc79dbaefe3d38c055e746
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2021-06-17 18:37:44 +00:00
Arthur Detroux (ard) f3d840d1a6 [FIX] mass_mailing: make editor perform cleanForSave on save
Before this commit, when editing a mass_mailing template, on save,
the editor would not tell the snippet menu to perform a cleanForSave
which it should normally do for the option to properly prepare to save.

Bug discovered while working on task-2327045
Ideally, would need to be backported but requires a different fix in the
old editor.

closes odoo/odoo#72346

X-original-commit: 639b6a55586107bd3d855d322c1102df101eb079
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-06-18 12:08:45 +00:00
Aurélien (avd) 54e06aa28d [FIX] account: Fix reconciliation with multi-currencies but balance = 0
This commit fixes the case when the reconciliation never ends due to an infinite loop.
This happens when we attempt to reconcile two journal items having differents foreign currencies but an amount_residual = 0.0.
In that case, partials are created everytime with zero amount, zero debit_amount_currency and zero credit_amount_currency.
We don't need to handle such reconciliation because exchange difference journal items are always created using the same foreign currency as the originator line.

The way the reconciliation is made for reversal moves is also edited by this commit to avoid reconciling lines on the same moves but with different currencies.

closes odoo/odoo#72266

X-original-commit: 1231d54b8c2084db6ffb9551af7ed4ee9e31a95a
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2021-06-18 12:22:05 +00:00