Commit Graph
403 Commits
Author SHA1 Message Date
luvi 49159d791e [FIX] web: fix displayed label of the SelectMenu
This commit fixes the wrong label that was displayed when options
are defined inside groups. Since displayValue was only looking for
a label on choices set using the choices props, the getter was only
returning the technical value for choices defined in groups.

A test has been modified to verify that the correct label is shown,
also on choices present inside of a group. This test previously
asserted that, but only on choices given by the choices props.

closes odoo/odoo#112766

X-original-commit: 176e61d5c25111a1e9339a0687bb526d1d430790
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Luca Vitali <luvi@odoo.com>
2023-02-15 12:33:47 +01:00
FrancoisGe 365fe390fd [REF] web: remove redirect in router
The redirect function in the router exists only for the wait option.
This option is only used in one case (client action home). We have
therefore decided to remove the redirect function and to call
browser.location.assign(...) directly.

We will also remove the "wait" param for the "reload" and "home"
client actions. Because no call to "reload" needs it (1) and all calls to
"home" want it wait=True. So we will move the code that was executed
if wait=true to the "home" action client.

(1) In the POS, wait=true is used for a "reload" but this has no impact.
Wait=true was intended to wait for the server to restart before reloading
the page. In the case of the POS, there is no restart of the server, so
wait=True is useless.

closes odoo/odoo#112621

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-02-15 10:14:42 +01:00
Bruno BoiandJulien Mougenot 24fb77d457 [IMP] web: Draggable hook builder
This commit adds several improvements and overall changes the way
draggable builders can be built, adding some helpers to temporary
manipulate DOM elements during drag sequences and making some changes
on the way drag callbacks are handled.

The current implementations of draggable hooks built with this feature
have been adapted.

The drag test helpers have also been reviewed to more accurately
mimick real-life scenarios and allow for more flexiblity (i.e. moving an
element to a certain point during the drag sequence before being
dropped).

Part-of: odoo/odoo#110819
Co-authored-by: Julien Mougenot <jum@odoo.com>
Co-authored-by: Bruno Boi <boi@odoo.com>
2023-02-14 17:09:05 +01:00
a3dd93194f [IMP] web: introduce useVirtual hook
This commit introduces a hook named "useVirtual" which allows to filter
a given list of objects and return only those that are visible in the
current viewport. This effectively allows to use virtualization in lists.

The hook will trim down the list of objects it received to those that fit
in the current viewport (with a fixed margin above and under to allow
smoother transitions on scroll).

The following requirements must be met to use this feature:

- the scrollable area has a fixed height
- along with the list of items, a "getItemHeight" getter must be
provided to determine the actual height of each individual item;
- the items are rendered with a proper offset inside the scrollable area.
  This can be achieved e.g. with a css grid or an absolute positioning.

Part-of: odoo/odoo#110819
Co-authored-by: Bruno Boi <boi@odoo.com>
Co-authored-by: Julien Mougenot <jum@odoo.com>
Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
2023-02-14 17:09:04 +01:00
Nshimiyimana Sénaandhuvw 1309a8b86c [FIX] web: fix arabic date parsing
# Steps to reproduce
* Have Arabic language installed
* Create an invoice
* Register a partial payment (keep invoice open)
* Switch to Arabic language
* Click the register payment again

=> You should be met with a traceback

# Cause
Currently, the `parseDate` function relies on `parseDateTime`. If no
format is passed to `parseDateTime` (like in our case), the user's
`localization.dateTimeFormat` is used. `parseDateTime` implements
workarounds to allow parsing of dates (without a time).
However, those workarounds do not work with languages such as Arabic.

opw-3133992

closes odoo/odoo#112354

X-original-commit: 869b01da4948775d9a3009426a74cc9207e81374
Signed-off-by: Bruno Boi (boi) <boi@odoo.com>
Co-authored-by: huvw <huvw@odoo.com>
2023-02-09 23:09:00 +01:00
MerlinGuillaume a021c48417 [FIX] spreadsheet,web: use dot or comma in date format
Date fields are changing format if you type it in instead of using the
date selector calendar popup

Steps to reproduce:
1. Install Time Off
2. Open the current language and change the date format to `%d.%m.%Y`
3. Go to Time Off > Approvals > Allocations
4. Create a new allocation
5. Change the validity period to 10.03.2023 (by typing it in, not using
   the datepicker) and click out of the field
6. The date displayed is changed to 2010/03/20 or 20.03.2010 (if the
   datepicker was opened)

