Commit Graph
238 Commits
Author SHA1 Message Date
Bruno BoiandMathieu Duckerts-Antoine 5de4c6dca1 [FIX] web: allow any levels in navbar menus
In 14.0 the menu items in the navbar sections menu could have any level.
Since the webclient refactoring landed in 15.0 0573aca this feature has
been unintentionnally limited to two levels.
More sub menus would simply not be displayed.

**Before this commit**
- Have a menu item with the following path:
  `App/Menu/Group/Sub-group/Item`
- The `Sub-group` is displayed as an item. It is clickable but nothing happens.
- The `Item` is not displayed.

**After this commit**
Works properly as it should. See screenshots on the PR description.

closes odoo/odoo#121422

X-original-commit: 708d17ba3a9d12e153069ecb7ae6c8e3d6187dd0
Signed-off-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Signed-off-by: Bruno Boi (boi) <boi@odoo.com>
Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
2023-05-15 17:51:58 +02:00
MerlinGuillaume 93df76fedb [FIX] web: disable click on list action with target new
When importing data and checking the possible values of a field,
clicking on one of the records to open it throws an error

Steps to reproduce:
1. Install Projects
2. Go to Project > My Tasks and trigger the list view
3. Select any record and export it (check the import-compatible export
   option)
4. Open the exported file and modify the `project_id` to a non-existing
   project name
5. Click on Favorites > Import records
6. Upload the modified file and click on 'TEST'
7. In the `project_id` field, click on 'See possible values'
8. Click on any project, an error is thrown

Solution:
Prevent the form from being opened when the action is in target "new"

Problem:
Opening the record in a target new throws the error `switchView
called but the current controller isn't a view`

opw-3161777

closes odoo/odoo#121384

X-original-commit: 63d43713ea5b2efba2e63b1735954bb2069bc6f4
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Guillaume Merlin (megu) <megu@odoo.com>
2023-05-15 12:56:20 +02:00
Aaron Bohy f9b8414823 [IMP] web: remove old search menus
Overseeded by the SearchBarMenu.

Part-of: odoo/odoo#116641
2023-05-12 22:59:23 +02:00
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
Brieuc-brd 418413e499 [IMP] web, *: directional icons
This commit adapts the directional icons to improve the usability and
maintain consistency with the ui icons library.

task-2818586

Part-of: odoo/odoo#116641
2023-05-12 22:59:22 +02:00
stefanorigano (SRI) 79f57643ce [REF] web, mail, hr, website, auth_totp, test_apikeys: top-menu design
task-2818586

Part-of: odoo/odoo#116641
2023-05-12 22:59:13 +02:00
FrancoisGe 21d3b73c2f [FIX] web: change action from a dirty form view
Before this commit, if we try to change the action from a form view
a new record in an x2m and the new action fails to mount, then the new
record in the x2m will always have a virtual id even if it has already
been saved on the server side.

Why:
When you try to exit the form view, the form view will save the record
and not read the record because you leave the view (in the beforeLeave).
But in our case, we fail to mount the new action and so we will stay on
the form view without it doing a read to know the id of the record added
in the x2m. So the view thinks that the x2m still contains a virtual record.

Solution:
Going back to action should rebuild the whole compound. To cause this,
we'll restore the last controller.

How to reproduce:
- Going to a form view with an x2m field and a widget performing a doAction
- Add a line to the x2m
- Click on the widget to change the action
- New action fails to mount, it returns an error
- Close the error dialog
- Edit another field
- Save the form view

Before this commit:
    The new line in the x2m is duplicated.

After this commit:
    The new line in the x2m is unique

opw-3193765

closes odoo/odoo#120765

X-original-commit: 72f68e2
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-05-10 19:17:17 +02:00
Julien Carion (juca) 787c6ff32a [FIX] web: Handle access rights in readonly fields
This commit adapts the behavior of all readonly fields
to take access rights into account when deciding whether the field
should be editable or not.
Steps to reproduce: give minimal access rights to Marc Demo user,
log in as Marc Demo, go to crm, make sure no one is assigned as
salesperson in a record and check if the add user icon is available.
Also applies to every kanban view fields (like priority,
many2many_avatar, ...)

