Commit Graph
454 Commits
Author SHA1 Message Date
Pierre Paridans eef262abf4 [FIX] *: adapt QUnit tests and tours
[FIX] *: selectors in tours

[FIX][TMP] account: CogMenu selector in tours

[FIX][TMP] web*: Breadcrumb targetting in tours

Adds a `o_breadcrumb` class to target the whole breadcrumb, no matter
how much elements it contains (collapsed parts, visible path, single
name...).

add classname on last breadcrumb item

[FIX][TMP] project: View buttons selector in tours (moved away from CP)

[FIX][TMP] project: Kanban selectors in tours (quick create)

[FIX][TMP] *: SearchBar selectors in tours (toggle menu)

[FIX][TMP] *: ButtonBox selector in tours

[WIP][IMP] web: add toggleSearchBarMenu in search helpers

adapt and unskip 3 list tests

adapt and unskip calendar tests

unskip web_tour test that actually pass

post rebase fix

allow to lose cell focus after multi edition (given to searchbar) - bug reported, to check later

post rebase fixes

fix

Part-of: odoo/odoo#116641
2023-05-12 22:59:22 +02:00
Julien Mougenot caf40dfe2d [IMP] web: Improve date utils & localization consistency
This commit introduces various improvements to simplify, speed-up and/or
strengthen consistency in the date utility functions and localization
service.

It also takes care of removing luxon<->moment conversion helpers since
they are only used in the date picker, which has been rewritten.

Part of task 3121497

Part-of: odoo/odoo#112171
2023-05-05 13:52:21 +02:00
Julien Mougenot 7874bf3fc1 [IMP] web: Function fieldDependencies + utils doc
This commit does the following in the Web module utilities:

- makes the `fieldDependencies` property of the field objects
definitions a function instead of a list of strings: this makes it
possible for fields to extract their dependencies based on the fields
info from the arch;

- adds/improves types and documentation for some utility functions.

Part of task 3121497

Part-of: odoo/odoo#112171
2023-05-05 13:52:21 +02:00
Michael (mcm) 517d3258f2 [REF] web,*: add dependencies param to odoo.define
This commit makes the `dependencies` param of
`odoo.define` mandatory. It was optional and when
omitted, a regexp read the function to find the
dependencies. We can simplify it now almost all js
modules have been converted to esm.
The transpiler already adds the param for the es
modules except if the module has an alias.

task id: 3271352

closes odoo/odoo#119145

Related: odoo/enterprise#40040
Signed-off-by: Mathieu Duckerts-Antoine <dam@odoo.com>
2023-05-03 12:39:30 +02:00
Pulinckx Pierre (PIPU) 608e90e998 [REF] *: Replace underscore functions by native JS
Replace _.map(), _.flatten(), _.delay(), _.contains(), _.pluck(), _.isUndefined(), _.isEmpty(), _.isString(), _.isEqual(), _.isBoolean(), _.memoize(), _.invoke(), _.bind(), _.escape(), _.debounce(),
_.str.sprintf(), _.str.repeat(), _.str.startswith(), _.str.trim(),
_.str.escapeHTML(), _.str.escapeRegExp(), _.str.startsWith(), _.str.include()

closes odoo/odoo#118012

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2023-04-20 11:57:29 +02:00
Pulinckx Pierre (PIPU) 800223ae7c [REF] *: Replace underscore _.each() by native JS
Replaced _.each() functions (average 235 occurences)

Description of the refactoring this PR addresses:

Current behavior before PR:

There are underscore.js function enumerated above used in odoo.

Desired behavior after PR is merged:

These functions has been replaced by native javascript
prototypes/methods/functions.

TaskId : 3246238

closes odoo/odoo#118565

Signed-off-by: Georis François (fge) <fge@odoo.com>
2023-04-18 15:38:54 +02:00
Bruno Boi e9aced9d53 [FIX] web: close popover on mousedown away
**Before this commit**
The popovers will close on click away.
This makes impossible to start selecting text within a popover
using the mouse and finishing the move outside of the popover
(as it will get closed).

**After this commit**
Popovers will close on mousedown away instead, which is a general
standard for user interfaces anyway.

Part-of: odoo/odoo#118066
2023-04-13 16:40:18 +02:00
Samuel Degueldre 8d35700aaf [REF] point_of_sale, pos_restaurant, *: stop using legacy environment
*: web

This commit removes the use of the legacy environment from the PoS, as
it is no longer needed. This will allow us to more easily use the new
unit testing infrastructure from web.