Solution:
Add dot and comma as a possible character for static format
Also deduplicated function isValidStaticFormat so we have a single
definition

Problem:
Formats using dots were not considered as valid static format so the
value entered was parsed with the format `yyyy/MM/dd` instead

opw-3081268

closes odoo/odoo#112218

X-original-commit: 18d6944510b55a4de21be050b8fef327f00e71d5
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
Signed-off-by: Guillaume Merlin (megu) <megu@odoo.com>
2023-02-08 16:50:00 +01:00
Géry Debongnie a5036864b1 [IMP] web: add a memoized checkAccessRight method on user service
This prevents the property field from calling repeteadly the server for
an information that (almost) never changes. Note that all checks should
probably go through this services for the rest of the codebase.

closes odoo/odoo#111571

Signed-off-by: Géry Debongnie <ged@odoo.com>
2023-02-06 12:09:51 +01:00
Aaron Bohy 55a0207473 [FIX] web: tooltip: open tooltip even if entered slowly
Before this commit, there was a weird issue with tooltips. If the
element was entered very slowly from the left or top, sometimes,
the tooltip didn't open.

The problem came from the way we closed the tooltip. This was done
by checking the x and y mouse positions within a setInterval, and
if it wasn't inside the element having the tooltip, the tooltip
was closed. When approaching the "?" icon, the mouseenter event was
triggered, we registered the setTimeout to open the tooltip. In the
next ms, the setInterval callback to check whether the mouse is
still hovering the element was executed. We observed that when the
mouseenter event is triggered, the x and y mouse positions aren't
yet inside the element, for 1 or 2 px (like if the mouseenter was
triggered too soon). As in the scenario, we move the mouse very
slowly, the setInterval callback determined that the mouse wasn't
hovering the element and thus cancelled the setTimeout callback that
will open the tooltip.

This commit fixes the issue by changing the way we detect that we
have to close the tooltips. We now listen to "mouseleave" events,
and when triggered on the element with and opened tooltip, we close
it.

Task 3150954

closes odoo/odoo#111718

X-original-commit: 89770d32cbb368f73ab304ea5c1637bd3cc19bcd
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
2023-02-03 06:06:15 +01:00
Stefan-Calin Crainiciuc (stcc) 0187c8a466 [FIX] web: pyjs: Tokenize float numbers in scientific notation
Steps to reproduce:

- Install Dashboard, Inventory apps
- Go to Inventory > Products
- Add a custom filter "Quantity on hand > 0.00001"
- Favorites > Add to my dashboard > Add
- Go to dashboard app

Issue:
JS Traceback is raised: `Expected "]", got "(name)"`

When executing the rpc call to `/board/add_to_dashboard`, the number
`0.00001`, which is passed as argument, is decoded as `1e-05` in the
python code and stored in the custom view.

When parsing the same view in the frontend, the tokenizer fails to
detect `1e-05` as a floating number and an error is thrown while parsing.

Solution:
Add regex for floating point numbers in scientific notation in `py.js`.
The regex accepts numbers such as:
- 1.2
- 12.
- .1
- 1e-02
- 1.2E-2
- 12.e+2
- .1E3

opw-3038707

closes odoo/odoo#111664

X-original-commit: d2d23e517fb81ab3779f6f0dbf0d035544c863d8
Signed-off-by: Samuel Degueldre <sad@odoo.com>
Signed-off-by: Stefan-Calin Crainiciuc (stcc) <stcc@odoo.com>
2023-02-03 05:09:35 +01:00
Jorge Pinna Puissant 5c27039bc7 [FIX] web: update field when using compute date
- have a current date of 24/03/2022;
- have a date field of 29/01/2020;
- use compute date (+5d for instance) on the field;
- as the date field changed, the datepicker will update with the new
    value : 29/03/2022;
- use again the compute field, with the same value (+5d);

Before this commit, the datepicker didn't shown the result of the
compute date but it will show 05/01/2022. This occurs because the
datepicker updates when the dates are different, in this case the result
of the computation and the current date are the same. The shown date
05/01/2022 is shown because the input have 5 in it.

Now, the datepicker input will always update, and the correct date is
shown.

closes odoo/odoo#111574

X-original-commit: 85a36a183de5a1a68f8566489b307216568dad9c
Signed-off-by: Michaël Mattiello <mcm@odoo.com>
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
2023-02-01 14:38:09 +01:00
Laurent SmetandAaron Bohy cf1bcb1851 [FIX] web,base: add 'count_limit' attrs in kanban and list
This commit adds an attribute in kanban and list archs that
fixes performance issues.

