The Race concurrency promise never settles if the first settled promise
rejects and therefore you can't catch the rejected promise.
closesodoo/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>
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
closesodoo/odoo#104304
X-original-commit: fd88fc1bbad4c0cdb44cf634b6a5621eb7597e0d
Related: odoo/enterprise#33322
Signed-off-by: David Beguin (dbe) <dbe@odoo.com>
*: 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-validationclosesodoo/odoo#103723
Related: odoo/enterprise#33044
Signed-off-by: Géry Debongnie <ged@odoo.com>
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.
closesodoo/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>
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)
closesodoo/odoo#103572
X-original-commit: 95f8266a5b84f5faa59a713019ab713392b3ef78
Signed-off-by: Géry Debongnie <ged@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
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.
closesodoo/odoo#103561
X-original-commit: a11e1fb5f702400fe51938362fe3f24570977ba9
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Mathieu Duckerts-Antoine <dam@odoo.com>
**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.
closesodoo/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>
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.
closesodoo/odoo#103429
X-original-commit: 4802c2528cfa23c5981fa30fa69cfa23f28faf05
Signed-off-by: Luca Vitali <luvi@odoo.com>
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
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.
closesodoo/odoo#102462
X-original-commit: 084af201f1f4f4cb3476ab34d3dcd649a71a4254
Signed-off-by: Luca Vitali <luvi@odoo.com>
Signed-off-by: Mathieu Duckerts-Antoine <dam@odoo.com>
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.
closesodoo/odoo#102308
X-original-commit: 673faab4dec7a0df434cf0575303df97a36db0f1
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Click on the back button in the model field selector popover used to
often remove too many names in the path created via the selector. For
example, starting with "partner_id.name" and clicking on the back button
in the opened popover would give the invalid path "" instead of
"partner_id". We fix that problem.
closesodoo/odoo#102156
X-original-commit: e4a7b63c68a87d7afef987e8d036d7ba9c5b6f96
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Mathieu Duckerts-Antoine <dam@odoo.com>
In a domain selector, have a selection field and the operator "is set"
selected, then change the operator to be "=". A crash occurs. This
happens because the category of operator change and thus the function
onDidTypeChange of DomainSelectorSelectionField is called with no
parameter. The same problem can happen with DomainSelectorDateTimeField.
We fix that by calling component.onDidTypeChange with the right
parameter in any case.
X-original-commit: a01c2473d93d0d123391ba0131ad505775b3c50b
Part-of: odoo/odoo#102156
A new useDraggable hook is introduced and used in the various components that
use the feature.
It relies on the draggable hook builder which is a generic way to prepare
specific drag and drop features.
X-original-commit: cb1cfe5f5efe1b683d7fdffde3718bd8bf1bcd86
Part-of: odoo/odoo#102153
The event listeners were added to the upload object instead of the xhr
object making them being called before they were supposed to.
closesodoo/odoo#102061
X-original-commit: 804467d7b0a583ab36a47212d482b41d29ca2203
Related: odoo/enterprise#32247
Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
Have a many2one field in a form view, and try to quick create a
record. If the name_create returns an error (e.g. ValidationError
in the model), the many2one field opens a form in a dialog (aka the
slow create). It thus properly handle the error.
However, before this commit, the error returned by the RPC was also
displayed in its own dialog (behind the form dialog).
This was due to a mistake in the Mutex, which forks the promise
returned by the registered action. When that promise was rejected,
the forked one was thus rejected as well, and it wasn't caught.
That later promise is only used to unlock the mutex, so we can
safely catch it.
closesodoo/odoo#101549
X-original-commit: fe9e044b9e03ac7fff5d314e6e207921a15c8965
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit moves the inline handlers of the `useSortable` hook
calls in the list and kanban renderers to proper class methods.
This allows said handlers to be overridden in child classes.
closesodoo/odoo#100986
X-original-commit: ec5ab1d389a0bdfb37c8b2c6766b6be1330085a7
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
The useChildRef (used with the useForwardRefToParent hook) allows
to retrieve, from a parent component, a t-ref from a child.
Consider the following scenario:
- have a parent calling useChildRef
- have a conditional (with t-if) child calling useForwardRefToParent
- in the initial rendering, the child is displayed
-> ref.el points to the correct html element
- re-render s.t. the child is no longer displayed
-> ref.el is null, because the referenced element doesn't exist
- re-render s.t. the child is displayed again
Before this commit, at this point, ref.el will always be null,
even though the corresponding element comes back into the DOM. This
commit fixes the issue by correctly updating the ref, each time the
useForwardRefToParent hook is called.
closesodoo/odoo#100937
X-original-commit: 78d39c79993d1d63c189164f8104e5a3c90f2efd
Signed-off-by: Géry Debongnie <ged@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
The purpose of this commit is to improve the domain selector UX with
multiple little changes:
- The model field selector popover is now autofocused when opened
- Removal of a div that appeared during a hover on "add leaf" and
"ellipsis button"
- Caret icon next to the root node selector
- Minor CSS changes
task-2861497
closesodoo/odoo#99321
Signed-off-by: Géry Debongnie <ged@odoo.com>
Before, the small "caret" to the right of the dropdown was only
displayed if the current Dropdown was a child of another Dropdown.
It is sometimes necessary to display this caret in a parent
`Dropdown` in order to make the user understand that there is a
dropdown if he clicks on the text.
Now, it is possible thanks to a props to display manually this carret
if desired.
Part-of: odoo/odoo#99321
"Notebook" component had to be adapted to make the use of tabs
more consistent trough the app. The component now allows a use of
default tabs style in a vertical display
task-2950591
Part-of: odoo/odoo#98706
XML files are now declared in python module manifests. During the qweb
't-call-asset' directive, assetbundle will fetch the declared xml files,
apply the inheritance (t-inherit) and create a javascript service (for
eg: 'web.assets_backend.bundle.xml') which is added at the end of the
*.js mimifier file.
When the debug mode is activated, comments are added in the template
indicating which file the template comes from as well as the
inheritances applied to it.
****
JavaScript:
assets.js (module @web/core/assets) takes care of loading libraries,
javascripts and styles.
`loadJS(url)` (loads the javascript and returns a resolved promise when
the templates are also loaded via the '*.bundle.xml' service)
`loadCSS(url)` (loads the style a resolved promise when the file is
loaded)
`loadXML(xml, app=assets.defaultApp)` (load template into
application/owl, used by the `*.bundle.xml` services)
`getBundle(bundleName)` (get the bundle descriptor)
`loadBundle(desc)` (load the files and bundle from a descriptor)
templates (XML element content all owl templates)
A new `ready(serviceName)` method on boot.js lets you know when a
service is loaded are the require.
The xmlDependencies attribute no longer exists.
Python:
The xmls taken into account by assetbundle.py, applying `t-inherit`
inheritances and adding an `name_of_the_bundle.bundle.xml` service in
the generated JavaScript file.
****
Every manifest changes is into the next commit, except 'web_tour' in
this current commit as example.
Part-of: odoo/odoo#95500
This views has multiple custom features such as file upload, attachment
viewer and download.
A lot of files have been rendered obsolete and have been deleted,
notably `file_upload_mixin` which has been replaced by the
file_upload service and hooks.
closesodoo/odoo#99769
Related: odoo/enterprise#31145
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Since owl now uses error chains/causes when errors happen in the owl
lifecycle, when an error happens in the owl lifecycle, the displayed
tracebacks generally only contain the stack trace of where owl called
the corresponding lifecycle hook.
This commit modifies the error service and the error utils so that now,
when completing/annotating a traceback, we also add the tracebacks
(annotated when appropriate) of the error cause chain, as it contains
valuable debugging information.
This commit also makes it so that the QUnit suite logs the source of
each test failure (which may be an error with a chained stack trace)
closesodoo/odoo#98157
Signed-off-by: Géry Debongnie <ged@odoo.com>
Have a form view with a notebook.
In the notebook a page has autofocus, and is also invisible in some
circumstances.
Before this commit, the default page was always displayed, even if invisible,
its anchor was not selected though.
After this commit:
- if the default page is visible, display it.
- if the default page is not visible, select the first visible page
- if the default page was visible and the page has changed, don't select the default page at next render
- if the default page was not visible and becomes visible, select it at next render
closesodoo/odoo#97742
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
- Name of the test
"utils > dates > parse smart date input"
- Before this commit
The test makes a comparison between the result of parse utils,
which yields luxon's DateTime objects in the user's local TZ
(patched by default to UTC+1 in the testing env), and locally
created DateTime objects in UTC.
This has no sense to compare a date in UTC with another in UTC+1.
The test was thus failing when ran between 11pm and 0am.
- After this commit
The test has been refactored.
Also, even if it has no impact on the parsing result, the local function
parseSmartDateInput now use a DateTime object in local TZ.
This has been done in order to avoid future confusion.
If you're wondering why it has no impact, it is because this function is
used in parseDate(Time), which always sets the local TZ at the end:
```
const a = {
foo: luxon.DateTime.local(),
bar: luxon.DateTime.utc(),
};
a.foo.equals(a.bar.setZone("default")); // true
```
closesodoo/odoo#99616
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Connect in your browser to a db on runbot with mail installed and wait
until the runbot put to sleep the db. After a while, a new request to
get im_status will be sent and nginx responds to it with an error 404
and an invalid JSON response. A traceback with a particularly bad
message is then shown. Here we improve the traceback message.
closesodoo/odoo#99430
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commits fixes the behavior of the confirmation dialog.
When a user dismiss a dialog using the close button or the
ESCAPE key, it should expect to execute the cancel action,
if any had been given to the dialog.
The behavior was missing, and the dialog was simply closed.
Tests have also been added, since this core component didn't
have any test since its introduction.
closesodoo/odoo#99418
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
On Chrome, have a field that supports autofill (you have to have set up an adress in Chrome first).
Click on that field, and apply the autofill proposition.
Before this commit, there was multiple crashes, roughly one for every handler of event `keydown`.
This was caused by the fact that the autofill feature triggers keydown events without the field `key`.
(https://bugs.chromium.org/p/chromium/issues/detail?id=581537, I could not find a better ticket).
This seems to be a bug on Chrome's side, since the spec doesn't mention that field may be unset (https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key).
After this commit, there is no crash.
closesodoo/odoo#99348
Signed-off-by: Bruno Boi (boi) <boi@odoo.com>
The goal is to improve the dates utility functions (parse/format) by removing the timezone option, which is difficult to understand and has proven to be error prone.
- Rationale
When manipulating DateTime objects on the JS side, associated timezones
must be always coherent.
Until now, there were several code parts that had to check the DateTime
timezone and handle things differently in a case or another.
This sometimes lead to wrong code.
E.g. there was a bug in the DatePicker component because the DateTime
object it receives in props is in local timezone, but once it updates it
through the parse utility, the new object is in UTC.
- After this commit
The DateTime objects you'll get through deserialization or parsing are
always set in the user's local timezone.
The formatted strings you'll get through formatDate and formatDateTime
utils will always be expressed in the user's local timezone.
The formatted strings you'll get through serialization utils will always
be expressed in UTC.
- serializeDate and serializeDateTime
- expected input: a DateTime object (its timezone does not matter)
- outputs: a string formatted for the server expressed in UTC
- formatDate and formatDateTime
- expected input: a DateTime object (its timezone does not matter)
- outputs: a string formatted for the user, expressed in the user's TZ
- deserializeDate and deserializeDateTime
- expected input: a date(time) string provided by the server, in UTC
- outputs: a DateTime object in user's TZ
- parseDate and parseDateTime
- expected input: a date(time) string provided by the user, in its TZ
- outputs: a DateTime object in user's TZ
- Other changes in this commit
As the timezone option has been removed from parsing/formatting utils,
all their usage had been adapted in the codebase.
The large diff in dates_tests.js is because some tests were reorganized,
others were removed/adapted/joined.
A test has been removed from daterange_field_tests.js, because it has
no sense: it displays a date field as a datetime, but a date field does
not have any time information.
Part-of: odoo/odoo#98980
Co-authored-by: Julien Mougenot <jum@odoo.com>
Have a date picker component in a dropdown (like in Add Custom Filter),
open the related bootstrap datepicker by clicking on the date picker
input and select a date: the dropdown closes. In this fix, we make the
dropdown stay open in that situation.
closesodoo/odoo#99345
Signed-off-by: Bruno Boi (boi) <boi@odoo.com>
Setting [(1, "=", 1)] as domain in the debug text area would make crash
the DomainSelector component because the sub component ModelFieldSelector
would not accept 1 as a fieldName prop due to its props validation. We
fix that by converting 1 to a string.
Part-of: odoo/odoo#99207
Co-authored-by: Michael Mattiello (mcm) <mcm@odoo.com>
This commit standardizes the API of orm service functions by adding
a "kwargs" parameter, s.t. one can always use those functions even
if the target model overrides the corresponding method to add the
support of a given kwargs. Furthermore, to simplify those function
API, and to close the gap between the js and python APIs, we moved
the "context" argument inside the kwargs.
closesodoo/odoo#99018
Related: odoo/enterprise#30830
Signed-off-by: Samuel Degueldre <sad@odoo.com>
This commit changes the API of the "create" function of the orm
service to better reflect the API of the corresponding method in
models.py, which takes a list of record values in argument.
Before this commit, a call to "create" only allowed to create a
single record.
Part-of: odoo/odoo#99018
Before this commit, the "read" function of the ORM service didn't
allow to pass any kwargs. As a consequence, it wasn't possible to
call the "read" method of a model with "load" kwargs specified.
This commit fixes the issue, and adapts existing calls accordingly.
Part-of: odoo/odoo#99018
Purpose
=======
For security reason access on ir.model is not granted to internal suers. Due
to this constraint a component exists in spreadsheet to be able to select
the models for which we have a read access on the records of this model.
This is required for the properties fields feature, hence moving its code
to web.
Some renaming is performed to make it generic. This generates some changes
in other addons, notably some class renaming.el.
Task-2852259
Part-of: odoo/odoo#95184
Before this commit, clicking on any part of a kanban record would
initiate a drag & drop sequence, this included its dropdown. This caused
2 issues:
- You could start to drag & drop records by dragging their still opened
dropdowns ;
- Said dropdowns would remain open when dragging their parent record.
This commit fixes both of these issues by hiding dropdowns during drag
sequences and preventing drag when clicking inside the dropdowns.
closesodoo/odoo#98791
Signed-off-by: Simon Genin (ges@odoo) <ges@odoo.com>
This commit adds a new parameter to the 'useSortable' hook that allows
HTML elements to prevent a drag sequence. This 'ignore' param can be a
string or a function returning a string, that will be a selector
targetting the elements that need to prevent drag & drop sequences.
Part-of: odoo/odoo#98791
This commit introduces an object parameter to the "useAutofocus" hook,
that has 2 new optional keys:
- "refName": to override the ref "autofocus" (effectively allows to run
the hook multiple times)
- "selectAll": selects the whole value of the input/textarea (instead of
putting the cursor at the end).
Part-of: odoo/odoo#97411
Before this commit, pick did not work on non-enumerable properties.
For example, getters in a class are non-enumerable properties. It was not
possible to pick the value of a getter in a Class with the pick function.
closesodoo/odoo#97558
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Previously, when registering a hotkey without an area then a hotkey with
area, there would be a crash, as that latest hotkey is the candidate
winner, and we then check that there is no other matching hotkey with an
area that's more specific. In doing this, we assume all other candidates
have an area and call it as a function, but since some hotkey
registrations don't have one, we get a crash.
This commit fixes that by filtering the candidates to only those which
have an area before trying to narrow down to the most specific one.
Part-of: odoo/odoo#98535
# Before this commit
Serializing a date would apply the TZ offset of
the luxon's DateTime object in which it is contained.
This sometimes led to output the wrong date.
# After this commit
Serializing a date contained in a luxon's DateTime object
will not apply any TZ offset and will output a serialized version as-is.
# Note
If you still want to apply the TZ offset, you should do it manually:
const toSerialize = date.setZone("utc");
const value = serializeDateTime(toSerialize);
closesodoo/odoo#98194
Related: odoo/enterprise#30469
Signed-off-by: Julien Mougenot (jum) <jum@odoo.com>
This commit fixes the recently converted color_picker field
widget. It is now always opened in a list as in legacy,
no longer togglable and many style issues have been fixed.
In form views, we still toggle the opened state because
always edit is coming and it would bloat the UI to
keep it always open.
Tests has been added/modified to assert those desired
behaviors.
closesodoo/odoo#97872
Signed-off-by: Simon Genin (ges@odoo) <ges@odoo.com>
Have a domain declared somewhere in the XML as:
`("&", ("field", "=", "value"), ("field2", "=", "value2"))`
Before this commit, that expression made the Domain algorithm crash, because tuples
were not allowed.
After this commit, only tuples containing at least one other tuple and some optional strings are accepted.
closesodoo/odoo#97850
Signed-off-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Before this commit, in a touch device the behaviour was a
"tap-hold-to-show” which let the user see the Tooltip by pressing the
element, and letting it disappear when the pressure ends.
This commit allows choosing between the previous "tap-hold-to-show"
behaviour and a new "tap-to-show" which let the user see the Tooltip by
pressing the element, and keep it open until it press something else.
This behaviour is more adapted when the tooltip is on a specific icon,
as is the case for the labels, since : f981c5f8f0closesodoo/odoo#97680
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
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
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