Commit Graph
11839 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) 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
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
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
wan d29c8427d1 [FIX] web: increase file upload to 128Mb
Also make this a configurable value, from the server.

This is the limit of the SAAS servers.

closes odoo/odoo#72143

X-original-commit: bcd1c8aade6123dd20d7aebaae8a0f204f258604
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: William André (wan) <wan@odoo.com>
2021-06-14 15:51:24 +00:00
Jeremy Kersten 926af37343 [REF] *: remove unused fileToken cookies
This cookies is not more used since 35d452cffb

closes odoo/odoo#72079

Related: odoo/enterprise#18967
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2021-06-14 07:32:18 +00:00
Adrien Widart 80d643c141 [FIX] web: save operator for m2o fields in pivot view
When generating a spreadsheet from a pivot view, the values of m2o
fields are added up instead of being counted.

To reproduce the error:
(Need point_of_sale,documents_spreadsheet)
1. Open a POS session
2. Process 3 orders
3. Close the session
4. Point of Sale > Reporting > Orders - Pivot View
    (Note: the number of orders is 3, which is correct)
5. Insert in Spreadsheet

Error: On spreadsheet, the number of orders is incorrect (the value
corresponds to the sum of the order identifier of each POS order line)

When generating the spreadsheet, here is how the operator for each field
is computed:
https://github.com/odoo/enterprise/blob/06bf2b0e2def3445cdd21d5b6fccc58e3015e0b5/documents_spreadsheet/static/src/js/o-spreadsheet/pivot_utils.js#L217-L225
If there is not any `group_operator`, the `operator` will be defined to
`sum`.

In the above case, the attribute `group_operator` is indeed not defined
for the field `order_id`:
https://github.com/odoo/odoo/blob/1ddbcb4860ee220e9f826e8b6f6b85b6c22fb2b7/addons/point_of_sale/report/pos_order_report.py#L14

However, when generating the pivot view, if the field is m2o, its
`group_operator` value is not considered and the operator is directly
defined to `count_distinct`:
https://github.com/odoo/odoo/blob/7cf8f6f40e5769d2f22620ac425208c4ad9ae80b/addons/web/static/src/js/views/pivot/pivot_model.js#L979-L987

Since the spreadsheet is based on the pivot view, this fix suggests
saving this decision so the spreadsheet will behave in the same way.

OPW-2551030

closes odoo/odoo#72020

X-original-commit: a7ada576df9bbd6c1fd1cbf082ba0a79ec7802f9
Related: odoo/enterprise#18945
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: Adrien Widart <adwid@users.noreply.github.com>
2021-06-10 19:25:31 +00:00
Géry Debongnie 5beeff02be [FIX] web: update owl from 1.3.0 to v1.3.1
This commit updates owl to the latest release. It only contains a
fix to better handle t-calls in nested t-slots

Release on github: https://github.com/odoo/owl/releases/tag/v1.3.1

closes odoo/odoo#71989

X-original-commit: 5c66f47e849144f79ecf9dd63d51529be3510aff
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-06-10 13:52:44 +00:00
Bruno Boi eec15347e9 [FIX] web: wrong condition in time helpers
closes odoo/odoo#71871

X-original-commit: a299fb2dd2f49edc1e5d088e6a0cd672583a76eb
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-08 13:45:23 +00:00
Xavier Morel 36f368599c [FIX] web: warning about t-foreach missing a t-key
closes odoo/odoo#71841

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-08 06:12:18 +00:00
dht-odoo 3d35ea645f [FIX] web: fix scss of ol tag in report
This is a temporary fix, it needs to be fix properly in future.
It was working properly with HTML reports but when it is render with
wkhtmltopdf it does not apply padding on left. Due to which issue is occuring.

Task id: 2499504

X-original-commit: 2958c8d08f4bdab94ba55fc944db6d314fb3fa43
2021-06-07 05:24:08 +00:00
dht-odoo 025004309c [FIX] web: fix js traceback of imageType variable
X-original-commit: 895f262e03d0aaa6d00f2ba937561be0d8b8fd28
2021-06-07 05:24:08 +00:00