Some tables are very huge and depending of the searched domain,
the search_count made in web_search_read takes much more time
than the search_read. For 10M records, the search_count could take
more than 10x the time of search.

This commit allows to set the count_limit in the arch to override
the hardcoded 10k value.

closes odoo/odoo#111284

X-original-commit: 699215ec9a71b8c9b6a53fe96e924a400d216729
Related: odoo/enterprise#36431
Signed-off-by: Géry Debongnie <ged@odoo.com>
Co-authored-by: Aaron Bohy <aab@odoo.com>
2023-01-28 08:43:48 +01:00
Aaron Bohy 7416cdca33 [FIX] web: debug: View Metadata dialog: format dates in user tz
Before this commit, the creation date and last modification date in
the metadata dialog (in debug, in any form view, click on the debug
item, then View Metadata) were displayed in UTC, whereas they
should be formatted in the user timezone. This commit fixes the
issue.

closes odoo/odoo#111153

X-original-commit: 104e17211be9098b48eac842d65b1c378af5c05a
Signed-off-by: Michaël Mattiello <mcm@odoo.com>
2023-01-27 09:18:06 +01:00
Benoit Socias 364440456a [IMP] web: retry loading CSS before showing error
When starting a trial instance, skipping the configurator and picking a
theme, it can happen that some lazy loaded `web_editor` CSS is not ready
yet - which causes a traceback popup to be displayed.
Note that this problem could not be reproduced.

This commit introduces a retry mechanism when a CSS cannot be loaded in
order to try to preserve the trial's "wow" effect.
For readability, the link is now added after defining the Promise that
registers the event handlers.
The test is adapted in order to make the retry mechanism retry faster.

task-2972330

closes odoo/odoo#110590

X-original-commit: 6a9212d52114ccda827ad2784d0369ffd9d6526e
Signed-off-by: Arthur Detroux (ard) <ard@odoo.com>
Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
2023-01-23 11:20:11 +01:00
Aaron Bohy 5d45465758 [FIX] web: error service: no crash on prom rejected w/o error
Before this commit, the error service crashed when it had to handle
a rejected promise error with a reason that was a truthy value but
not an error.

This happens for instance in the wysiwyg editor which may reject
promises with `Request took too long (more than 10 seconds).` as
reason. We sometimes get this error on odoo.com after migrating
to 16.0, typically on a tab running in the background.

closes odoo/odoo#110613

X-original-commit: 3021f7e64382e648d15671a2a1d16847b3d72cb0
Signed-off-by: Géry Debongnie <ged@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-01-23 10:16:48 +01:00
Jorge Pinna Puissant e6d89466fd [FIX] web: invert position (start/end) when using rtl
Before this commit, when using a rtl language, the position of the
popper elements using the 'usePosition' hook weren't inverted.

This issue was found, for instance, on autocomplete dropdowns. The
dropdown component inverted the position if it was a rtl language, this
behaviour was moved to the `usePosition` hook.

X-original-commit: a357009cbc6aacd3f1c87f3c6e632e83c235295d
Part-of: odoo/odoo#110610
2023-01-20 21:57:12 +01:00
Michael (mcm) 28df053a51 [FIX] web: don't add hotkey if readonly statusbar
Before this commit, the statusbar added a hotkey even if
it was readonly or non clickable.
Because of this, the user could change the status with a hotkey.

Now, if the statusbar is readonly or non clickable then
the hotkey won't be available.

closes odoo/odoo#110262

X-original-commit: 9569b4f463b6e82df3c8eafb8bd4329faac871b1
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Michaël Mattiello <mcm@odoo.com>
2023-01-18 17:38:23 +01:00
Joseph Caburnay 84d9cb9271 [IMP] web: auto-select content on focus for autocomplete (e.g. m2o) fields
On first focus in an autocomplete field, the text content of the input element
is automatically highlighted.

closes odoo/odoo#109025

Task-id: 3117420
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-01-09 12:22:46 +01:00
Michael (mcm) 50d23d6253 [FIX] web: support multi select in domain selector
Before this commit, domain selector did not support
selection field with "in/not in" operator because the
field does not accept these operators.
This commit adds the support as the operators can still be used.

closes odoo/odoo#108628

X-original-commit: 8ddd5e60f34f2ae9ca52fe936dc8da7054d1dc5e
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-01-02 13:55:45 +01:00
Michael (mcm) 4d520d1679 [FIX] web: show correct domain operator
Before this commit, the domain selector did not list the
operator if it is not accepted by the field
i.e. [['state', 'in', ['draft']]] is not listed in the domain
selector because "in" is not accepted by a selection field.