Part-of: odoo/odoo#117290
2023-04-06 16:12:02 +02:00
Michael (mcm) 77e825cab2 [REF] web: replace odoo module by native one
This commit converts almost all odoo module by native module.
The goal is to deprecate odoo.define in favor of native module and then
simplify boot.js by removing the regexp that finds module dependencies.

task id: 3162300

closes odoo/odoo#117456

Signed-off-by: Géry Debongnie <ged@odoo.com>
2023-04-04 16:01:57 +02:00
Géry Debongnie 332c781ff6 [FIX] web: make mock_server implementation closer to orm
The mock server implementation does not exactly match the actual orm
implementation. It is not really a big deal, but it makes the test suite
less useful.

In particular, the onchange call should return a value for all fields
when we are creating a new record. Also, the default get implementation
was not exactly correct.

The motivation for this change is to prepare the future relational model
refactoring.

closes odoo/odoo#117434

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-04-03 12:56:54 +02:00
Michael (mcm) 8da2b52333 [IMP] web: introduce overlay service
This commit adds a new service "overlay" that will be used as a base
for other service which displays a component on foreground like
"popover" or "dialog". The services "popover", "dialog" and "effect"
already uses this new service to have a common container.

The "overlay" service also fix a stacking context issue that could
happen when a popover opened a dialog and this dialog then opened
another popover thanks to the common container.

task id: 3233266

closes odoo/odoo#115308

Related: odoo/enterprise#38786
Signed-off-by: Bruno Boi (boi) <boi@odoo.com>
2023-03-30 16:22:51 +02:00
Géry Debongnie 3db0ad01a1 [REF] web, *: rework webclient cache invalidation system
The web client has a mechanism to invalidate the action and the view
cache: in the basic model (and the relationalmodel), some code is
looking for updates to some specific models (such as ir.actions) and
trigger a `CLEAR-CACHE` event. This event is then listened by the action
and view services to properly clear the caches.  This mechanism was also
used to reload the page after editing a company, or reloading the
currencies after editing some currency.

With this commit, we modify the orm service to trigger an event after
each rpc. This event can then be used by the action/view service, and
also by the currency/company services to perform their specific cleanup.
This work is one step in the future refactoring of the relational model.

closes odoo/odoo#115655

Related: odoo/enterprise#38814
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-03-27 16:04:58 +02:00
7710c3331e [REF] mail, *: refactor Discuss
This commit refactors discuss code to use OWL components
and new tools and services in web/.
Functionally, Discuss app should work relatively the same as
before this commit.

closes https://github.com/odoo/odoo/pull/110188

Related:
https://github.com/odoo/enterprise/pull/38058
https://github.com/odoo/upgrade/pull/4423

closes odoo/odoo#110188

Related: odoo/upgrade#4423
Related: odoo/enterprise#38058
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Co-authored-by: Alexandre (aku) <aku@odoo.com>
Co-authored-by: Didier (did) <did@odoo.com>
Co-authored-by: Géry (ged) <ged@odoo.com>
Co-authored-by: Louis (wil) <wil@odoo.com>
Co-authored-by: Maël (mapa) <mapa@odoo.com>
Co-authored-by: Maryam (maki) <maki@odoo.com>
Co-authored-by: Sébastien (seb) <seb@odoo.com>
Co-authored-by: Thanh (tso) <tso@odoo.com>
Co-authored-by: Matthieu (tsm) <tsm@odoo.com>
Co-authored-by: Zelong (zel) <zel@odoo.com>
2023-03-17 11:47:09 +01:00
Xavier BOL (xbo) 9ae4a0d647 [IMP] web: manage bool_or and bool_and for boolean in mockServer
Before this commit, the `bool_or` and `bool_and` aggregations are not
managed in the mockServer.

This commit allows to use the `bool_or` and `bool_and` aggregators for
boolean fields in the read_group mock rpc.

task-2702636

Part-of: odoo/odoo#108605
2023-03-09 20:52:51 +01:00
Mathieu Duckerts-Antoine 94c2db94e0 [FIX] *: adapt code related to orm service create
The previous commit has as a side effect to change the value returned by
the create method of the orm service. Here we adapt the code that uses it
and make the test pass.

Part-of: odoo/odoo#111965
2023-02-20 19:25:00 +01:00
Mathieu Duckerts-Antoine 8780f0db25 [IMP] web: support of array_agg for integers and floats in mockReadGroup
Let us have records with values 1, 0, 77, 3 for a float field 'foo'.
read_group allows to get those values in an array with the aggregate
function array_agg:

read_group([], ["foo:array_agg", ...], []) will return

[{ __count: 4,  foo: [1, 0, 77, 3], ... }]

We now support the use of array_agg for integer and float fields in
the mock server.

closes odoo/odoo#112825

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-02-16 17:56:58 +01:00
Mathieu Duckerts-Antoine cdd6b74b11 [FIX] web: support of count_distinct for many2ones in mockReadGroup
mockReadGroup should not count the value false for a many2one when
aggregating a many2one field with the aggregate function count_distinct
and should always return a number. We fix that.

Part-of: odoo/odoo#112825
2023-02-16 17:56:57 +01:00
Mathieu Duckerts-Antoine 14f6ae8b5f [IMP] web: support of array_agg for many2ones in mockReadGroup
Let us have records with values false, 1, 2, 1, 1 for a many2one 'm2o'.
read_group allows to get those ids in an array with the aggregate function
array_agg:

read_group([], ["m2o:array_agg", ...], []) will return

[{ __count: 5,  m2o: [null, 1, 2, 1, 1], ... }]

We now support the use of array_agg for many2ones in the mock server.

Part-of: odoo/odoo#112825
2023-02-16 17:56:57 +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
Julien Mougenot 1ac6ae1801 [IMP] web: Add support for Elements in tests
Before this commit, some QUnit asserts and test helpers taking a
"target" param (or equivalent) would try to evaluate it, among other
possibilites, as an HTMLElement.

This is too restrictive however, as all these helpers can also be
performed on 'Element' instances (querySelector, classList, etc.), which
covers other sub-classes than HTMLElement, such as the whole range of
SVG Elements.

This commit changes the checks for `instanceof HTMLElement` to
`instanceof Element` instead to allow the helpers to be used on the
whole range of native Elements.

Part-of: odoo/odoo#110819
Co-authored-by: Julien Mougenot <jum@odoo.com>
2023-02-14 17:09:05 +01:00
Julien Mougenot 48bc5315da [IMP] web: Improve mockCopy and mockServer logging
This commit handles 2 things:

1. bring the mock server "copy" handler closer to its actual
implementation, supporting a second argument which is a dictionnary of
default values to be applied to the copied record;

2. make the mock server debug logs more readable, with a nice color code
(blue for requests, orange for responses) so that debug info are easier
to read in the console.

Part-of: odoo/odoo#110819
Co-authored-by: Julien Mougenot <jum@odoo.com>
2023-02-14 17:09:04 +01:00
Julien MougenotandMathieu Duckerts-Antoine d96b56f670 [IMP] web: Improve mockRead performance
This commit improves the performances of the mock server "read" handler
by reducing the amount of iterations performed on the current set of
records.

This was needed as some tests (namely: gantt manual performance tests)
mocked huge amounts of records and the main bottleneck was the mock
server, while the actual impact was supposed to be measured on the
rendering process.

Part-of: odoo/odoo#110819
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
Aaron Bohy 49297bc7bb [REM] *: remove legacy basic views + some fields/widgets
This commit removes the legacy implementation of the form, kanban
and list views. It also removes the legacy view widget registry,
and all legacy widgets it contained. The legacy field registry
couldn't be removed yet as some fields are still used (e.g. in
client actions: FieldMany2One, FieldMany2ManyTags...), and
sometimes accessed from that registry (e.g. uom service). More
clean up will come later. Note that all tests using legacy views
have thus been removed, even though the tested feature might still
remain (e.g. FieldMany2One tests have been removed, but that field
is still there). However, those features are deprecated and
unlikely to evolve. They should be removed in the next saas, or the
one after.

Finally, this commit also removes the legacy view dialogs.

Task 3168640

Part-of: odoo/odoo#111809
2023-02-08 13:27:58 +01:00
Géry Debongnie 3a5060c691 [REM] mail: remove remaining form renderer override
The mail code had to override both new and old form views to add the
chatter feature.  Since we converted (almost) all uses of the legacy
form view to the new owl views, the old override is no longer necessary.

This commit removes it, and also removes the 'legacy_form' entry in the
registry so all screens should fall back to the new form view, which is
stable.

closes odoo/odoo#110168

Related: odoo/enterprise#35924
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-01-18 13:25:43 +01:00
Ivan Yelizariev c37c9850fe [FIX] web: convert python/js bool values in read_progress_bar
Because of an issue with converting bool values, read_progress_bar didn't work
on grouping by bool fields (e.g. Active).

