Commit Graph
147 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
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
824024f8aa [REF] web,mail: formView design
- ButtonBox is moved to the ControlPanel's actions section (center).
- StatusBarField, ButtonBox and PercentPieField design.
- Chatter is moved below the ControlPanel (aka "in the view")

task-2818586

Part-of: odoo/odoo#116641
Co-authored-by: Pierre Paridans <app@odoo.com>
Co-authored-by: Pierre Rousseau <pro@odoo.com>
Co-authored-by: luvi <luvi@odoo.com>
2023-05-12 22:59:14 +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
Bruno Boi f22961ad07 [FIX] web,*: repair root class attr
*: web + adaptations in base, fleet, hr, hr_expense, hr_recruitment,
   loyalty, lunch, mail, mass_mailing, note, project, stock, survey,
   web_tour

**Foreword**
Since d19037e141 the rootnode class attribute for form/list views was
copied two times:
- on the o_view_controller div
- and on the root node of the view renderer.

Examples:

<form class="foo">...</form>

    gives

<div class="o_view_controller o_form_view foo">
    <div class="o_control_panel">...</div>
    <div class="o_content">
        <div class="foo o_form_editable ...">...</div>
    </div>
</div>

and

<list class="foo">...</list>

    gives

<div class="o_view_controller o_list_view foo">
    <div class="o_control_panel">...</div>
    <div class="o_content">
        <div class="o_list_renderer foo ...">...</div>
    </div>
</div>

**Issue**
This could lead to confusion and also unexpected styling issues.
See this PR #119815 to read a message JS Framework team has received.
See also another a fix that had to be made for x2m fields: 980244fa8

**Introduced Changes**
- in the form compiler, the root node attributes are no more copied to
  the root div node of the compiled template the form renderer receives
- the root div node generated by the form compiler now has the
  "o_form_renderer" class, which was removed during the recent form view
  refactoring.
- the list renderer no more adds the root node class attribute to its
  "o_list_renderer" div
- the X2ManyFieldDialog has been adapted too
- since View, X2ManyField & X2ManyFieldDialog both need to compute view
  classnames derivated from the arch root node, an util has been
  introduced to avoid duplicating code
- the whole codebase has been checked and adapted.

Related: odoo/enterprise#40418
Signed-off-by: Mathieu Duckerts-Antoine <dam@odoo.com>
2023-04-27 16:10:30 +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
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
FrancoisGe 2ecfed335d [REF] *: extractProps receive dynamicInfo
Before this commit, the use of multiple <field> with the same name in a
view was not well supported.

Why was this?
Some Field components need to know information related to the <field>
such as context, domain, required and readonly. The solution used before
this commit to access this information is to use the getFieldContext,
getFieldDomain, isReadonly, isRequired functions of the model.
Unfortunately, these only take into account the last occurrence of the
<field> because the model is not aware that the same field is present
several times on the view. The information must therefore not come from
the model. For example, it was not possible to have the same field
twice with 2 different domains. It will use the domain of the last
field for both.

Solution:
We will add the object "dynamicInfo" to the fieldInfo passed to the Fields
extractProps function. This object will contain a getter to get the value
of required, readonly, domain and context for the current <field>.
If a Field needs one of its information, it will just have to get it
from extractProps.

Part of Task: 3179751

closes odoo/odoo#115197

Related: odoo/enterprise#38151
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-03-24 01:24:48 +01:00
Jorge Pinna Puissant c7aff4cb7d [FIX] web: remove translation alert banner
The translation alert banner is an old remaining edit/save feature that
is not relevant anymore with the new "always edit" and the "save when
leave" features.

closes odoo/odoo#115866

Task-id: 3232795
X-original-commit: dfd65d08ef3d76f9cd702927ee09dafe429d895a
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-03-20 18:13:06 +01:00
Michael (mcm) 3f65bfb158 [FIX] web: prevent recreating a deleted record
Before this commit, deleting a record containing
changes (dirty) recreated the record when leaving the view.
Now, the changes are discarded when deleting the
record so it is not marked as dirty and not recreated.

task id: 3063834

closes odoo/odoo#115767

