Commit Graph
317 Commits
Author SHA1 Message Date
Géry Debongnie 130a7d9ee1 [IMP] web, web_tour: improve isVisible helper
Before this commit, the isVisible helper would most of the time work as
expected, except if an element has display: contents.  In that case, it
has no bounding box, but it may still be visible if one of its child
is visible.

This is particularly important since we want to set the display property
of all field components to "contents".

Part-of: odoo/odoo#96865
2022-08-08 12:33:11 +02:00
Adrien Schoffeniels 9c5b5a9dfd [IMP] web: allow commands to be middle-clickable
Purpose
=======
Allow commands in the command palette to be opened in a new tab by
either CTRL+clicking on the command, CTRL+ENTER or right clicking and
copying the link/opening in new tab.

Specifications
=============
Add new slot `focusMessage` that displays the message (if device is not
a mobile device). The `href` value has then to be defined in the
registry.

Task-2710445

Part-of: odoo/odoo#94241
2022-08-05 12:09:54 +02:00
Xavier BOL (xbo) 650d0679c0 [FIX] web: fix autofocus when input type is 'number'
Before this commit, when the autofocus is used on an input with
`type="number", the `selectionEnd` is not available because the input
element's type ('number') does not support selection.

This commit checks the input type is not a number:
- if it is the case then the selection is used to place the cursor at
  the end of the input content,
- otherwise the selection properties are not used and the input is
  simply focused.

closes odoo/odoo#97466

X-original-commit: 38a5de7b2962a47c29b23f12f2ea7599bdea11fd
Signed-off-by: Xavier <xbo@odoo.com>
Signed-off-by: Samuel Degueldre <sad@odoo.com>
2022-08-05 03:38:20 +02:00
Lucas Perais 6c155e1713 [FIX] web: relationalModel: basic keys supported in record context
Have an editable list view, displaying a many2many tags field. The m2m field
has a context, mentioning `active_id`. (`context="{'default_field': active_id}"`)

"basic context keys" is to be understood as the usual suspects: active_id, active_ids, current_company_id, active_model

Type something in the m2m input, and selet create and edit, in order to create a new record in a dialog form view.

Before this commit, there was a crash because active_id was not present in the evaluation context.

After this commit, the new record opens in its form view, with the right value for the field that must have a default.

closes odoo/odoo#96910

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2022-08-04 18:35:32 +02:00
Michael (mcm) a18ac8b272 [IMP] web: cache fields_get in DomainSelector
Before this commit, the DomainSelector did a lot of
RPCs to fields_get each time it was rendering.
Now, we use the view_service.loadFields which does the
RPCs and caches the results.

closes odoo/odoo#96852

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-08-03 11:06:30 +02:00
Michael (mcm) 80638a3f92 [FIX] web: get correct operator in DomainSelector
Before this commit, giving an unknown operator for a
certain field type made the DomainSelector crash.
Now the component lists all existing operators to find
one that matches and prevent crashing.

Part-of: odoo/odoo#96852
2022-08-03 11:06:30 +02:00
Bruno Boi 9d1786c361 [IMP] web: account for local timezone when formatting dates
formatDate and formatDateTime had their default 'timezone' option set to
false but this was changed to true in order to have the same behavior as
the legacy formatDate and formatDateTime functions.

Part-of: odoo/odoo#96946
2022-08-02 09:19:56 +02:00
Romeo Fragomeli a1dbac0f9b [FIX] web: adapt checkbox and boolean_toggle for BS5
In the BS5 migration, the legacy `checkbox` and `boolean_toggle` widget
were adapted but not the OWL Component.

Also, we have tweaked the old widget and the component to have better
positioning and margins.

Note:
the CSS for the print is already done in BS5
```css
@media print {
  .form-check-input {
    color-adjust: exact;
  }
}
```

Also we change `offsetWidth` by `getBoundingClientRect().width` in
`list_renderer` to avoid inaccurate rounding in columns width's
calculation.

Lastly a `.o-checkbox` class is added to the Checkbox component for a
more universal and context independent targetting.

closes odoo/odoo#96185

Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2022-08-01 13:26:31 +02:00
Jorge Pinna Puissant cd624c891f [IMP] web: focus trap on the dialog
This commit will trap the focus on the dialog, this will avoid modifying
a background record when a dialog is open. Trapping the focus on the
dialog is a well-known technique for modals (dialog).

closes odoo/odoo#96361

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-07-28 08:10:42 +02:00
Samuel Degueldre c5e63850dd [FIX] web: fix tooltip rendering crashing because of lack of env
With the merge of the new views, we introduced an owl directive which is
t-call-context, that allows a t-call to execute in a controlled context
that is not the context of the component itself. In doing so, we forgot
that some existing templates rely on the presence of the env in the
rendering context for things like knowing if we are in debug mode or if
the device is small/mobile.

This commit fixes that by simply adding the env to the rendering context
of tooltuips.

closes odoo/odoo#96875

Signed-off-by: Géry Debongnie <ged@odoo.com>
2022-07-28 05:04:35 +02:00
luvi 37d7247df5 [REF] web: changes to the Notebook API
This commit fixes the API of the Notebook component
that mixed props of page templates with its attributes
(isVisible, title and index). Mixing page props and
attributes was confusing. Tests have been adapted
to reflect those changes.

closes odoo/odoo#96807

Signed-off-by: Samuel Degueldre <sad@odoo.com>
2022-07-28 03:50:50 +02:00
Lucas Perais (lpe) d3f26c4aab [FIX] web: MainComponentContainer updates when registry changes
Before this commit, adding a component in the main component registry
after the initial mount did not work that is, the MainComponentContainer
never rendered the new component.

After this commit, adding a component to the registry works as expected.

Part-of: odoo/odoo#78221
2022-07-22 16:21:39 +02:00
Géry Debongnie b4063a1e73 [IMP] web: update owl from 2.0.0-beta-14 to 2.0.0-beta-16
Release notes:

https://github.com/odoo/owl/releases/tag/v2.0.0-beta-15
https://github.com/odoo/owl/releases/tag/v2.0.0-beta-16

Details:

- fix: lifecyle_hooks: correctly wrap errors in async code
- imp: use a custom error class for all errors thrown by owl
- fix: package.json: remove browser value
- ref: component_node: slightly simplify code
- fix: components: fix cause left unset when thrown object is not Error

Part-of: odoo/odoo#78221
2022-07-22 16:21:38 +02:00
FrancoisGe 5ee62cc927 [FIX] web: rename pluck to pick
Name error, the implementation of pluck is the pick function. So we will
rename the pluck function to pick.

Part-of: odoo/odoo#95945
2022-07-21 00:50:05 +02:00
Samuel Degueldre 106193e359 [FIX] web: fix useService binding service methods when it should not
Previously, the useService hook would call _protectMethod, which wraps
async methods so that any call to them after the component has been
destroyed throws an error, and any call that was started while the
component was alive but returned after the component was destroyed would
return a pending promise such that no more component code is executed.

In doing so, it would for some reason bind all the methods to the
service, this prevents some functionalities where a method would return
a differently configured version of that same service, on which you can
call the methods again (eg: orm.silent), as the modified service's
methods would not be bound to that modified service.

This commit fixes this issue by not binding the methods eagerly, and
introduces a test for all these behaviours.

closes odoo/odoo#96121

X-original-commit: 518a93a5487f62bd9b460412d4775cd0ac80a262
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Samuel Degueldre <sad@odoo.com>
2022-07-19 11:51:03 +02:00
Pierre Paridans f5ef77839f [IMP] web: Tooltip UX on touch-enabled devices
Port of legacy's BasicRenderer for WOWL views.

In a nutshell: Tooltips are problematic in touch devices as they are
meant to appear on hover... which doesn't happen with touch events.

This commit implements a "tap-to-show" behavior which let the user see
the Tooltip by pressing the element, and letting it disappear when the
pressure ends.

Part-of: odoo/odoo#95924
2022-07-19 11:50:51 +02:00
6acfad2651 [IMP] web: speed up pager total counter for large DB
Doing a `search_count` on millions of records could be very slow. On
large databases, the pager counter "1-80 / 8000000" could take several
seconds just to get the total number of records.

This commit limits the counter in list and kanban views to 10k records,
and shows "1-80 / 10000+" if the limit is reached. If you click on
10000+, it updates with the real count (or if you go up to 10000 with
pager or input value).

The search_count on res.partner of odoo.com takes 4s. With this patch,
it will take ~20ms.

Task 2761165

closes odoo/odoo#95642

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Aaron Bohy <aab@odoo.com>
Co-authored-by: Damien Bouvy <dbo@odoo.com>
2022-07-19 11:50:24 +02:00
Michael (mcm) 2faf0ac64d [FIX] web: fallback for domain selector operator
Before this commit, it happened that the domain selector
couldn't find the operator linked to the field.
This commit adds a fallback on the existing operators
to find an operator that matches.

for example the domain `[["name", "like", "M"]]` gave
`Name ? "M"`, now it correctly gives `Name like "M"`.

closes odoo/odoo#95891

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-07-13 18:49:50 +02:00
Michael (mcm) 88412a2d2b [FIX] web: fix patch descriptor
Before this commit, patching a getter of a class made it enumerable
(`Object.keys({ a: 1 })` -> `["a"]`).
In javascript, getters of a class are not enumerable but
getters of an object are enumerable.

When patching, the system replaced the descriptor of the old class
member by the member of the object.
Now, it replaces some info of the old descriptor by the new descriptor
but not the entire descriptor.

closes odoo/odoo#95921

X-original-commit: fd7c2c0c14bfaac228abacb265278157eec4aad0
Signed-off-by: Géry Debongnie <ged@odoo.com>
Signed-off-by: Michaël Mattiello <mcm@odoo.com>
2022-07-13 16:23:08 +02:00
FrancoisGe 1f4e583ba2 [FIX] web: CP lose init seach value
Before this commit, in the HomeMenu, typing several characters very
quickly could result in some not being present in the command palette
when it was opened.

Exemple:
In the HomeMenu,if I type "a" "b" "c" quickly the command palette will
open with the search value "/a" or "/ac". So we have lost the second
and/or third character.

Why:
All characters typed between the first and the moment the command pallet
is not yet mounted are lost because the search bar of the command pallet
is not yet available.

Solution:
If you use openPalette and the command palette is already open.
The configuration of the command pallet will be overwritten by the one
given to openPalette.
In our case, we can pass new configurations with the correct searchValue
until the command palette is returned.

closes odoo/odoo#95492

Task-id: 2906623
Related: odoo/enterprise#29230
Signed-off-by: Géry Debongnie <ged@odoo.com>
2022-07-12 04:21:33 +02:00
Xavier BOL (xbo) 45780793dd [FIX] web: create string ast for PyDate(time) object
Before this commit, when a new domain is created with a list of rules
and in one of those rules contains a PyDate/PyDatetime object in a
right leaf, this leaf will be converted into a plain object instead of
keeping the initial object.
For instance:
```js
a = new Domain([['date', '=', PyDate.create({day: 1, month: 1, year: 1970})]])
a.toList() // result: `[['date', '=', {day: 1, month: 1, year: 1970}]]`
```
Since it is a plain object, when the result will be passed to the
server, the final result will be an object in a string instead of giving
the utc date formatted.

This commit fixes this issue by checking if the object instances of the
`PyDate` or `PyDatetime`. If it is the case, then the ast type will be a
string and the value will stay the same instead of creating a plain
object and the ast type which determines a JSON.

closes odoo/odoo#95570

X-original-commit: be5c8d0fc340b3e2ad9721d21ef1133870d8a774
Signed-off-by: Géry Debongnie <ged@odoo.com>
Signed-off-by: Xavier <xbo@odoo.com>
2022-07-07 17:31:19 +02:00
Romeo Fragomeli 1fcd098af5 [REF] *: BS5: migration
Automated change made by a lot of RegEx to change all think that is
possible to automate.

https://getbootstrap.com/docs/5.1/migration

Task ID: 2766483

Part-of: odoo/odoo#95450
2022-07-07 13:30:24 +02:00
Romeo Fragomeli b82ba2a8fd [REF] *: BS5: Migrate modals and .btn-close for modals and alerts
- modal 'show' option doesn't exist anymore
  -> We need to call .show()

- by default, show is not the default
  -> we need to call .show() explicitly.

- generic close button for dismissing content like modals and alerts.

- BS5 modals needs `modal-dialog` class to work

- normally we need also to add `modal-content` class but as the original
XML don't have this nested level of div we don't use it, but instead
we add `pointer-events: auto` for all children `DIV` of `modal-dialog`
-> See DocumentViewer

Task ID: 2766483

Part-of: odoo/odoo#95450
2022-07-07 13:30:18 +02:00
Julien Mougenot 38710465a9 [IMP] web: Update to FileInput API
This commit changes the prop names of the FileInput component to bring
them in line with the current naming conventions. Also the default
route has been changed from '/web/binary/upload' to
'/web/binary/upload_attachment' since the latter is used more often.

Part-of: odoo/odoo#92475
2022-06-30 09:29:48 +02:00
Samuel Degueldre a7be88cd91 [REF] hr_contract, web: give tooltip info as t-call-context
Previously, we would use t-set to add the tooltip info under the key
"info" in the rendering context, while this works fine, it was mostly
just a workaround for the lack of support in owl for passing a rendering
context to be used by the t-call directly. Since this is now supported
in owl, the commit uses this feature for the tooltips and adapts the
call sites.

Part-of: odoo/odoo#92475
2022-06-30 09:29:47 +02:00
Michael (mcm) b1f072cba4 [IMP] web: adapt dialog for mobile
This commit modifies the dialog to make it more user
friendly on small screen. On small screen, the dialog
opens in fullscreen and saves the scroll position when
opening to restore it on close.

Part-of: odoo/odoo#92475
2022-06-30 09:29:46 +02:00
Aaron Bohy af0f323bac [REF] web: adapt debug items to new views
This commit adapts the (form) view debug items to make them work
with the new owl kanban, list and form views, and to make them
use the new owl SelectCreateDialog.

Part-of: odoo/odoo#92475
2022-06-30 09:29:44 +02:00
+2 48ef812a63 [REF] web: kanban, list and form views in owl
This commit introduces the new kanban, list and form views written
in owl. Even though it contains the implementation of those 3 views,
only the kanban view is activated for now (the list and form views
aren't 100% ready yet, so they aren't added to the view registry).

Alongside the views, the fields (<field name="..."/> in archs) and
widgets (<widget name="..." in archs) of web/ have been implemented
in owl as well. Legacy ones remaining in other addons are supported
in our new views, thanks to a compatibility layer. The goal is to convert
them asap though.

Legacy views, fields and widgets are kept for now, which explains the
number of added lines in this PR (around half of them concern tests).
They are still extended by custom code in other addons, that still need
to be converted (a lot of them are already on the way). Moreover,
they are still used in Studio as well. The plan is to lazy load them in
the Studio bundle when all custom code extending them will be
converted. Studio will be converted for v17.

Part-of: odoo/odoo#92475
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>
Co-authored-by: luvi <luvi@odoo.com>
2022-06-30 09:29:44 +02:00
Aaron Bohy 8697a136c3 [IMP] web: tooltip: style, delay and empty tooltips
This commit is threefold:
 1) it improves the style of tooltips (mostly, a larger font size)
 2) it adds an option, `data-tooltip-delay` that allows to specify
    the delay before the tooltip opens
 3) it handles the case where the tooltip is empty (no tooltip
    displayed)

Part-of: odoo/odoo#92475
2022-06-30 09:29:43 +02:00
Bruno Boi 34c2610e9f [IMP] web: CheckBox: can toggle on Enter
This commit allows to toggle the value of a CheckBox component
by pressing Enter.

Part-of: odoo/odoo#92475
2022-06-30 09:29:43 +02:00
Bruno Boi aa97c19814 [IMP] web: add hotkey service options
This commit adds two options to the hotkey service to improve its
usability in some cases:
- `area` which is a function that returns an HTMLElement that restricts
  the operating area for an hotkey registration
- `validate` which is a function that returns a boolean that tells if
  the hotkey registration's callback should be called or not

Some typings adaptations were made in:
- @web/core/commands/command_palette
- @web/core/commands/command_service
- @web/core/utils/ui

Part-of: odoo/odoo#92475
2022-06-30 09:29:43 +02:00
FrancoisGe 37271102be [IMP] web: dropdown: various small changes
1) Force the cursor: pointer for dropdown items containing a
   checkbox (e.g. optional field dropdown in list views)
2) Always stop click events in dropdown togglers as they are
   handled
3) Add a test for the "tooltip" props

Part-of: odoo/odoo#92475
2022-06-30 09:29:43 +02:00
luvi bbc0f0c76e [IMP] web: add ColorList component
This commit introduces a ColorList component which allows to
choose a color from a list. There are several usecases for such
a component in Odoo (e.g. ColorPicker, Many2ManyTags, KanbanRecord).

Part-of: odoo/odoo#92475
2022-06-30 09:29:42 +02:00
Michael (mcm) ec8ed943fc [IMP] web: new DomainSelector in owl
This commit introduces the DomainSelector and ModelFieldSelector
components. They will especially be used by the owl DomainField.

Part-of: odoo/odoo#92475
2022-06-30 09:29:42 +02:00
Lucas Perais (lpe) 0096f6f32e [IMP] web: add Notebook component
This commit introduces a Notebook component, which displays tabs
and an active page. The component is configurable to display the
notebook vertically (e.g. form views) or horizontally (e.g. kanban
examples dialog).

Part-of: odoo/odoo#92475
2022-06-30 09:29:42 +02:00
Michael (mcm) a8b13c2481 [IMP] web: add AutoComplete component
This commit introduces an AutoComplete component, which displays
an input and reacts to input events to display a list of suggestions
in a dropdown. The main usecase for this component is the Many2One
field.

Part-of: odoo/odoo#92475
2022-06-30 09:29:42 +02:00
Julien Mougenot ebb410accb [IMP] web: introduce useSortable hook
This hook offers an alternative to jQuery UI sortable and
draggable. It's a step in the way to removing jQuery UI. This
hook will be used by the new owl list and kanban views.

Part-of: odoo/odoo#92475
2022-06-30 09:29:42 +02:00
Samuel Degueldre e5152781cc [IMP] web: debounce: support "animationFrame" delay
By passing "animationFrame" as delay value, the debounced function
will be called just before the next animation frame following the
moment if has been effectively called.

Part-of: odoo/odoo#92475
2022-06-30 09:29:41 +02:00
Aaron Bohy 7a8052efd8 [IMP] web: concurrency utils: add Deferred
Part-of: odoo/odoo#92475
2022-06-30 09:29:41 +02:00
Aaron Bohy 313052ffb8 [IMP] web: object utils: add pluck function
Part-of: odoo/odoo#92475
2022-06-30 09:29:41 +02:00
Xavier BOL (xbo) 5501744a83 [IMP] web: add searchCount implementation in ORM service
Part-of: odoo/odoo#92475
2022-06-30 09:29:41 +02:00
Aaron Bohy 178aa2360b [IMP] web: orm service: add nameGet
Part-of: odoo/odoo#92475
2022-06-30 09:29:40 +02:00
Aaron Bohy 442d855c2e [FIX] web: notification: properly use className option
Before this commit, opening a notification with the className
option would result in a notification being displayed without the
given className. That className was overriden by the transition
className. This commit ensures we keep all classNames.

Part-of: odoo/odoo#92475
2022-06-30 09:29:40 +02:00
Julien Mougenot 35c2f217b0 [FIX] web: parseDate(Time): can handle short notations
In the wowl codebase, we use luxon instead of moment to manipulate
dates. Moment was able to parse dates with short notations (e.g.
08/15/22 for the format MM/DD/YYYY). Luxon is more strict and does
not support those cases (the format must be perfectly respected).
As a consequence, moving from moment to luxon would introduce a
regression in our date and datetime fields. This commit implements
the same kind of logic as what is done in moment, in our date
parsers, such that those cases are handled.

Part-of: odoo/odoo#92475
2022-06-30 09:29:40 +02:00
Samuel Degueldre 3c870eacf6 [FIX] web: urls: encode keys and correctly handle falsy values
This commit ensures that keys in the hash or querystring in the url
is URI encoded. Moreover, it properly handles the case where a
value in the hash is falsy. Before this commit, if a value, say "x",
was falsy, it resulted in the url in "x", which produces a crash
when decoding. With this commit, it generates "x=" in that case.

Part-of: odoo/odoo#92475
2022-06-30 09:29:39 +02:00
Julien Mougenot aa7a901678 [FIX] web: domain: correctly compare arrays
With this commit, we ensure that array values in domains are
correctly compared, w.r.t. the = and <> operators.

Part-of: odoo/odoo#92475
2022-06-30 09:29:39 +02:00
Mathieu Duckerts-Antoine 7e1ed51c5e [FIX] web: domain: can follow field relations
Before this commit, a domain like
```
   [["partner_id.name", "ilike", "Agrolait"]]
