Commit Graph
218 Commits
Author SHA1 Message Date
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
Bruno BoiandLuis González 29ca002ee5 [FIX] web: menus missing aria attributes
Some missing aria attributes from 14.0 are reintroduced.

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

closes odoo/odoo#106277

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Bruno Boi (boi) <boi@odoo.com>
Co-authored-by: Luis González <lgonzalez@vauxoo.com>
2022-11-23 13:24:51 +01:00
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
fdardenne 9d74c8ec4d [FIX] web: legacy_client_actions: scroll to saved position
Before in a legacy client action, using a link to change view and
going back to the client action with breadcrumb does not restore the
scroll position.

Now with this commit, the scroll position is restored when going back to``
the client action.

Steps to reproduce:
- Install Accounting
- Go to `Accounting -> Reporting -> Balance Sheet`
- Unfold the tree to make the window scrollable
- Click on a link at the bottom of the window
- Go back to Balance Sheet

closes odoo/odoo#105443

X-original-commit: 225e809aa3ce1c506be69287e8084adf877547d7
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-11-09 15:04:11 +01:00
Jorge Pinna PuissantandLucas Perais 21374cc41a [FIX] web: form_compiler, classes on FormLabel in a group
Before this commit, when compiling a form group, the scope class is
added to the elements of the outer group. It was added on the element
class attribute. The issue is that FormLabel don't have a class
attribute but a className attribute. So the class wasn't shown on the
DOM.

Now, the class is added on the FormLabel className attribute and shown
in the DOM.

closes odoo/odoo#105315

X-original-commit: 214beb39d7c1a315255f0a5a842e60f73e7900cc
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Lucas Perais (lpe) <lpe@odoo.com>
2022-11-08 14:40:15 +01:00
Jorge Pinna PuissantandPatrick Hoste e42175c1d5 [FIX] web: settings_form_compiler, copy all attributes to the labels
Before this commit, the labels tags that were after the fields losses
their attributes (i.e. classes) after the compilation of the form view
arch.

Now, the attributes are correctly copied after the compilation.

similar to : 873790f802

X-original-commit: 395bdf8880c5929652838a93351596b045708905
Part-of: odoo/odoo#105315
Co-authored-by: Patrick Hoste <pko@odoo.com>
2022-11-08 14:40:15 +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
Hubert Van de Walle (huvw) 7b948a731f [FIX] web: discard rejected reloadProms in magicReload
Steps to reproduce:

  - Go to a list view with multiple items
  - Click on an item
  - Delete it
  - Go back in history twice (Using the browser navigation) to return to the list view
  -> We can't click on another record

opw-2854113

closes odoo/odoo#103808

X-original-commit: 92c90823139b413c8289d1c323ad694fc8220a61
Signed-off-by: Hubert Van De Walle <huvw@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-10-21 17:17:19 +02:00
Aaron Bohy 3f12de691b [FIX] web: ConfirmationDialog: do not call confirm twice
Before this commit, multi clicking quickly on the "Ok" or "Cancel"
buttons of a ConfirmationDialog would call the confirm/cancel
callbacks multiple times. For instance, in "Mass mailing", create
a new mailing and click "Send". In the confirm dialog, clicking
quickly multiple times on "Ok" would call the "Send" button action
multiple times.

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

Fixing #74647 (from 16.0 to master)

closes odoo/odoo#103572

X-original-commit: 95f8266a5b84f5faa59a713019ab713392b3ef78
Signed-off-by: Géry Debongnie <ged@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-10-20 10:19:58 +02:00
Lucas Perais 2a3bd05bac [FIX] web: form settings: keep scroll position per module app
Have more than one Odoo module installed. Go to the Settings.
Scroll the first page.
Change the app in the sidebar.

Before this commit, the scroll position was the same for all modules (or apps, same thing).
It is not wrong per se, but when changing app, there is no reason that the scroll position of the former
is somehow correct business-wise.

After this commit, the scroll position is stored and restored on a per-app basis.

closes odoo/odoo#103369

X-original-commit: 01b16c392b888ceaccc8b0c95da142dbb90517ef
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2022-10-18 13:17:22 +02:00
Lucas Perais 9390319b79 [FIX] web: settings form view should not autofocus its field
Have a simple char field somewhere in res.config.settings.