X-original-commit: cf8952aaac1ba9b43f0f558cc15e48462defcfe7
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-03-20 09:03:49 +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
Louis Wicket (wil) 9afe7c74c9 [IMP] *: remove "French spacing" 👺
According to Wiktionary, French spacing is "the archaic practice (though
still current in French) of inserting a space around colons, semicolons,
question marks, and exclamation marks". This is not standard practice in
English and most languages of the world.

The purpose of this commit is to start purging the code from this typo,
as it may reflect poorly on the software for some people.

closes odoo/odoo#114533

Related: odoo/enterprise#37853
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-03-14 15:52:10 +01:00
Mathieu (mano) d8958a45ba [FIX] web: checkboxes design & consistency
The main objective of this commit is to make checkboxes consistent
and fix their spacing issues.

Prior to these changes, the checkboxes on the `product_view` were
too close to their neighboring option labels, making it difficult to
know which checkbox to tick.

The new changes fixes inconsistencies in general such as undesired
hovering effects and the cursor behaviors on disabled inputs.

This commit also removes the margin in the checkbox template since the
padding from the checkbox wrapper compensates for the spacing between
the checkboxes and their respective labels.

Tweaking the selector in `settings_form_view.scss` to ignore boolean
field inputs allows us to get rid of max-width and margin overrides
introduced in commit b90059e936.

Most checkboxes were already falling under their labels on mobile, but
this change impacted those that were not. To address this issue, we
decided to consistently change the position of the checkboxes left to
their labels for small devices in form view.
This required slight adjustments to the `form_group.xml` template.

Still in form_view, for some of the specific checkboxes such as
`o_checkbox_optional_field` the changes in `form_controller.scss` are
made to mimic the new behavior for mobile sized screen.

However, if they are using the form_group template, their behavior
is unchanged at the moment.

Finally, even if these changes makes it better for most of them, some
checkboxes in `settings` still require some minor adjustments and will
be addressed in task-3113372.

task-3094083

closes odoo/odoo#114612

X-original-commit: ddb7574f97f11e69f0304c8bd8d55c2c53ab53fd
Related: odoo/enterprise#37887
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2023-03-10 12:31:11 +01:00
Hubert Van de Walle (huvw) 9b136383c2 [FIX] web,mrp,stock: don't call action buttons for virtual records in x2manys
Steps to reproduce
==================

- Make sure the "Work Orders" setting is enabled
- Manufacturing > Products > Bills of Materials > New
- Select a random product
- In the Operations tab, add a line
- Type something in the Operation field
- Set the workcenter to Assembly line 1
- Save and close
- Click on the "Show Instructions" action button

```
Traceback (most recent call last):
  File "/home/hubert/src/16.0/odoo/odoo/models.py", line 5108, in ensure_one
    _id, = self._ids
    ^^^^
ValueError: not enough values to unpack (expected 1, got 0)
```

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

The action is called without in id because the record is not yet created

Solution
========

The button should display a warning in x2manys when the record is virtual.
This was actually the case before Odoo 16 but there was an option on the
button `options='{"warn": true}'`. With this commit, it will be the
default behavior.
We also remove this option from the xml since it isn't used.

sentry-3950549982

closes odoo/odoo#114505

X-original-commit: 9fc0424a4450923aa8582bdb6766e1b19cb68546
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Hubert Van De Walle <huvw@odoo.com>
2023-03-07 18:02:53 +01:00
Jorge Pinna Puissant a73390a42a [REF] web: remove isVirtual function from Record
Before this commit, the model's record had two similar functions: isNew
and isVirtual, this commit will remove the isVirtual function to only use
the isNew one.

closes odoo/odoo#114431

Part-of: task-id 3179751
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-03-07 02:56:18 +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
Aaron Bohy 9374a6f2b7 [REF] *: js fields: extractProps receives fieldInfo
This commit is part of the preliminary work to rewrite the form,
list and kanban model. We want this new Model to only be aware of
field related information it needs (whereas in its current
implementation, the model stores all the information extracted
from the field node in the arch). This would allow to properly
manage multiple occurrences of the same field in views, that is,
each occurrence would be represented by a field component (if
visible of course), and that field component would use the field
information of the arch node it represents. To this end, we want
fields from not using anymore information stored in activeFields
in the record datapoint. Instead, we now call extractProps with
the whole fieldInfo (the information extracted from the arch), s.t.
each field can generate the props it needs from those information
(e.g. sub views for x2manys).