Related tests worked fine because mocked server responses were different from
real server responses. So, we need to adjust mocked server too.

opw-2870937

closes odoo/odoo#103926

closes odoo/odoo#104613

X-original-commit: e6ca3ef1b38dec964dab416c6058d4c1b7161614
Signed-off-by: Julien Mougenot (jum) <jum@odoo.com>
2023-01-13 16:27:08 +01:00
Jorge Pinna PuissantandBruno Boi fc47ddc2f2 [FIX] web: invalid datetime range/domain in mockReadGroup
The mock server's mockReadGroup function would not properly compute the
range and domain of the returned groups for datetime fields with groupby
hour.
The year of the range/domain should be the same as the record and not
the current year.

Consider the following:
- a record with a datetime field of value "2016-12-14 12:34:56".
- a read_group with groupby "['datetime:hour']"

The corresponding group would have had the following metadata (considering current year is 2022):
- value: `"13:00 14 Dec"`
- domain: `[["datetime", ">=", "2022-12-14 12:00:00"], ["datetime", "<", "2022-12-14 13:00:00"]]`
- range: `{ from: "2022-12-14 12:00:00", to: "2022-12-14 13:00:00" }`

It now has the following valid metadata:
- value: `"13:00 14 Dec"`
- domain: `[["datetime", ">=", "2016-12-14 12:00:00"], ["datetime", "<", "2016-12-14 13:00:00"]]`
- range: `{ from: "2016-12-14 12:00:00", to: "2016-12-14 13:00:00" }`

X-original-commit: cca1fad650efc13cd1695acb723b9aa9a54ba184
Part-of: odoo/odoo#108947
Co-authored-by: Bruno Boi <boi@odoo.com>
2023-01-03 08:54:47 +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
Samuel Degueldre deacb8c94b [FIX] web: remove incorrect usage of patch in mock_env
Previously, when restoring service metadata after clearing it, we would
use the patch function instead of an Object.assign. This is probably a
relic of a previous version of the code that used patchWithCleanup, but
in this context it is completely wrong, as we are giving something other
than a string as the patch name and no object at all as the patch value.

closes odoo/odoo#108390

X-original-commit: b83ab5061fe15e69f6c0703baf6f1eec61332f0e
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-12-21 07:59:57 +01:00
Vincent Schippefilt 25c6c15a06 [IMP] base,*: remove __last_update from all models
The main goal of this commit is to reduce the size of the registry by
removing the (almost) useless __last_update field.

Statistics # of fields with all modules installed:
before 30184 fields, 1299x last_update (4.30%)

Before this commit, the computed field __last_update was added on every model.
The idea behind this field was to have a computed field that had either
the write_date or the create_date if the write_date was empty. However,
the write_date is always written, even on creation, making it useless
to have the computed field __last_update

After this update, we completely remove from BaseModel:
* __last_update
* CONCURRENCY_CHECK_FIELD that was always defined as "__last_update"
* _compute_concurrency_field that was the compute function for __last_update

closes odoo/odoo#105739

Task-id: 3062140 (part of 3062137 improve registry load time)
Related: odoo/upgrade#4038
Related: odoo/enterprise#33939
Signed-off-by: Raphael Collet <rco@odoo.com>
2022-12-07 18:29:01 +01:00
FrancoisGe 96e158a8b8 [REF] web: simplify customizations of static menu actions
There are several customizations of the list and form view that consist
in modifying the behavior of a static menu action (archive, unarchive,
export, delete, duplicate). We have seen that this one is very complex.
So we decided to simplify it.

Solution:
Add the getStaticActionMenuItems API point. This allows us to easily
modify the behaviour of static actions.

We also took advantage of this commit to simplify the ActionMenu api.
We have removed the other actions because it was not clear enough.
They are directly added in the action category.

closes odoo/odoo#107086

Taskid: 3089039
Related: odoo/enterprise#34598
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-12-06 17:11:53 +01:00
Denis Ledoux 59e3269988 [FIX] base, web: transfer readonly/required modifiers for kanban/tree
Since odoo/odoo@69c3d5aa25
the readonly and required modifiers were no longer passed
for non-editable views. Which means:
- kanban: never passed,
- tree: passed only when `editable="1"` or `multi_edit="1"`,
- form: always passed.

The rationale behind that is that a view which is considered
as readonly doesn't need to know if its field are readonly or required,
as by definition, if the view is readonly, the user shouldn't
be able to modify anything in the view.
This was to make the views sent to the web client more light-weight,
not sending unused information, and save KB of transfers.