```
would crash when being evaluated.

Part-of: odoo/odoo#92475
2022-06-30 09:29:39 +02:00
Aaron Bohy 3e6bbb4ebd [REF] web: linting and small code improvements
Part-of: odoo/odoo#92475
2022-06-30 09:29:39 +02:00
Nicolas Bayet 59ef804bba [FIX] web,mass_mailing: bind the wysiwyg iframe document to hotkey service
Before this commit
When the user hit ctrl+k on a mass mailing, no command palette nor link
dialog was opening.
This was due to the fact that the hotkey service would not react
to hotkeys being pressed from inside of an iframe element.

After this commit
One can now register an iframe to the hotkey service to let it react
to hotkeys being pressed from within the registered iframes.

task-2738457

closes odoo/odoo#91102

Forward-port-of: #89940
Forward-port-of: #82994
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-06-29 17:11:27 +02:00
Nicolas Bayet 023153896d [FIX] web_editor: resolve shortcut conflict of link dialog & command palette
Whenever the user hit ctrl+k when being on an html field, both the
link dialog and the command palette opened.

In order to resolve the conflict, now ctrl+k open the command palette
with the first entry being the command to open the linktool and
a subsequent hit to ctrl+k when the command palette is open to open
the link dialog.

Task-2738457

Forward-port-of: #89940
Forward-port-of: #82994
Part-of: odoo/odoo#91102
2022-06-29 17:11:27 +02:00