This commit doesn't remove the use of record.activeFields in
concrete fields (this will come later), but reworks the fieldInfo
object generated by parseFieldNode, and provide it to the calls of
extractProps. In fieldInfo, the `options` key is no longer inside
`attrs`, as it is now top-level, alongside several other generic
keys that have been processed (like on_change, modifiers...). For
that reason, a lot of extractProps definitions had to be adapted.

Part of task 3179751

closes odoo/odoo#113092

Related: odoo/enterprise#37266
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
2023-02-24 11:11:32 +01:00
FrancoisGe 94c49cfdee [REF] *: fieldDependencies to Array
As with fieldsToFetch in commit 25bf5a3fabfa9da5367e82d1c5713425c77bc373,
we will convert fieldDependencies into an array of fields.
We did it because it's easier to use and more natural to has an array.

Part of task 3179751

closes odoo/odoo#113482

Related: odoo/enterprise#37449
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-02-23 16:08:42 +01:00
FrancoisGe 5126c9b1d4 [REF] *: register widget descriptors instead of components
Before this commit, the widget's description was stored on the
component and this component was then registered.

Now, an object describing the widget is used on registration the same way
as it is done for views since b828cfc.
This split the component's description (props, template, ...) of
the widget's description ( component, extractProps, ...) and makes
it clearer.

We did the same thing for fields in 9f4622492c

Part of task: 3179751

closes odoo/odoo#112962

Related: odoo/enterprise#37215
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-02-21 15:53:06 +01:00
Michael (mcm) 9f4622492c [REF] *: register field descriptors instead of components
Before this commit, the field's description was stored on the
component and this component was then registered.

Now, an object describing the field is used on registration the same way
as it is done for views since https://github.com/odoo/odoo/commit/b828cfc72c587d0b73fcc5459695705640437671.
This split the component's description (props, template, ...) of
the field's description (displayName, supportedTypes, ...) and makes
it clearer.

closes odoo/odoo#112498

Task: 3171520
Related: odoo/enterprise#37105
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-02-16 14:13:32 +01:00
fdardenne 1bfc3aa1cf [IMP] web: x2many list: deactivate modal when in editable
Before this commit, in a form view, it was possible to open a record in
a x2many list field when the list is editable (`editable="top|bottom"`)
and the form view or the field is in readonly.

We want to disable the opening of the record in this case to stay
consistant for a better UX:
- when in a editable x2many list, the record form view never opens (even
  if the form view or the field is in readonly)
- when not in editable, the form view always opens

This commit does not modify the behaviour of the x2many field kanban
view.

task-2964320

closes odoo/odoo#110838

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-02-07 15:35:49 +01:00
amdi-odoo 28746db41e [IMP] web: add dialog attributes
Purpose
=======
Extend the customization of the confirmation dialog
by creating 2 new optionnals attributes:
"confirm-title": To change the dialog title
"confirm-label": To change the dialog confirmation label

Task-3098731

Part-of: odoo/odoo#108410
2023-02-03 16:32:08 +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
Victor Feyens 509b30853e [FIX] web: field wrongly considered as always invisible
If a field is present twice in a view, the field information
stored in the relational model `activeFields` holds and consider
only the latest xml node found.

Therefore, a field is sometimes considered alwaysInvisible
when it is visible and editable.  This means that you might click
on the 'Save' button and get a server error because a required field
is not set when you should the required field should have been
highlighted and requested before making a `create` rpc request.

This commit makes sure that for the alwaysInvisible logic,
both nodes are considered.

closes odoo/odoo#110959

X-original-commit: 3d490a264b2fe837f9dc5138f8605f5466b7c312
Signed-off-by: Georis François (fge) <fge@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-01-27 10:47:41 +01:00
Eteil Djoumatchoua (etdj) 8827e20383 [FIX] web: Get the correct list of actions on hr.leave form view
Steps to reproduce:
- Go to base Runbot and install Time Off.
- Go to Time Off > List View and select a list view item (checkbox).
- Go to Action and notice there is no Archive option.
- Go to the form view and go to Action > Archive.
- See error about not being able to archive leaves.

Issue:
We can see the action archive but we can not run it