opw-3265086

closes odoo/odoo#119818

Signed-off-by: Georis François (fge) <fge@odoo.com>
2023-05-10 13:21:47 +02:00
Mathieu Duckerts-AntoineandMichaël Mattiello c1436ba8ca [IMP] *: advanced search
We allow edition/creation of domains with a domain selector via the
search bar facets or the menu "Add Custom Filter".
The domain selector has also been improved and now support expressions
and a new operator "between" for some field types (those for which <=
and >= are valid operators). We also improve the support of the connector
not.

Task ID: 3063564

closes odoo/odoo#112326

Related: odoo/enterprise#37715
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Co-authored-by: Michaël Mattiello <mcm@odoo.com>
2023-05-08 15:18:03 +02:00
Samuel Degueldre db4b11141d [REF] point_of_sale, web: factor report downloads out of action service
Previously, downloading reports was only possible by going through the
action service. In a few places, we want to download reports from the
PoS, but it doesn't make sense to load the action service and all its
dependencies in the PoS. In order to allow reports to be downloaded
without the action services, some functions are extracted out of the
action service itself and into report utils, which the action service
calls. These utils can now be used from the PoS without requiring the
action service and its dependencies be included in the PoS assets.

Part-of: odoo/odoo#120070
2023-05-05 17:06:37 +02:00
Géry Debongnie a7cd003173 [FIX] web: do not reload webclient in some cases with errors
Whenever an user updates a company or a currency, the webclient has to
reload, to properly apply these changes. It is done automatically,
immediately after the rpc has completed.

However, before this commit, it would do that always, even if the rpc
has failed (for example, if the user tried updating an invalid field),
so the user would briefly see an error window, then the browser is
immediately reloaded.

With this commit, we only reload the webclient when the rpc succeeded.

closes odoo/odoo#119730

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-04-27 10:13:05 +02:00
Jorge Pinna Puissant baebb6a5b0 [REF] web, *: Unique id for field nodes
Before this commit, the field node id (`field_id`) uses the field name
for the first occurrence on the arch, and add an underscore and a number
for the rest of the occurrences. This can create inconsistencies when
sombody assumes that the field_id is equal to the name, and don't take
into account the possibility of multiple occurrences.

Now, a unique id is created since the first occurrence, this remove all
ambiguity between the id and the name.

Part-of task-id 3179751

closes odoo/odoo#117799

Related: odoo/enterprise#39511
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-04-11 15:17:20 +02:00
flvr-odoo 3c180713fd [FIX] web: blocked pop-up warning always shows
partial revert of https://github.com/odoo/odoo/pull/117205

Since there was no link between the odoo instance and the new tab,
it was impossible to determine if it was really open and the test
afterward would always trigger

closes odoo/odoo#117973

X-original-commit: 5717eeec9eb8d5cc9cd684e6b147919d808f5db1
Signed-off-by: Vranckx Florian (flvr) <flvr@odoo.com>
2023-04-07 10:32:57 +02:00
flvr-odoo 3cfcb204ed [FIX] web : isolate new tab to external ressources
This commit is a security reinforcement.

Before this commit:

ir.action.act_url was able to handle and redirect to protocols like
file:, javascript:, date: ... This is unnecessary in the context of
this action. It could potentially be abused by a poorly written custom
module

It also would not isolate the landing page in case of a new tabs.
It means that chrome would still consider the tab to be from the
previous domain in case no url was passed and js was executed.
This would allow the newly open tab to still make query's to the
referrer using the referrer's cookie. While not stricly necessary
if we already prevent url that start with "javascript:", it is a
nice to have.

After this commit:

New tabs are not able to access referrer informations or execute
javascript interacting with the referrer. Also, it is now impossible
to redirect to protocols other than http and https directly from
the ir.action.act_url

Test update:

All new tabs are required to have the "noreferrer" argument

Tested an example of an unsupported protocol.

closes odoo/odoo#117687