However, some widgets, used in the kanban and non-editable tree,
allow to modify fields, even in readonly considered views,
and therefore need to know these readonly/required modifiers
from the field definition in the Python model.

e.g. the `widget="color"`, odoo/odoo#103478

Ideally, these readonly/required modifiers should be transferred
only when the widget requires it, to avoid transferring the
readonly/required modifiers
when they are not useful in kanban/tree views
(which is 99% of the time).
However, this would require a bigger refactoring,
which is considered too risky compared to the added value
for a stable release.

task-3013110

closes odoo/odoo#106838

X-original-commit: 5a68d254949f1d0ff545023cfd14890efff10f5f
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2022-11-30 20:03:15 +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
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
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
Romain Estievenart a172be756f [REF] web,*: dark mode uses service instead of legacy api
This commit adapts the codebase to match its enterprise counterpart
where calls to legacy cookie api (cf. web.utils.cookies) are replaced by
cookie_service ones.

closes odoo/odoo#104080

X-original-commit: 724469e19ff83e91a41c6721e334df1ad8d1c02c
Related: odoo/enterprise#33189
Signed-off-by: Pierre Paridans (app) <app@odoo.com>
2022-10-25 19:39:51 +02:00
Achraf (abz) e885885d74 [FIX] web: Allow user to "search more" when adding o2m field
Steps:
  - Open studio in any list view
  - Try to add o2m to the list view
  - Select a related field
  - Click Search more
  - traceback "ViewClass is not defined"

Since https://github.com/odoo/odoo/commit/186a8b31161fc8c75b346ff97f9403dca1ae677e#diff-5e3a43184a718068d966f2ea2eb972fb54b9795a8efa5c8e8cd99ab07a4e2cdfL19
the form, kanban and list view have been removed from the registry.

opw-3020871

closes odoo/odoo#103980

X-original-commit: 19f98f7eb316a49a754eb68ea1352834a1e2a2e6
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: Achraf <abz@odoo.com>
2022-10-25 13:03:39 +02:00
FrancoisGe c998fdd77b [FIX] base: consider multi_edit="1" views editable
Since odoo/odoo#95729

nodes with a `groups=` are completely removed from the views when
the user is not part of the group, instead of being made invisible.

In that PR, views have been adapted to add back fields, with invisible="1",
when they were required, for instance when they were used in a domain
of another field which was still there despite the user is not part
of the given group.

As `tree` views having `multi_edit="1"` where not considered
as editable views, the domain of fields in these views were not
validated:
- https://github.com/odoo/odoo/blob/1fb8fa16ab7dc298d54f089d7163fb556dbc5fcc/odoo/addons/base/models/ir_ui_view.py#L1460
- https://github.com/odoo/odoo/blob/1fb8fa16ab7dc298d54f089d7163fb556dbc5fcc/odoo/addons/base/models/ir_ui_view.py#L1321-L1322

while they are well required for the web client,
in `multi_edit="1"` this is possible to edit relational/many2one field,
and therefore it will do `name_search` calls using the domain of the
field, and therefore the fields used in these domains must always
be present in the views. Without it, a crash in the web client occurs
when attempting to edit the relational/many2one field.

This revision targets to consider the `multi_edit="1"` tree views
as editable, to make the field domains validated as they should be.

Hence, views are adapted to add back fields with `invisible="1"`
when they are required in domains of other fields.

Part-of: odoo/odoo#103790
2022-10-23 12:30:03 +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
Denis Ledoux 94e05f9eed [IMP] base, web: do not set on_change="1" on most views
Only kanban, tree and form implements onchanges.
Therefore, on calendar, graph, pivot, ..., putting `on_change="1"`
is useless and is a waste of resources and KB.

e.g. CRM lead pivot view

Before:
```xml
<pivot string="Pipeline Analysis" sample="1">
    <field name="create_date" interval="month" type="row"/>
    <field name="stage_id" type="col" on_change="1"/>
    <field name="expected_revenue" type="measure"/>
    <field name="color" modifiers="{&quot;invisible&quot;: true}"/>
    <field name="automated_probability" modifiers="{&quot;invisible&quot;: true}"/>
    <field name="message_bounce" modifiers="{&quot;invisible&quot;: true}"/>
    <field name="probability" on_change="1" modifiers="{&quot;invisible&quot;: true}"/>
</pivot>
```