Expected behaviour:
We shouldn't be able to see that action archive

Cause:
When computing the value of archiveEnabled we use the wrong variable "activeFields".

Solution:
Give the good one, "this.props.fields"

opw-3079475

closes odoo/odoo#110836

X-original-commit: 122fa724e1f15e8c28a29bbe8a80c089ff954956
Signed-off-by: Bruno Boi (boi) <boi@odoo.com>
2023-01-26 18:51:18 +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
Aaron Bohy f58f2e0d4f [FIX] web: do not save untouched fields on F5
Have a char field with trim option set to True (this is the
default). Open a form view where the value of this field has
leading or trailing spaces. Press F5 (or close the tab/browser).
Before this commit, a write was done before leaving, with the
trimmed value of the char field.

This isn't the expected behavior: as the field hasn't been manually
edited, we don't want to write on it.

This could be reproduced on project.task form views, on tasks with
a name with leading/trailing spaces (e.g. tasks created by mails
sent to feedback@odoo.com).

The issue occurred when we saved a record "urgently" (before unload)
because we parsed the value of each input field, and we sent it if
it was different from the initial (or last set) value. In our case,
parsing the value trimmed it, and it was thus different from the
initial value.

Bug reported after the migration of odoo.com to 16.0.

closes odoo/odoo#110528

X-original-commit: 43b7ae39e633ced6008b067bb4e63ed9be7eda01
Signed-off-by: Michaël Mattiello <mcm@odoo.com>
2023-01-20 20:58:45 +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
Thomas Lefebvre (thle) c70e410050 [FIX] web: correct type of defaultPage prop
Steps to reproduce:
- go to "Link Tracker" app;
- go to "Campaigns" tab (UTMs);
- create a new campaign;
- leave and return in this record.

Issue:
A traceback appears.
Error message:
`Invalid props for component 'Notebook': 'defaultPage' is not a string`

Cause:
The `defaultPage` prop must be a string.
When the record is new, it will be `undefined`,
so it will pass props validation because this prop is optional.
But when we try to calculate it and it does not return a value,
the `defaultPage` is null.
The variable is therefore declared but it is empty
(and therefore not a string).
`null` value does not pass the props validation test.
The problem appears in the "Campaigns" tab
because there is a notebook without content.

Solution:
Test if it is possible to have a value.
If not, set the `defaultPage` prop to be `undefined`.

opw-3109327

closes odoo/odoo#109533

X-original-commit: 402b1a822c3983af33aa1d3a3c7e93d8836c60d8
Signed-off-by: Dardenne Florent (dafl) <dafl@odoo.com>
2023-01-10 16:50:58 +01:00
FrancoisGe 5d7136c21d [FIX] web: Incorrect navbar when leaving an invalid form view
Before this commit, when trying to change the menu from an invalid form
view, you would stay on the form view but the navbar would be modified
to dispaly the menu you had selected.

How to reproduce:
- Go to a form view
- Edit the fields so that the record is invalid
- Change the menu using the menu app or the palette command

Before this commit:
The form view has not changed but the navbar has been modified, it shows
the menu you selected.

After this commit:
The form view and the navbar have not changed.

closes odoo/odoo#109460

X-original-commit: bd7e36edcd2f9d33a72cc25b030f91c20da78387
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-01-10 08:14:46 +01:00
Maruan Aguerdouh (magm) eb4197e22b [FIX] web: sheet views displaying properly for ecommerce categories form
Steps to reproduce:

- Go to the eCommerce app > eCOmmerce Categories.
- Select any categorie or try to create a new one.

Issue:

The box containing the fields it's not displayed properly.

Solution:

Added the class `clearfix` to the sheet component as it used to be in
previous versions.

opw-3080099

closes odoo/odoo#109408

X-original-commit: 4373cf2901b8db61592eba7cff2fae60ff68348a
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-01-09 12:22:59 +01:00
Aaron Bohy 7095310672 [FIX] web: view compiler: generic tags are case insensitive
In html, tags are case-insensitive. However, owl templates aren't,
as nodes starting with a capital letter are considered as component
nodes (not html). This means that people can use capital letters in
form or kanban archs for html nodes and it should work.