X-original-commit: a020072da17e32fca0bbe6ed02b1afaeec8e8a02
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-04-05 08:38:30 +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
Aaron Bohy 1f52c8edd3 [REF] *: remove form_view_initial_mode context key support
The purpose of this key was to force the form view to be in edit
mode directly when opening a record, in specific actions. This is
now automatically the case since form views are always in edit
mode. This commit thus removes the support of the key, and removes
all occurrences where it was set in the codebase.

Part of task 3179751

closes odoo/odoo#115172

Related: odoo/enterprise#38130
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-03-16 14:12:37 +01:00
Aaron Bohy 8fc4c6f2d8 [REF] *: remove legacy views support
The last view in the odoo codebase has just been converted to owl,
meaning that we no longer have legacy views. This allows us to
remove a lot of legacy view related code: the abstract elements on
which the legacy views were built, the compatibility layers that
allowed to deal with both owl and legacy views uniformly, legacy
widgets that were only used in those legacy views...

closes odoo/odoo#114893

Related: odoo/upgrade#4420
Related: odoo/enterprise#38005
Signed-off-by: Géry Debongnie <ged@odoo.com>
2023-03-10 13:33:04 +01:00
Aaron Bohy 14d74a1d65 [REF] web: tests: remove legacy action manager tests
Those tests check that we do not leak legacy Widget instances.
However, as the form/list/kanban views and fields have been
converted to owl, no Widget instance is created anymore by those
tests.

closes odoo/odoo#114577

Signed-off-by: Georis François (fge) <fge@odoo.com>
2023-03-07 18:03:27 +01:00
Audric Onockx (auon) 65f170947a [FIX] web: handle the cases were save actually deletes
Very niche usecase, but still:
\- Create a planning shift, set a recurrence for ever.
\- Go few occurences later (form via kanban) and set...
...recurrence type to "Number of Occurences",
...recurrence nmber to 1.
\- Save.

The write method will update the recurrence
so that it only contains only one occurrence.
Consequently, the record you just updated is deleted.
Then we try to fetch the record to display its form again.
Because de read returns [], _fetchRecord rejects the promise,
and we're stuck.

So, in this commit, we make `FormController.saveButtonClicked` call
`Record.save` with its params, so itself can be called with throwOnError,
and the potential error catched.
We all so cover the case where `BasicModel._fetchRecord`
returns `Promise.reject()`, in `BasicModel.save`.

Also, `Record.save` has an object as a default value for params.
When we call it from `FormController.saveButtonClicked` with params,
say params is an empty dict, the default value will be lost.

Istead of overriding this object, this commit only overrides/adds
the key of the object we give `Record.save` if any.

Also, when investigating on that, we jsut noticed that,
when you click save on a form dialog,
it reloads the record before closing it, which is useless.

closes odoo/odoo#112335

Related: odoo/enterprise#37752
Signed-off-by: Audric Onockx (auon) <auon@odoo.com>
2023-03-03 13:10:48 +01:00
Jorge Pinna Puissant 91303252f4 [REF] web, *: simplify concrete fields API - remove value setDirty
This commit, is part of a series of commits that aim to simplifie the
concrete fields API.

In this commit we will remove setDirty prop from concrete fields. Now if
needed the fields can declare itself dirty using triggering
"FIELD_IS_DIRTY" on the model's bus.

Note that this PR partially revert [1] and completely revert [2]

task-id 3179751

[1] : 89c2a3978e
[2]: c79bb3c9c6

closes odoo/odoo#114124

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-03-02 16:01:19 +01:00
Jorge Pinna Puissant 4a8876b550 [IMP] web: oh-snappisation
The aim of this commit is to make more warning and error dialogs behave
like the "oh snap" dialog of form views.

task-id=3126594

closes odoo/odoo#112276

Related: odoo/enterprise#37593
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-02-28 13:01:36 +01:00
Aaron Bohy 211ad04773 [FIX] web: Many2One in dialog: open related record in dialog
The external button of the Many2one field has been changed with the
"always edit" feature of the form view, s.t. it displays by default
another icon (a right arrow) and when clicked, opens the related
record in another plain screen action instead of a FormViewDialog.