After:
```xml
<pivot string="Pipeline Analysis" sample="1">
    <field name="create_date" interval="month" type="row"/>
    <field name="stage_id" type="col"/>
    <field name="expected_revenue" type="measure"/>
    <field name="color" modifiers="{&quot;invisible&quot;: true}"/>
    <field name="automated_probability" modifiers="{&quot;invisible&quot;: true}"/>
    <field name="message_bounce" modifiers="{&quot;invisible&quot;: true}"/>
    <field name="probability" modifiers="{&quot;invisible&quot;: true}"/>
</pivot>
```

I would have like something smarter, like using the `editable` concept
for instance, but it's not that easy.
e.g. kanban is not considered as editable, while it does support
onchanges when grouping record by a field and drag and dropping
record from one column to another.
However, if we change the kanban view to make it editable,
the view validation will start validating the fields domain:
https://github.com/odoo/odoo/blob/45d4ac14f65c53dcde56592715d50169bde116ad/odoo/addons/base/models/ir_ui_view.py#L1439-L1442
causing issues:
- If a field used in the domain is not in the view, it will need to be
  added in the view,
- while it will not be used, as you cannot do a search in related fields
  in kanban views anyway.
e.g.
```
odoo.tools.convert.ParseError: while parsing /data/build/odoo/addons/analytic/views/analytic_line_views.xml:120
Error while validating view near:
<kanban class="o_kanban_mobile" __validate__="1">
                <field name="date"/>
                <field name="name"/>
Field 'company_id' used in domain of field 'account_id' ([('company_id', 'in', [company_id, False])]) must be present in view but is missing.
```

In addition, the kanban doesn't need the readonly and required
attributes on the field nodes, as other editable views (tree and forms)
do.

In addition, the tree list is currently considered as "editable" only
when it has `editable="bottom" or `editable="top"`, while
a tree without this editable attribute can still trigger onchange,
for instance when using `widget="handle"` or `widget="boolean_toggle"`.
We should therefore making the tree list editable whatever the case,
leading to the same issues than listed for the kanban above,
or make an exception for field in non-editable tree views using a
widget..

So, as the smarter way seems difficult and risky, for a limited gain
I choose the easy way by separating the concept "editable" and
"onchange-able" and to not set `on_change="1"` on views not considered
as "onchange-able".

closes odoo/odoo#102788

X-original-commit: aeb65ee536b1611c1cb829c91906f327f8e331c7
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2022-10-09 21:07:47 +02:00
Aaron Bohy 8540aad29f [REM] *: remove legacy views converted to owl
This commit removes legacy views that are not used anymore as they
have been converted to owl. They could actually have been removed
in the commit that converted them, as we never needed to have a
double implementation of views, unlike we need to (field) widgets.

The LazyColumnList is a special case. This view hasn't been
converted. Instead, it has been decided not to use it anymore.
So it was dead code, and this commit removes it.

The form/list/kanban views are no longer necessary in the view
registry, since their owl version exists. However, we kept them
in the test asset, as they are massively used in legacy tests
(in field tests for instance).

closes odoo/odoo#102634

X-original-commit: 186a8b31161fc8c75b346ff97f9403dca1ae677e
Related: odoo/enterprise#32501
Signed-off-by: Géry Debongnie <ged@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-10-07 17:47:58 +02:00
Samuel Degueldre 9c59d9a4a0 [FIX] web: support <widget> in list new view
When converting the list view to owl, the support for view widgets was
overlooked as this feature is not used very extensively and was not
tested.

This commit adds support for them and adds a test for it.

closes odoo/odoo#102193

X-original-commit: 9098c1d3cd4af8f324b5b09668e92822575f932d
Signed-off-by: Géry Debongnie <ged@odoo.com>
Signed-off-by: Samuel Degueldre <sad@odoo.com>
2022-10-06 10:42:40 +02:00
Denis Ledoux fa67f44794 [IMP] base, web: do not pass field readonly/required for readonly views
pivot, graph, cohort views do not care to know whether a field
is readonly or required, as you cannot edit records in these views.

Even kanban is readonly in most cases:
- you can drag and drop records from one column to another,
  which is prevented if the group by field is readonly
  but this shouldn't rely on the fact the field is
  within the architecture, as you can group by on any fields
  from the search views / control panel.
  Hence, this shouldn't rely entirely on the modifiers passed on the field
  nodes in the view architecture alone.
- you can create new record inside the kanban,
  with a simplified form, thanks to the `quick_create`,
  but this uses an independant form view, in which the readonly and
  required modifiers are correctly passed.
So, `modifiers="{'readonly': true, 'required': true}"` can be dropped
for kanban views as well.

This allow to spare some KB by not setting useless modifiers in views.

e.g. CRM > My pipeline pivot

Before
```xml
<pivot string="Pipeline Analysis" sample="1">
    <field name="create_date" interval="month" type="row" modifiers="{&quot;readonly&quot;: true}"/>
    <field name="stage_id" type="col" on_change="1" can_create="true" can_write="true"/>
    <field name="expected_revenue" type="measure"/>
    <field name="color" modifiers="{&quot;invisible&quot;: true}"/>
    <field name="automated_probability" modifiers="{&quot;invisible&quot;: true, &quot;readonly&quot;: true}"/>
    <field name="message_bounce" modifiers="{&quot;invisible&quot;: true}"/>
    <field name="probability" on_change="1" modifiers="{&quot;invisible&quot;: true}"/>