Now, the domain selector shows the operator even if it
is not accepted by the field.

X-original-commit: 2ae3adbce8cae17116f96f0a86296e41faf55246
Part-of: odoo/odoo#108628
2023-01-02 13:55:45 +01:00
Bastien Fafchampsandluvi 26a1eee340 [ADD] web: add SelectMenu component
This commit adds a new SelectMenu component. This component makes it
possible to search for options for a select element. It can be used to
replace the jquery select2 element for most cases.

Changes have been made to the Dropdown component as well as the position
hook, to allow the menu to be placed with the same width than the toggler,
using the 'fit' variant. Tests have been added to assert this position
feature.

Tests have been added to make sure the behavior of this component is
working as expected, and let the core element's usage being asserted.

Part-of: odoo/odoo#106265
Co-authored-by: luvi <luvi@odoo.com>
2022-12-23 17:03:36 +01:00
luvi 6a7b3dedaf [IMP] web: position_hook supports fit variant
This commits adds another variant to the position hook. This one allows
a popper to be positionned next to a side, having the same dimension from
this side. A classname is then added to the popper, allowing the element
to be stylized depending of the side it's fitting.

Possible values:
(bottom/top)-fit would give the same width as the reference
(left/right)-fit would give the same height as the reference

Tests have been added to make sure those dimensions are correctly
applied when using thr fit variant.

Part-of: odoo/odoo#106265
2022-12-23 17:03:36 +01:00
Michael (mcm) 296413a616 [IMP] web: edit view in current action
Before this commit, editing views from debug menu opened a dialog
and the user needed to refresh the page to see the changes.
Now, the edit view is opened in a new action so when the user goes back
in the breadcrumb, the view is updated.

task id: 3081332

closes odoo/odoo#108524

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-12-23 12:11:03 +01:00
Samuel Degueldre f7f16bd85d [FIX] web: correctly log full traceback for uncaught errors
Previously, we added some handling so that errors that were not
defaultPrevented would have their traceback logged by the error service
instead of the default behaviour of the browser, because not all
browsers correctly log error chains (errors with causes). This did not
actually work because the errorEvent was written on the object at the
top of the error chain and checked on the error at the bottom of it.

This commit fixes that by just looking at the event on the uncaught
error.

closes odoo/odoo#108463

X-original-commit: cefba026ad7fe453da840a948e25d29d4d1837e9
Signed-off-by: Géry Debongnie <ged@odoo.com>
Signed-off-by: Samuel Degueldre <sad@odoo.com>
2022-12-23 12:10:55 +01:00
Bruno Boi ff619c4761 [FIX] web: repair keynav in dropdowns
- Before this commit
Keyboard navigation in dropdowns lead to a traceback

- Explanation
The traceback happens in the bootstrap library.
When upgrading to bootstrap v5.1.3 (see c48f57e), a fix done in the
previous bootstrap version was lost (see 78f85f2).
This previous fix also added a test but it was not enough to
detect the issue when the bootstrap lib was upgraded.

- After this commit
This commit reintroduce the same previous fix and adapts the test,
hoping it would be enough for future changes to not break further
the expected behavior.

closes odoo/odoo#108080

X-original-commit: daca8fe4e3da4a5ad5fabf3730496a3919af8abc
Signed-off-by: Georis François (fge) <fge@odoo.com>
Signed-off-by: Bruno Boi (boi) <boi@odoo.com>
2022-12-15 15:45:18 +01:00
Aaron Bohy 79727cca9c [FIX] web: AutoComplete: do not crash on "Enter"
Before this commit, there were two kind of related issues with the
AutoComplete component, involving an "Enter" keydown.

1) Click in an empty Autocomplete input s.t. the (only) source has
   no option, then press "Enter" -> crash
2) Enter something in an Autocomplete input s.t. there are results
   in the dropdown, then update the input again s.t. the (only)
   source has no option, then press "Enter" -> crash

This commit fixes those two issues by
1) Ensuring that we don't store in the state an option index that's
   out of range with respect to the current available options
2) Reseting the options when reloading the sources.

Those issues were reproducible on the Company form view, by using
the company name field (which uses partner_autocomplete).

closes odoo/odoo#107982