However, this doesn't work for Many2One fields that are already in
dialogs, because
 1) if it's an action dialog (target="new"), that dialog will be
    closed when opening the related record and the user loses its
    working context
 2) if it's another type of dialog (e.g. FormViewDialog), the
    related record opens in the background and the dialog remains
    open, which is obviously a bad UX experiment. This had been
    locally fixes at some places [2].

This commit fixes the issue by automatically opening the related
record in a FormViewDialog if the Many2One is itself already in a
dialog.

This commit also fixes an issue with the scenario where the related
record opens in a dialog: if there were changes done in the main
record, those changes where lost when the user clicked on "Save"
in the dialog of the related record. We now only reload the
display_name of the related record, and apply it to the model.

[2] https://github.com/odoo/enterprise/commit/ba0e95fe42696dcf44b8feddeb302f04876fcbdc

Task 3191319

closes odoo/odoo#112959

Related: odoo/enterprise#37213
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-02-27 09:37:18 +01:00
Romeo Fragomeli f9fd098f18 [IMP] web: add "crop" overlay in barcode scanner
The commit restores a similar crop overlay like in the Odoo Android
Mobile App for the Barcode scanner.

This feature helps to scan the right barcode when the user scans a
barcode surrounded by other barcode, which before this commit a barcode
was scanned but in some cases not the good one. The commit solves the
problem by returning only the values into the rectangle overlay.

Part-of: odoo/odoo#112855
2023-02-17 12:07:20 +01:00
Pierre Paridans 6f700b2973 [FIX] web,purchase: no content helper position in modal on small screen
This commit fixes an issue where the "No records found" helper text is
wrongly positioned below the sample data's records (i.e. not visible)
instead of over them.

This is basically a revert of 9407383a56
due to the changes in the DOM and styling made in the meantime.

But actually we can go further and ensure we always have the ListView's
table present in the DOM. This change allows to simplify the positioning
of the helper and the implementation of the Purchase's dashboard.

Steps to reproduce:
- create a new database **without demo data**
- install "Planning" and "Sales" apps
- with a mobile-like screen size, open Planning
- switch to Gantt view
- in a cell, click/tap on the magnifier button (which is on hover...)
- the many2x view doesn't contain data
=> action helper "No records found" isn"t visible (scroll to bottom to
find it)

closes odoo/odoo#112878

X-original-commit: 766498a36b322ffe9c647616f56f3ba04cc51d96
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Pierre Paridans (app) <app@odoo.com>
2023-02-16 17:57:00 +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
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
FrancoisGe 97a641a750 [FIX] web: client action reload
This commit aims to solve two problems:
1. Keeping the hash if no action_id or menu_id is passed as a parameter.
2. Always force a reload of the page.

Description of the issues:
1. When reloading from an action, we just want to force a reload of the
page while staying on the same action. We only want to modify the hash
if we want to reload the page by opening another action.

2. When installing the website module, an error dialog is displayed and
the page is not reloaded because location.assign(...) only causes
a reload when the url has changed (path or search, it ignores the hash).
The error comes from trying to access a client action that is not yet
in the assets. It will be added when the page is reloaded.

Solution:
1. Modify the hash only when you have action_id or menu_id in the action params

2. We have thought of two solutions:
- Do a location.reload(...) when the url has not changed. The error
  appears during the reload time because location.assign(...) modifies
  the hash. The service action will then try to execute the client action
  which does not yet exist. (legacy solution)
- Always have a different url so that location.assign(...) causes a reload.
  So we decided to add/remove the reload key in the url search. This will
  always force a reload. We will opt for this solution because it avoids
  displaying a crash.

closes odoo/odoo#112077

Taskid: 3144132
X-original-commit: 77772c0e73d9f561fed63847175e2dbc9b809fa1
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-02-07 13:34:45 +01:00
Jorge Pinna Puissant 89c2a3978e [FIX] web: show status indicator buttons on editing field
Before this commit, when editing a form view, when editing a input field,
the status indicator buttons (the save and discard buttons) didn't show
up until a click outside the field was done (change event).

Now, the status indicator buttons shown as soon as the input field is
edited (input event).

task-id 3147130

closes odoo/odoo#111387