</pivot>
```

After
```xml
<pivot string="Pipeline Analysis" sample="1">
    <field name="create_date" interval="month" type="row"/>
    <field name="stage_id" type="col" on_change="1"/>
    <field name="expected_revenue" type="measure"/>
    <field name="color" modifiers="{&quot;invisible&quot;: true}"/>
    <field name="automated_probability" modifiers="{&quot;invisible&quot;: true}"/>
    <field name="message_bounce" modifiers="{&quot;invisible&quot;: true}"/>
    <field name="probability" on_change="1" modifiers="{&quot;invisible&quot;: true}"/>
</pivot>
```

Regarding the change of behavior shown in `addons/web/static/tests/views/kanban_view_tests.js`.
It was introduced very recently, by myself, in
odoo/odoo#100806
I revert this possibility to set readonly="0" on a field node in a
kanban view, because:
- First, this is not used anywhere in both odoo/odoo and
odoo/enterprise.
- Second, this really makes things harder if we want to do so:
  - as readonly="0" is passed, the "readonly" gets removed from the node
    modifiers, as they are simplified by removing falsy value:
    modifiers="{'invisible: True, 'readonly': False}" becomes modifiers="{'invisible': True}"
  - as readonly in not amongst the modifiers, it fallbacks on the model
    field property, in the javascript code, which is readonly: True.
  - the thing to do would be to still transfer "readonly"
    from the field attributes to the node modifiers.
    - which either mean to consider a kanban view as editable
      - this will cause issues because the validation mechanism
        will suddenly check the domain attribute property
        https://github.com/odoo/odoo/blob/d4a92b112d0554a2624f7768feb7d54e0484469f/odoo/addons/base/models/ir_ui_view.py#L1443
        and there will be plenty of views where some field used in the
        domains will be missing. Besides it is pointless to validate these
        domains as they are completely unused in kanban views
    - either mean to find another mechanism than "editable" to decide
      wheter to transfer the modifiers "readonly"/"required" or not,
      which over-complicates things.
    - besides only "readonly" would need to be passed, not "required.
So, to keep the code stupid simple, I remove this possibility added only
a few days ago, which is actually not used anywhere in standard for the
moment.

closes odoo/odoo#102221

X-original-commit: 69c3d5aa25655173ed66a52570559322c650c7df
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2022-10-06 00:37:00 +02:00
Denis Ledoux 99a9cce9ba [IMP] base, web: set can_create/can_write only on editable nodes
Setting the attributes `can_create` and `can_write` in views
which are not editable is useless as you cannot edit the record
in these views.

This allow to gain some KB when serving the view to the web client,
as well as making the view cleaner.

e.g. the graph view in the CRM > My Pipeline menu

Before:
```xml
<graph string="Opportunities" sample="1">
    <field name="stage_id" can_create="true" can_write="true"/>
    <field name="user_id" on_change="1" can_create="true" can_write="true"/>
    <field name="color" modifiers="{&quot;invisible&quot;: true}"/>
</graph>
```

After:
```xml
<graph string="Opportunities" sample="1">
    <field name="stage_id"/>
    <field name="user_id" on_change="1"/>
    <field name="color" modifiers="{&quot;invisible&quot;: true}"/>