X-original-commit: 390a9b589495e67235b15137ccc510b76350443f
Signed-off-by: Michaël Mattiello <mcm@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-12-14 22:04:15 +01:00
Ricardo Gomes Rodrigues (rigr) 5376b60af0 [IMP] base, web: add not like and not ilike operators for the JS Odoo domain
Currently the `not like` and `not ilike` operators are available for the Odoo domain in Python but not in JS.

This commit adds these two operators in the JS Odoo domain too for better code clarity. For instance:
`[('fiscal_country_codes', 'not like', 'AR')]`
instead of
`['|', ('fiscal_country_codes', 'like', 'AR')]`

Part-of: odoo/odoo#106221
2022-12-09 11:48:42 +01:00
luvi cc411a5076 [IMP] web: only enable spellcheck on focused inputs
This commit adds the ability to enable spellcheck on input/textarea only
if they are in focus. This avoids the UI to be bloated with unwanted
underlined text on unfocused elements. It is especially useful in a context
of form view in always edit mode.

A core hook has been introduced to allow other components to use the same
behavior without reimplementing it. It is currently used by the TextField.
It means it is also used in the HtmlField. Tests have been written, both for
the field component, and the core hook.

task #2861428

Part-of: odoo/odoo#106866
2022-12-07 18:29:10 +01:00
fdardenne 8414b797c3 [FIX] web: hotkey_service: replace by space
Pressing `<space>` in browsers results in a ` ` event key.
We don't want this event key as ` ` is not recognized and not
whitelisted in the hotkey service.

Instead we want to use `space` because it is more readable in the
codebase.

Part-of: odoo/odoo#99050
2022-11-30 15:06:00 +01:00
Samuel Degueldre 2b33d2113e [FIX] web: make originalError the root of the error chain
Previously, when calling error handlers, we would give them a new error
created by the error service, as well as an `originalError` which is the
error that was caught by the error service. In some cases, this error is
part of an error chain, eg: errors that happen in the owl lifecycle are
wrapped in an `OwlError`, so that when an error occurs in a callback
passed to a lifecycle hook, the position where the hook was called to
register the offending callback is part of the stack trace.

In practice, most error handlers only care about the error that caused
the entire error chain (the root) when deciding whether they should
handle the error or not, eg: an RPCError should be handled by the rpc
error handler, regardless of whether it occured in an event handler or
in a component's willStart. It already reads the traceback to display on
the UncaughtError provided by the error service as this traceback
contains the entire error chain stack information and is annotated with
source maps by the error service.

This commit makes it so that the `originalError` passed to handlers is
now the root of the error chain, it also sets the `cause` of the
UncaughtError which is passed to handlers as the error that was caught
by the error service, so that if a handler needs to inspect the error
chain to know whether it can handle the error or not, it can still do
that.

related to OPW-3069633

closes odoo/odoo#106720

X-original-commit: dd6f103b1635868e03a7aa40eb7186861d22d377
Signed-off-by: Michaël Mattiello <mcm@odoo.com>
Signed-off-by: Samuel Degueldre <sad@odoo.com>
2022-11-28 18:51:47 +01:00
Bruno Boi 7f257a2025 [FIX] web: popovers and arrows repositioning
**Before this commit**
When a popover is shown and then repositioned to a different placement
(i.e. due to window scrolling or resize), its arrow is misplaced.

This is due to the fact that classnames added in order to correctly place
its arrow are just added to the previous ones instead of replacing all
the needed classnames.

**After this commit**
The classnames are now properly replaced instead of just being appended.

closes odoo/odoo#106495

X-original-commit: c54cc2f87930147b5addb6f447574c677ef3504d
Signed-off-by: Luca Vitali <luvi@odoo.com>
2022-11-28 14:51:16 +01:00
Bruno BoiandLuis González 29ca002ee5 [FIX] web: menus missing aria attributes
Some missing aria attributes from 14.0 are reintroduced.

They are required for screen reader users to be able to know if menus
are opened and if menuitems are checked (e.g. if a filter is applied).

closes odoo/odoo#106277

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Bruno Boi (boi) <boi@odoo.com>
Co-authored-by: Luis González <lgonzalez@vauxoo.com>
2022-11-23 13:24:51 +01:00
Bruno BoiandLuis González 192e80c03e [FIX] web: dropdown unusable by screen readers
Dropdown menus/items were refactored and moved to OWL when migrating to
15.0. Now, the focus is always on the dropdown button, which captures
and handles all keyboard events, to be able to move over the menus.
Currently-selected item is highlighted by toggling classes.

However, since the focus is always on the dropdown button, screen
reader users are  no longer able to know what menu item is being
selected, as it's only a visual change (in previous versions, the focus
actually moved to the selected element).