X-original-commit: 64aa9a6afdc8eb27711f6deb5d6ee3e79e6276b2
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-02-01 10:25:04 +01:00
Samuel Degueldre ef67615e97 [FIX] web: correctly destroy apps created for legacy MockServer
A recent change in owl exposes live (non-destroyed) apps on the window.
This change causes the memory used by the QUnit test suite to balloon
out of control. The reason is that when creating a mock environment, we
create a standaloneAdapter to serve as the legacy MockServer's parent,
but this standaloneAdapter creates a dummy owl application and this
application is never destroyed. This commit fixes the problem by
registering a cleanup to destroy the application at the end of the
running test.

closes odoo/odoo#110889

X-original-commit: 27ff522cd6b0c3be32be623e375052e63bb1a04f
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Samuel Degueldre <sad@odoo.com>
2023-01-25 08:18:04 +01:00
Jorge Pinna Puissant 4cdd74fc58 [IMP] web: allow the use of setting tags on the form view
The setting tag was introduced in [1], it was restricted to the setting
view (the js_class : base_settings).

This commit move the setting tag to the form view, to remove the
restriction and allow the use of the setting tag in any form view.

[1]: c7c2959449

Part-of: odoo/odoo#110432
2023-01-25 08:18:01 +01:00
Hubert Van de Walle (huvw) 0b335ad510 [FIX] web: settings view: call server actions with the resId
Steps to reproduce
==================

- Go to settings
- Search for IAP
- Click on View My Services

Cause of the issue
==================

In the settings view, there is a specific hack which removes the resId
from the record

https://github.com/odoo/odoo/blob/e4fe05ac07dbafb993922ff28dc3f7705c639dff/addons/web/static/src/webclient/settings_form_view/settings_form_view.js#L35-L39

This means that the records is not defined in the server action and so
nothing is done

https://github.com/odoo/odoo/blob/cd356f29abcaa1029e8a79ae76c2561f4833232a/addons/iap/views/res_config_settings.xml#L9

Solution
========

Instead of removing the res_id to mark the record as new, override
BasicModel.isNew

opw-3120995

closes odoo/odoo#110679

X-original-commit: ffb09c4ba5a4fb521a242adb0541595bd3ec1524
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-01-23 13:19:02 +01:00
Aaron Bohy a7a7c150aa [FIX] web: crash when clicking deleted records in breadcrumbs
Here is a way to reproduce the problematic situation: with CRM
installed, go to Contacts, open one, clicks on its Opportunities
stat button, open one in form view, click on the "Customer" field
internal link to open again the contact in form view, delete the
record, and finally click on the first occurence of the contact
in the breadcrumbs.

Before this commit, it crashed because we ended up in an error
handler (formSaveErrorHandler) that doesn't deal with the fact
that originalError could be falsy. This is handled by the
legacyRejectPromiseHandler, but due to the low sequence of the
faulty handler, this one was executed after.

Same error would occur if you tried to open an url of a record
that doesn't exist.

This commit fixes the error handler sequences s.t. the crash no
longer occurs.

Issue reported in the feedback pad after migrating odoo.com to 16.0.

closes odoo/odoo#110545

X-original-commit: 8e78efa3dda2484b34422a66d3963c7b20915036
Signed-off-by: Samuel Degueldre <sad@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-01-20 21:56:53 +01:00
Pierre Paridans 93790839b6 [FIX] web,website,point_of_sale: settings' header alignment
This commit is a follow-up of odoo/odoo@bb819f6a5c.

Even if the fix above worked around having the settinggs header's
content out of screen on smaller screen, the solution was ugly and was
meant to be improved later on.

This commit reworks the HeaderSetting's template and simplifies it to
properly fix this issue.

closes odoo/odoo#110530

X-original-commit: 0ab079664e380e5e77440e290ec604e3830108bb
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2023-01-20 21:56:45 +01:00
Renaud Thiry a8cb52afee [FIX] web: keep full urls in settings
The function that adds the missing url root on documentation links uses a regex
in startsWith, which is not supported.

startsWith is replaced with ``regex.test`` which will succeed
if the regex has any match.
Which is fine because we use a '^' to ensure it *starts* with https

task-3079113

closes odoo/odoo#110443