Before this commit, it didn't, because the compiler kept the case
when generating the owl templates. For instance, an arch like
`<form><Div/></form/>` produced the error 'Cannot find the
definition of component "Div"'. This commit fixes the issue.

Part-of: odoo/odoo#108221
2022-12-19 16:49:03 +01:00
Aaron Bohy aa616d2880 [FIX] web,mail,project: ViewCompiler: warn if wrong usage
Kanban and form archs aren't owl templates. Kanban archs define
a (historically) qweb template ("kanban-box") which is html + some
directives (e.g. t-esc, t-foreach...) and extra tags (field, widget).
Form view archs are html + some extra tags (e.g. group, notebook,
field, widget...).

With the conversion of those views to owl, a door was left open:
one *could* use owl directives (for instance, t-on-click) in archs.
However, we don't want people to do that, as it would tie the archs
in database with js implementation details, which will then limit
the evolution of the js framework.

This commit adds warning when such forbidden directives are detected.
In master, we'll raise errors.

Part-of: odoo/odoo#108221
2022-12-19 16:49:02 +01:00
Adrien Dieudonné 94cb7ba07d [FIX] web: status indicator next to the breadcrumb
Before this fix, the '.o_form_status_indicator' was in the right
part of the control panel.
But on desktop, we want it next to the last breadcrumb item
to cognitively attach the "save status" to the record name.

closes odoo/odoo#107397

Task-id: 3067691
X-original-commit: 24b098767b03c97ffe108a7f8aa0f77c08aecef5
Signed-off-by: Pierre Paridans (app) <app@odoo.com>
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2022-12-07 18:29:33 +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
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
amdi-odoo 57c8e7face [FIX] web: prevents not dirty forms saving
Purpose
=======
Prevents auto save of not dirty forms with
text fields on page reload and tab/browser closing.

Specifications
==============
The text field default value is making Odoo consider
the form as dirty even when it's not which triggers
auto saving for not dirty forms.

Change the text field widget setDirty condition to
prevent considering empty textarea string dirty.
Typically, if the previous value was false, false and
empty string should be considered as the same value.

Task-3031570

closes odoo/odoo#106619

X-original-commit: 787ef58dd3f91f829509f738ee40c8764c403757
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-11-25 19:52:02 +01:00
FrancoisGe a882b725bb [REF] web: adds the callback onWillSaveRecord and onRecordSaved
The purpose of this commit is to add extension points that allow code
to be executed before and after the save of a record.

CallBack:
    onWillSaveRecord is a callBack that will be executed before the
        record save if the record is valid if the record is valid.
        If it returns false, it will prevent the save.

    onRecordSaved is a callBack that will be executed after the save
        if it was done. It will therefore not be executed if the record
        is invalid or if a server error is thrown.

This commit will replace all the save overrides by the onWillSaveRecord
and onRecordSaved callBack.

Observed problem:
We could notice that each of the overrides of save in order to execute
for example a doAction after this one did not take into account the fact
that the save did not succeed.
For example, a required field is invalid and we try to save, then the
doAction will be executed without the "write" of the save.
The callBack onRecordSaved will prevent this common error.

closes odoo/odoo#105180

Related: odoo/enterprise#33710
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-11-15 13:01:29 +01:00
Adrien Dieudonné a68d8bd2fb [FIX] web: form: ignore invisible items from rows
Before this commit, we had an issue with the width calculated
for data cell (see. sizeOfDataCell).
In some case, the width was 50% instead of taking 100% of the
available space.

This was because some elements of the inner groups that should not
have been visible were computed as if they were, taking an effective
slot in an innergroup's row.

E.g. with two labels:

Before:
"invisible label" and "label" on the same line with `style="width: infinite"`
"data field" on a second line with `style="width: 50%"`

After this commit:
"label" and "data field" on the same line with `style="width: 100%"`

Note that as `infinite` is not a valid value, this wasn't interpreted and
style attribute was empty.

Thanks to grid for still aligning elements even if they are technically
in different rows. It's why we only saw this issue because of the
width of the data cell.

Steps to reproduce:
- Go to Accounting
- Customer -> Invoice
- Create a new invoice
-> See Customer field

Thx to @kebeclibre

closes odoo/odoo#105489