The above is fixed by making the activeElement follow the visual change.

Part-of: odoo/odoo#106277
Co-authored-by: Luis González <lgonzalez@vauxoo.com>
2022-11-23 13:24:51 +01:00
Denis Ledoux 5631887594 [FIX] web: "Set Defaults" feature from the debug menu
Since odoo/odoo#99660
the `depends` field attribute is no longer passed
from the server to the web client.

Because of this, the "Set Defaults" feature
of the debug menu is completely unusable,
as the list of fields on which to set a default is empty because of it.

The use of this `depends` field attribute has been introduced in
revision odoo/odoo@ce9bbf6c10
In the commit description, we can read that setting a default
on computed fields having depends has been disabled
because the defaults set were being overwritten by the call to onchange.
Note that only the fact the field has depends is required,
the actual list of field names is not used, just the fact the list is
not empty.

However, since revision
odoo/odoo@488e334fc8,
available since Odoo 14.0,
this is no longer the case, the defaults are no longer being overwritten
by the call to `onchange`, since the `default_get` has been integrated
into the `onchange`.

A video attached to the pull request of this revision
shows the behavior difference.

Hence, setting a default on a computed fields having depends
(with an inverse method, hence not readonly)
can be allowed again in this "Set defaults" debug feature,
therefore avoiding to have to send back the `depends` field attributes
to the web client.

opw-3031290
opw-3038711
opw-3055292

X-original-commit: 48ac799288e76a0256b9ce0712a70ed5abc0f62e
Part-of: odoo/odoo#105251
2022-11-21 14:56:53 +01:00
FrancoisGe 1c5fe423f2 [IMP] web: add isAvailable in options command
This commit adds the isAvailable option to the command. If you set this
option, then it determines if the command should be displayed or not
in the command palette.

Why add this option?
We want to allow a component to define a command that will be displayed
according to the internal state of the component

Part-of: odoo/odoo#91821
2022-11-14 17:17:47 +01:00
FrancoisGe 86824d8e0c [FIX] web: search in a m2o block the ui
Before this commit, performing a search in a m2o can block your ui
despite the result already being displayed.

Why?
When you perform your search in a m2o, a set of RPC queries are made
with the different search values (name_search). If the last search value
(the one that will be used by the m2o in its autocomplete) has already
been resolved, but one of the other RPCs has still not been resolved,
then the screen will remain blocked until all the rpc's have been resolved.

Solution:
Since we are only interested in the last rpc, we will cancel all the
others. So with each new rpc, we will cancel the previous one.

How to reproduce:
- Go to a form view with a m2o field
- Edit this field +- slowly (several rpc will be done with different values)
- Receive the result of the search. (The autocomplete is displayed with
     the right values)

Before this commit:
If one of the other rpc's is not yet resolved, the ui will block
until all rpc's are resolved.

After this commit:
The ui will not block.

closes odoo/odoo#105269

X-original-commit: 9917d841fa38ccc1e6d67875a665494dc22ef92f
Signed-off-by: Samuel Degueldre <sad@odoo.com>
2022-11-14 14:20:42 +01:00
Aaron Bohy 98095e082f [FIX] web: AutoComplete: don't show previous results
... when re-opening the dropdown.

Before this commit, in an autocomplete component with an async
source, when:
 - clicking on the input to open the dropdown,
 - then typing something to filter the results
 - then selecting one of them (which closes the dropdown)
 - and finally re-opening the dropdown:
the previously displayed (and filtered) results were briefly
displayed, while the source was being fetched again. It thus
produced a weird and annoying flickering.

This commit fixes the issue by reseting the source before fetching
it.

closes odoo/odoo#105539

X-original-commit: 83769b00837f4eea29586f53709d65d3078ddce3
Signed-off-by: Michaël Mattiello <mcm@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-11-10 13:15:56 +01:00
Julien Mougenot cda3396546 [FIX] web,project: Restore kanban drag&drop in Firefox
Before this commit, the drag & drop feature for the Project "Tasks"
kanban view did not work if the drag sequence was initiated from the
title of the card.

This was due to the "o_kanban_record_headings" class having the CSS rule
`overflow: hidden`, because of a well known 6 year-long-and-counting
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1352061

Namely: mouse enter|leave events won't fire on anything underneath
elements having `overflow: hidden`.

This commit solves this issue by introducing a dedicated class name
'o_dragged' to all elements dragged using the `draggable_hook_builder`,
and defining on it the CSS attributes that were assigned in JS before,
as well as `pointer-events: none` on itself and all its children to
avoid the issue mentioned above.