</graph>
```

This revision takes the opportunity to port the `editable` concept
from the server to the web client MockServer,
in order to be able to test the removal of these attributes from the views
in the QUnit tests.

The `_editableNode` JS function added here is the translation of the
existing `def _editable_node` method in `addons/base/models/ir_ui_view.py`

https://github.com/odoo/odoo/blob/f5edde3624f4fe40f87cc7fed7dcfc4bbce1f19f/odoo/addons/base/models/ir_ui_view.py#L1282-L1301

closes odoo/odoo#101902

X-original-commit: f0beddf534a57e972ac3a7bef6afa1caae1dcff3
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2022-10-03 15:18:55 +02:00
Achraf c120f43905 [FIX] web: Allow users to enable list view with group_by_no_leaf
- Go to accounting/Report/Invoices Analysis
- Open studio
- enable list view
- empty view

This code bellow compute count_field as `__count` because group_by_no_leaf
is in the context.

But in the basic_model we don't consider this case.

https://github.com/odoo/odoo/blob/5797fd80a63309269f15bcbe4948d4429a53eec2/odoo/models.py#L2798-L2802

opw-2980923

closes odoo/odoo#101570

X-original-commit: bde2985959ef8914da4b8aca96efc5772262d0c0
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-09-29 13:23:01 +02:00
Michael (mcm)andluvi 710271240f [IMP] web: remove readonly mode of form view
This commit does multiple things:
- The readonly mode of form view is removed but not for the fields.
  it means that the fields in the view are always in edit mode except
  if we force them to be readonly.
- The control panel is revamped to take less vertical space and shows now
  the record editing (dirtiness)/validity status after editing the record.
- The record is saved only when leaving the view or by clicking the save
  button when hovering the record status in the control panel.
- The record can still be discarded by clicking the discard button when
  hovering the status text in control panel.

task id: 2822553

X-original-commit: 77824ad44b6945a9811120380747f87ef6362ae2
Part-of: odoo/odoo#101118
Co-authored-by: luvi <luvi@odoo.com>
2022-09-27 12:43:50 +02:00
Bruno BoiandJorge Pinna Puissant ed9a9d024a [REF] *: calendar view in owl
This commit introduces the new calendar view written in owl.

closes odoo/odoo#101185

X-original-commit: e88988f58582d5b49a32d7102a74a176f40c4c69
Related: odoo/enterprise#31808
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Bruno Boi (boi) <boi@odoo.com>
Co-authored-by: Bruno Boi <boi@odoo.com>
Co-authored-by: Jorge Pinna Puissant <jpp@odoo.com>
2022-09-26 22:48:44 +02:00
FrancoisGe 2c26a810c8 [FIX] web: wrong domain in a new column
Before this commit, in a Kanban view, the group representing
a new column did not contain a domain. Its domain should have combined
the view domain and the groupBy domain ([groupByField.name, "=", id]).

How to reproduce:
- Go to a grouped kanban view with a progress bar
- Create a new column
- Create a record in this new column
- Click on the progress bar to filter the records on a state

Before this commit:
All records corresponding to the selected state are displayed in the
column. (even the records that are not part of the column)

After this commit:
Only the new record is displayed in the column.

closes odoo/odoo#101096

X-original-commit: 1022262c6fcd51c8d4fc8024217542bb1f536d2c
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-09-26 12:39:52 +02:00
Aaron Bohy 45a718aa10 [FIX] web: PhoneField: set correct type on input
"phone" isn't a valid input type, so it had no effect, except
breaking the tour system when a PhoneField input was the target
of a step, since the "consume event" was then "click" instead of
"input"..

closes odoo/odoo#100388

Related: odoo/enterprise#31437
Signed-off-by: Pierre Paridans (app) <app@odoo.com>
2022-09-17 00:51:42 +02:00
Denis Ledoux ef16e96255 [FIX] base, web: graph and pivot views requires more field descriptions
Following odoo/odoo@4636620004
`get_views` only pass the model fields included in the view architecture,
except for the main model when the search views is requested.
Because the search views requires all fields for the user to be able
to make advanced filters and advanced group by using any fields of the
model.

However, other views requires more field descriptions as well than
just the fields included in their architecture:
- the graph view requires all integer and float fields,
    to automatically add suggestions of measures in the measures dropdown
    menu. It's a bit like the search view, the user should be able
    to choose any measure available in the model
    (as long as this is integer or float fields)
- the pivot view requires all groupable fields,
    so the user can group by any groupable fields of the model.

The JS MockServer `getViews` is adapted to include the changes added by the above
revision as well as the current revision,
for the qunit tests suite to be able to reflect these API changes
from the server side.

closes odoo/odoo#100376

Related: odoo/enterprise#31427
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2022-09-17 00:51:34 +02:00