X-original-commit: fdaeaf69c1770edf3f33e32947326d1ebe42820e
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
2023-01-20 10:42:43 +01:00
Jorge Pinna Puissant 65244f2122 [FIX] web: settings_form_view - resIds should contains only one id
- Install two languages;
- Install Accounting;
- Active 'Default Terms & Conditions';
- Select 'Add a Note';
- Click on the translate button;
- Answer 'Ok' when asking for saving the settings before modify the
    translation;
- Save or Discard the translations;
- Save the settings.

Before this commit, a backtrace is raised. This issue raise because we
create twice the settings record. One before opening the translation and
the second time juste before saving the settings. This is a normal
behaviour in settings, as we consider the settings view as always new, a
new record is always created. But, only the last one should be sent to
the python code on the resId array.

opw-3109677

closes odoo/odoo#109803

X-original-commit: 5394f4c82829f8c7e6aaf73ddb1590f316f87ee3
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
2023-01-18 13:25:27 +01:00
Aaron Bohy 942fcbfb3a [FIX] *: views: add component instance to rendering context
Owl last update fixes the leaking `this` in rendering context of
templates called with `t-call-context` [1]. Since [2], we use the
`t-call-context` directive to control the rendering context of
templates compiled from an arch (e.g. in form and kanban views).
We can now better control what people use in archs, where we don't
want them to access js implementation details, as `this` is no
longer available.

However, the component instance still needs to be accessible in
the compiled template. We thus add the `__comp__` key in the
rendering context. Since we do not want people to access it in
archs, we add a check in the view validation that this string
isn't used in dynamic attributes.

[1] https://github.com/odoo/owl/commit/df59ec49aefce2e0913fdc1792d42b9680fb28b6
[2] https://github.com/odoo/odoo/commit/4c5b867ff6b0b674cb83d1a1262ae354ebaa6d57

X-original-commit: 264f313012aa99449d1576ae1110252c13755142
Part-of: odoo/odoo#110196
2023-01-18 10:16:12 +01:00
Michael (mcm) 07f121faff [FIX] web: confirm to leave settings
Before this commit, the confirmation dialog was opened
only when the user clicked on an action button.
Now, the dialog is also shown when the user clicks a
menu item in the navbar.
Of course this dialog is shown only if the user has
changed a setting.

closes odoo/odoo#110194

Task: 3102800
X-original-commit: a180178bfd73d6e5f95ee5a9e9cdc1b0d64fc574
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-01-18 10:16:08 +01:00
Bruno Boi 3a814f50ba [FIX] web: back to same action w/ pending changes
Before this commit, when a user was on a form view with pending changes
and would click on the browser back button. If the previous action was
the same action, the user would be redirected to the form view but a
traceback would be raised because the form view was not able to handle
the pending changes "in time".

Here "in time" means before the form view is rendered. The form view
when rendered will try to update its display name through its controller
config, but as the new controller will be in fact the same as the
previous one, its config is currently being changed while the previous
form view is still using it. This leads to a traceback.

This commit fixes this issue by making sure that the changes are
properly commited before changing the config for the new controller.

The same kind of issue has been fixed in the action service for the
restore function, but there are no sensible ways to test this particular
use case.

closes odoo/odoo#109653

X-original-commit: e8a95c37e4e9ee4e4a65a3bfb216d3fa55544933
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-01-11 15:39:08 +01:00
FrancoisGe 79c89438a7 [REF] web: converted the client actions from misc.js
This commit is to convert the client actions in misc.js into the new
architecture.
We remove the client actions login and logout because they are no
longer used in the code base.

closes odoo/odoo#109332

Task-id: 3099992
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-01-10 12:35:04 +01:00
Mathieu Duckerts-Antoine d22928b7ed [FIX] web: sample server: populate groups
When some true groups have been fetched, the sample server use them to
construct the value returned by _mockWebReadGroup, i.e. construct some
fake groups. It also populate those groups by assigning them some
previously created fake records. It turns out that those fake records did
not have the right type when the first group by is a date/datetime field.
The record values created (during the group assignation) for that field
were luxon.DateTime instances instead of strings like "2022-12-15".

This was the root cause of the following problem.