Also in this commit: fixed a syntax error in a CSS rule in project's
"task_name_with_subtask_count_char_field" widget.

closes odoo/odoo#105353

Related: odoo/enterprise#33774
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-11-10 12:21:57 +01:00
Jorge Pinna Puissant 4f24e34b39 [IMP] test_lint, *: eslint remove caughtErrorsIgnorePattern from no-unused-vars
Unused catch block arguments are now forbidden even when prefixed with an
underscore:  if the argument on the catch block is not needed, the use of the
optional catch binding is enforced.

Part-of: odoo/odoo#105433
2022-11-09 16:08:07 +01:00
Lucas Lefèvre 080160de54 [FIX] web: reject race promise when first promise rejects
The Race concurrency promise never settles if the first settled promise
rejects and therefore you can't catch the rejected promise.

closes odoo/odoo#104733

X-original-commit: 24cc8cdb440a5af944d82a25d98b0239e72e2625
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
2022-11-02 15:34:41 +01:00
abd-msyukyu-odoo 64d48616c9 [FIX] knowledge: make removeContextUserInfo a web asset
removeContextUserInfo was a Spreadsheet asset, which is not a dependency of
Knowledge.

In order to make this feature available for all modules, it is moved in web as
an object util, that needs to be used alongside the user service in order to
dynamically remove user context information (no hardcoding).

Task-3017349

closes odoo/odoo#104304

X-original-commit: fd88fc1bbad4c0cdb44cf634b6a5621eb7597e0d
Related: odoo/enterprise#33322
Signed-off-by: David Beguin (dbe) <dbe@odoo.com>
2022-10-27 15:41:21 +02:00
Joseph Caburnay c412f11c02 [REF] web,web_*: import owl features using "@odoo/owl" module
In @odoo-module files, we do the following conversion:

`const { ... } = owl;` -> `import { ... } from "@odoo/owl"`.

While in legacy odoo module (odoo.define):

`const { ... } = owl;` -> `const { ... } = require("@odoo/owl");`.

closes odoo/odoo#104260

Task-id: 3032274
Related: odoo/enterprise#33298
Signed-off-by: Géry Debongnie <ged@odoo.com>
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2022-10-27 14:41:17 +02:00
Jorge Pinna Puissant 886f3de768 [IMP] web,*: force props validation for components
*: base_automation, lunch, mail, mrp, project, web_editor, website

This commit adds a warning if the props validation is not set for a
component.

The props validation is important to tell how a component should be
used, by looking at its code, it's a good documentation of the component.
It's also critical, to test if the component is correctly used, if all
the obligatory props are passed and that there are of the correct type.

For more information, see: https://github.com/odoo/owl/blob/master/doc/reference/props.md#props-validation

closes odoo/odoo#103723

Related: odoo/enterprise#33044
Signed-off-by: Géry Debongnie <ged@odoo.com>
2022-10-26 16:07:18 +02:00
Bruno Boi a0f4957304 [FIX] web: moment.js to luxon's conversions
The web client exposes an utility function that converts the tokens
of a luxon's DateTime format into a moment.js format.
While this function is not false (still it is uncomplete), the strategy
of using it to convert a luxon's DateTime object into a moment.js moment
is not good.

The daterange field make use of this bad strategy.

Because of the differences between luxon and moment.js locale handling.
Luxon relies on the native JavaScript Intl API.
Moment has its own implementation of locale handling.

So having to pass through formatters/parsers may yield to unexpected
results. For instance, when a locale does not have the same way (in
moment.js and Intl) to express i.e. months and we try to convert a
luxon's DateTime into a moment by formatting the first and then
parsing into the second, the second will be invalid. This is the same
the other way around.

This was in fact encountered with some locales, i.e.
- syrian arabic (ar-SY)
- albanian shqip (sq-AL)

This commit brings an alternative strategy by providing other utility
functions to directly convert a moment into a luxon's DateTime
and vice versa.

This is a better strategy for various reasons:
- it abstracts the way the conversions are done
- no need to play with timezone's offsets
- probably all libs that has moment as a dependency accept a moment
  object in their options, that may not be the case for formats

- The daterange field now use the new strategy
- The datepicker component now use the new utility functions as it had
  implemented locally something similar.

closes odoo/odoo#104138