X-original-commit: e177c63e3618e4b9e492a27d1301c098a0066cb6
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2022-11-09 19:03:48 +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
Joseph Caburnay c412f11c02 [REF] web,web_*: import owl features using "@odoo/owl" module
In @odoo-module files, we do the following conversion:

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

While in legacy odoo module (odoo.define):

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

closes odoo/odoo#104260

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

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

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

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

closes odoo/odoo#103723

Related: odoo/enterprise#33044
Signed-off-by: Géry Debongnie <ged@odoo.com>
2022-10-26 16:07:18 +02:00
Aaron Bohy 3f12de691b [FIX] web: ConfirmationDialog: do not call confirm twice
Before this commit, multi clicking quickly on the "Ok" or "Cancel"
buttons of a ConfirmationDialog would call the confirm/cancel
callbacks multiple times. For instance, in "Mass mailing", create
a new mailing and click "Send". In the confirm dialog, clicking
quickly multiple times on "Ok" would call the "Send" button action
multiple times.

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

Fixing #74647 (from 16.0 to master)

closes odoo/odoo#103572

X-original-commit: 95f8266a5b84f5faa59a713019ab713392b3ef78
Signed-off-by: Géry Debongnie <ged@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-10-20 10:19:58 +02:00
Mathieu Duckerts-Antoine 8c2ec7b4de [REF] web: remove PieChart
Now that the module web_dashboard has been removed https://github.com/odoo/enterprise/pull/31641,
the component PieChart is unused. We remove it.

closes odoo/odoo#102761

X-original-commit: 3e92c60034cedcd999572bb7e93c8b05ca07be70
Related: odoo/enterprise#32573
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Mathieu Duckerts-Antoine <dam@odoo.com>
2022-10-19 11:11:53 +02:00
Thomas Lefebvre (thle) b4f9086bff [FIX] web: correctly append attribute expressions
Steps to reproduce:
    - install "Peru - Accounting" module (l10n_pe module);
	- try to open a contact form.

Issue:
    An error message appears with an impossibility of access to the form.

Cause:
    The function that concatenates the different attributes should not take into account the "{{ ... }}" tags already put in before.

    Example:
    When appending `scope && scope.className || ""` to `{{props.record.isInEdition ? 'o_form_editable' : 'o_form_readonly'}} d-block {{ props.record.isDirty ? 'o_form_dirty' : !props.record.isVirtual ? 'o_form_saved' : '' }}`;
    This is generated:
    `{{{{props.record.isInEdition ? 'o_form_editable' : 'o_form_readonly'}} d-block {{ props.record.isDirty ? 'o_form_dirty' : !props.record.isVirtual ? 'o_form_saved' : '' }} scope && scope.className || "" }}`
    instead of:
    `{{props.record.isInEdition ? 'o_form_editable' : 'o_form_readonly'}} d-block {{ props.record.isDirty ? 'o_form_dirty' : !props.record.isVirtual ? 'o_form_saved' : '' }} {{scope && scope.className || "" }}`

opw-3018917

closes odoo/odoo#103460

X-original-commit: 846d3b3c67e8ef46ecb29c5d72d895b2b852fc10
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Lefebvre Thomas (thle) <thle@odoo.com>
2022-10-19 07:21:55 +02:00
Aaron Bohy 5da13e1d5a [REF] web: remove legacy fields/widgets compatibility layer
This commit removes the code that wrapped legacy fields and widgets
(coming from the legacy registries) into owl components and added
them to the wowl registries. This temporary compatibility layer,
which was incomplete and only allowed us to merge the new views
without converting all fields/widgets in once without breaking
everything, is no longer necessary as we now have converted all of
them into owl components.

X-original-commit: 555959c87e25faa71396f61479e8bb41b66ac164
Part-of: odoo/odoo#102606
2022-10-18 18:05:01 +02:00
Lucas Perais 62526a3546 [FIX] web: discarding an existing record in form view action target new.
Do an action in target new that will spawn a record in its form view.
The typical example is "Edit View: XXX" in the debug systray.

On the dialog, click on "Discard".

Before this commit, that button did not close the dialog.

After this commit, that "Discard" button closes the dialog.

closes odoo/odoo#103275

X-original-commit: 08751e0eef0cefe74e626ffa8ba26a5e8f18113f
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2022-10-18 13:17:06 +02:00