Have a kanban view in sample mode and grouped on a date field, then
switch to a pivot view grouped on the same date field. A crash occures.

That crash is linked to the above mentionned problem in the following
way:

- open the kanban view (with sample="1" in its arch)
- some existing groups are fetched by the relation model but no records
  exist
- the kanban view switches to sample mode and some fake invalid records
  are created in the sample server (the invalidity of records do not
  cause visible problems at that time)
- switch to the pivot view
- the sample server is reused but existingGroups is set to be null, so
  that _mockWebReadGroup uses the invalid records to create the groups
  it needs. The crash occures at that step.

Forward-Port-Of:: cdd583f74f51086c8d5f243a2a761622229ccc26

closes odoo/odoo#109031

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Mathieu Duckerts-Antoine <dam@odoo.com>
2023-01-04 14:44:57 +01:00
Aaron Bohy fa9f865067 [FIX] web: fix test failing randomly
Before this commit, the modified test sometimes failed on runbot,
because it might happen that the hashchange event is triggered in
the next animation frame (the event isn't triggered synchronously).
This commit ensures that we wait for the hashchange event, and for
a nextTick before checking that the next action is in the DOM.

Fixes runbot issue 6946

closes odoo/odoo#109028

X-original-commit: 6aba445e2b4a1f6321cefb04fb07584df615dfa2
Signed-off-by: Samuel Degueldre <sad@odoo.com>
2023-01-04 08:11:43 +01:00
Bruno Boi c2f6189eed [FIX] web: keep props resId on restore breadcrumb
**Before this commit**

    When a breadcrumb is restored, the props resId is overwritten by the
    res_id of the action.

**After this commit**

    The props resId is kept if it is defined.

closes odoo/odoo#108996

X-original-commit: 810a1d29bfa7c497627a37e0cec64df51b75bb4b
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-01-03 14:33:06 +01:00
Aaron Bohy a3d77e877d [IMP] web: list view: sticky header
With this commit, the header of list views no longer scrolls with
the table, it remains visible on the top when scrolling.

Task 1917230

closes odoo/odoo#107631

Related: odoo/enterprise#35097
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2022-12-23 14:09:23 +01:00
Sergey ShebaninandAaron Bohy 91b80fbb5c [IMP] web: blockui when executing a target=self act_url action
An act_url action in target "self" redirects the current window/tab
to the given url. It always reloads the page, except when only the
hash or query string changes.

This commit blocks the ui when the page reloads, because there's a
lack of feedback and interacting with the ui is unnecessary anyway.

For instance, module operations (install, remove and update) end
with page reload. During the operation, the ui is already blocked
because the operation takes time. After the operation and before
the page is actually reloaded, the ui is unblocked. As the reload
also takes time because of asset rebuilding, it makes false feeling
for the user that operation completes and interface is ready for
interaction. With this commit ui is blocked until the page is
reloaded.

closes odoo/odoo#107830

Signed-off-by: Géry Debongnie <ged@odoo.com>
Co-authored-by: Aaron Bohy <aab@odoo.com>
2022-12-14 17:17:47 +01:00
Jorge Pinna Puissant 76add62453 [FIX] web: settings view, always perform an onchange to fetch the data
- On the settings view;
- Open the CRM settings;
- Click on "Update Probabilities" button;
- Change the "consider leads created as of the" date;
- Click on "Confirm" button;

Before this commit, the fields on the settings related to the dialog
were not updated. This occurs because, as the setting model is a
transient model, the settings view should always perform an onchange to
fetch the view, and it wasn't the case here.

Now, we patch the basic model used on the settings view to remove the
res_id, to consider the record always as new. This will always perform
an onchange to fetch the data. Note that, this hack is the same as it
was done before the owl migration.

opw-3073124

closes odoo/odoo#107879

X-original-commit: 792567c71aed626b5566f32b656104e3e70c496c
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2022-12-14 11:42:08 +01:00
Jorge Pinna Puissant ebbc63dbff [IMP] web: improve setting search
Before this commit, the setting search was done exclusively in some
selected texts. These texts needed to be on some specific selectors
(field, label, span.o_form_label and div.text-muted).

Now, all text on a setting are searchable (including the text in
buttons). This commit also re-structure the setting compilers file to
remove the functions outside the class, this is done to standardize the
compilers (setting, form and view).

closes odoo/odoo#107226

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-12-08 08:48:46 +01:00
Jorge Pinna PuissantandMichael Mattiello (mcm) c7c2959449 [IMP] web, *: simplification and standardization of the settings arch
The aim of this commit is to simplify and standardize the settings archs.

To do this, a small DSL exclusively for the settings was created. This
new DSL introduces 3 tags: `app`, `block` and `setting`.

The `app` tag is used to declare the application on the settings view.
It creates an entry with its logo on the sidebar of the view. It also
acts as delimiter when searching.

```xml
    <app string="CRM" name="crm">
    ...
    </app>
```

- `string` : The "display" name of the application.
- `name` : The technical name of the application (the name of the module).
- `logo` *optional* : The relative path to the logo. If not set, the
        logo is created using the `name` parameter :
        `/{name}/static/description/icon.png`.

The `block` tag is used to declare a group of settings. This group can
have a title and a description/help.

```xml
    <block title="Title of group Bar">
    ...
    </block>
```

- `title` *optional* : The title of the block of settings (the old h2),
        you can perform research on its text.
- `help` *optional* : The description/help of the block of settings
        (the old h3), you can perform research on its text.

The `setting` tag is used to declare the setting itself. The first field
in the setting is used as the main field (optional). This field is
placed on the left panel (if it's a boolean field) or on the top of the
right panel (otherwise). The field is also used to create the setting
label if a `string` is not defined. The `setting` tag can also contain
more elements (e.g. html), all of these elements are rendered in the
right panel.

```xml
    <setting string="this is bar">
        <field name="bar"/>
        ...More elements
    </setting>
```

- `type` *optional* : By default, a setting is visually separated on two
        panels (left and right), and is used to edit a given field. By
        defining `type='header'`, a special kind of setting is rendered
        instead. This setting is used to modify the scope of the other
        settings. For example, on the website application, this setting
        is used to indicate to which website the other settings apply.
        The header setting is visually represented as a yellow banner on
        the top of the screen.
- `string` *optional* : The text used as label of the setting. If it's
        not defined, the first field is used as label.
- `title` *optional* : The text used as tooltip.
- `help` *optional* : The help/description of the setting. This text is
        displayed just below the setting label (with classname
        `text-muted`).
- `company_dependent` *optional* : If this attribute is set to "1" an
        icon is displayed next to the setting label to explicit that
        this setting is company-specific.
- `documentation` *optional* :  If this attribute is set, an icon is
        added next to the setting label, this icon is a link to the
        documentation. Note that you can use relative or absolute path.
        The relative path is relative to
        `https://www.odoo.com/documentation/server_version`, so it's not
        necessary to hard-code the server version on the arch anymore.

closes odoo/odoo#106425

Task-id: 3081367
Related: odoo/enterprise#34337
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: "Michael Mattiello (mcm)" <mcm@odoo.com>
2022-12-02 14:40:25 +01:00
Aaron Bohy 4c5b867ff6 [IMP] web,*: control form and kanban rendering context
Before this commit, the rendering context of kanban and form views
was the instance of the KanbanRecord and FormRenderer, respectively.
As a consequence, a lot of implementation details (e.g. "props",
"__owl__", any Class method...) were available. This wasn't what
we want.

The door being left open, people went through, and in 16.0, several
kanban and form archs contain(ed) such use of undesired "features".

With this commit, we restrict the rendering context of those two
views. In kanban views, it contains what has been historically
available (e.g. "record", "widget", "kanban_color"...). In form
views, nothing is available since the only dynamic part in those
archs is the attrs, which aren't evaluated by the rendering engine.

To do that, we use `t-call-context` owl directive. When using this
directive, the rendering context is the given one, + `this`. So the
component instance is still available, but through the `this`
keyword. We can thus use it in our compilers, to make them work as
before. Note that `this` can never be used in an arch directly.

Task 3085357

closes odoo/odoo#106045

Related: odoo/enterprise#34493
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2022-12-02 11:37:48 +01:00