X-original-commit: 9dedfcaa4ad1fb5ea24f604b40df1bf0830617cb
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
2022-10-26 14:05:53 +02:00
Aaron Bohy 3f12de691b [FIX] web: ConfirmationDialog: do not call confirm twice
Before this commit, multi clicking quickly on the "Ok" or "Cancel"
buttons of a ConfirmationDialog would call the confirm/cancel
callbacks multiple times. For instance, in "Mass mailing", create
a new mailing and click "Send". In the confirm dialog, clicking
quickly multiple times on "Ok" would call the "Send" button action
multiple times.

This commit also ensures that we wait for the promise of the
confirm callback before closing the dialog. This highlighted an
issue in the ORMBatcher, as we didn't reject the promise when
the batched rpc failed. As a consequence, the confirmation dialog
never closed itself. This has been spotted by an existing test.

Fixing #74647 (from 16.0 to master)

closes odoo/odoo#103572

X-original-commit: 95f8266a5b84f5faa59a713019ab713392b3ef78
Signed-off-by: Géry Debongnie <ged@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-10-20 10:19:58 +02:00
Mathieu Duckerts-Antoine e0b852bc6e [FIX] web: core: offset in to_utc
Take a PyDateTime representing the moment "2022-10-17 00:00:00" in
the timezone of Brussels. Trying to get the related utc moment through
to_utc gives wrongly "2022-10-16 23:00:00". This happens because the
months are not numbered in the same way in Date or PyDateTime, so that
in October for example, the offset applied was that of November which is
-60 instead of -120 (summer/winter change). We fix that problem.

closes odoo/odoo#103561

X-original-commit: a11e1fb5f702400fe51938362fe3f24570977ba9
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Mathieu Duckerts-Antoine <dam@odoo.com>
2022-10-19 18:06:59 +02:00
Joseph CaburnayandBruno Boi 390955b751 [FIX] web: fix traceback when shift-tab on list field
**Before**

A traceback is raised when pressing shift-tab on the first column of
the first row in a focused list field as shown in the vid:
https://youtu.be/g97ZTp1QdBE

**After**

shift-tab on the first column of first row will now unselect the list field
and immediately focuses on the previous field.

**Additional change**

We now allow skipping focus on the dropdown toggler by introducing new
props.

closes odoo/odoo#103485

X-original-commit: 9ba9977e42d201035b5299bc13ba03211cddbc1f
Signed-off-by: Bruno Boi (boi) <boi@odoo.com>
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
Co-authored-by: Bruno Boi <boi@odoo.com>
2022-10-19 12:10:41 +02:00
fdardenne 5ba91f1d69 [FIX] web: checkbox: deactivate onChange when disabled
Before, even if the checkbox is deactivated, clicking on it
cause an `onChange`.
This caused unexpected behavior, the form view changed to a dirty
mode even if the checkbox was in read-only mode and nothing
was modified.

Now, the checkbox does not call `onChange` when deactivated.

closes odoo/odoo#103429

X-original-commit: 4802c2528cfa23c5981fa30fa69cfa23f28faf05
Signed-off-by: Luca Vitali <luvi@odoo.com>
2022-10-18 17:12:04 +02:00
Sébastien Geelen (sge) e483ae5fb4 [FIX] web,web_editor,mail : Fix ModelFieldSelector and DynamicPlaceholder
Add missing feature of the ModelFieldSelector popover :
* keyboard navigation
* additional debug value
* add default value page ( for dynamic placeholder)
* add validate callback

Migrate dynamic placeholder to be compatible with new OWL field.

task-2978722

X-original-commit: 929108e29168058fad5da85e0ff9c66d2c5b2525
Part-of: odoo/odoo#102603
2022-10-07 14:37:20 +02:00
Mathieu Duckerts-Antoine 4044635677 [FIX] web: ModelFieldSelectorPopover: edition of path in input
Before this commit, it was not possible to edit the path via the
model field selector popover input (visible in debug mode). We fix that.

closes odoo/odoo#102462

X-original-commit: 084af201f1f4f4cb3476ab34d3dcd649a71a4254
Signed-off-by: Luca Vitali <luvi@odoo.com>
Signed-off-by: Mathieu Duckerts-Antoine <dam@odoo.com>
2022-10-06 19:04:25 +02:00
Michael (mcm) 2d97866f5a [IMP] web: hide relation in field selector
There was an option in the legacy ModelFieldSelector
that could be used to prevent following the relations.
This option was lost since the widget has been
converted. This commit simply reintroduces the option.

closes odoo/odoo#102308

X-original-commit: 673faab4dec7a0df434cf0575303df97a36db0f1
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-10-06 00:37:36 +02:00