Before this commit, when arriving on the settings form view, the settings page
was scrolled. This was because the standard FromRenderer has and used its autofocus feature,
thus focusing the first text field present in the view.
After that, the Settings form view gave the focus back to its search view input.

After this commit, the FormRenderer's autofocus feature is deactivated.

X-original-commit: 2c67b1dbe15d2cb77ee0b50514a4b9d41a006114
Part-of: odoo/odoo#103369
2022-10-18 13:17:22 +02:00
stefanorigano (SRI) 5234fad374 [IMP] web, base: adapt for dark-mode
This commit adapts several components in order to correctly handle
color-scheme variations.

It also allows user_menu to handle switch entries 

task-2710677

Part-of: odoo/odoo#102868
2022-10-11 13:15:53 +02:00
Mathieu Duckerts-Antoine fecde580d5 [FIX] web: tree found in action views
Before this commit, open an act window action asking for a tree view
would cause a crash. We fix that.

closes odoo/odoo#101831

X-original-commit: fa6fd8b079ad3347f3571654f07bf9751834654d
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-10-01 17:04:48 +02:00
Simon Genin (ges) 6233bcbac3 [FIX] web: markup no content helper with session storage actions
When an action was retrieved from session storage, the no content helper
content was not markuped. It would therefore display hmtl text on the
user screen.

closes odoo/odoo#101306

X-original-commit: 592b8016b8a44dc1775918e4ffbf572e9b02c50f
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Simon Genin (ges@odoo) <ges@odoo.com>
2022-09-27 17:11:34 +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
Jorge Pinna PuissantandLucas Perais e234810faa [FIX] web: SettingsPage propagate NoContentHelper slot
Before this commit, we propagate all the slots to the SettingsPage. This
could raise an issue if the default slot (propagated) has a content, for
more information see: https://github.com/odoo/owl/issues/1256

Now, to avoid this, we only propagate the slots that are used on the
SettingsPage component, ie: NoContentHelper.

closes odoo/odoo#100362

Signed-off-by: Géry Debongnie <ged@odoo.com>
Co-authored-by: Lucas Perais <lpe@odoo.com>
2022-09-16 16:20:49 +02:00
Aaron Bohy 8f58b1c768 [FIX] web: actionService: do not allow to leave invalid form
From a (e.g.) list view, click on "Create". In the form view, fill
in some fields, but leave a required field empty. Click on the
breadcrumbs to come back to the list. Before this commit, a
notification was displayed (because some required fields are
unset), but we left the form to come back to the list anyway.

The desired behavior is to stay on the form view, and display a
notification indicating that some fields are invalid.

In legacy views, we rejected promises to indicate that we couldn't
leave. This is a pattern we tried not to use anymore in new code.
Instead, we return a promise (if the method is async obviously)
which resolves to a boolean value, indicating if it works or not.
As a consequence, the action service wasn't properly dealing with
new views, as the promises they return always resolve.

This commit fixes the issue by adapting the code in the action
service.

Part-of: odoo/odoo#100050
2022-09-13 13:53:41 +02:00
Aaron Bohy 5f499d170e [FIX] web: apply default favorite even if active_id(s)
Before this commit, we didn't apply the default favorite (if any),
when there was an active_id or active_ids in the context. This was
a mistake. Note that it only impacted owl views.

closes odoo/odoo#99989

X-original-commit: 1e13e6cd073e57b3744caefc4b8f3795c35a4c10
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-09-12 13:49:37 +02:00
Samuel Degueldre 3db59860cb [IMP] web: display full tracebacks for error chains
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)

closes odoo/odoo#98157

Signed-off-by: Géry Debongnie <ged@odoo.com>
2022-09-12 13:48:49 +02:00
Hubert Van de Walle (huvw) 04b3a890d4 [FIX] web: duplicated breadcrumbs when discarding settings
Steps to reproduce:

  - Go to settings
  - Click on discard
-> the breadcrumbs contains twice the "Settings" entry.

This commit fixes the issue by restoring the legacy behavior in
the "Discard" button handler, that is, calling doActionButton with
the special="cancel" param. This had been changed by mistake during
the conversion of the settings form view.

To make the fix work, a slight changed has been done in the model
as well, as reloading a datapoint could lead to the creation of
a new datapoint (typically when it's a new record), so the handle
must be updated in this case.

closes odoo/odoo#99904

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-09-12 11:38:18 +02:00