Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] base: consider multi_edit="1" views editable #103743

Closed

Conversation

beledouxdenis
Copy link
Contributor

Since #95729

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

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

As tree views having multi_edit="1" where not considered
as editable views, the domain of fields in these views were not
validated:

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

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

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

Since odoo#95729

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

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

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

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

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

Hence, views are adapted to add back fields with `invisible="1"`
when they are required in domains of other fields.
Before this commit, in a list view in multi_edit mode and editable="0",
it was possible to edit a required field with an invalid value.

Why:
In the PR 101924, we decided to no longer pass readonly/required of fields
in non-editable views (if no editable="1").

Solution:
To know if a view is editable, you should not only look if it is
editable="1" but also if it is multi_edit="1".
So we want to pass the readonly/required fields if the view is
editable="1" or multi_edit="1".

How to reproduce:
- Go to a multi_edit="1" and editable="0" list view with at least one
  required field on the server side
- Select the checkbox of the record you want to edit
- Edit that field with an invalid value (e.g. clearing a text field)
- Click outside the line being edited

Before this commit:
The record is saved with the invalid value

After this commit:
An alert dialog is displayed to warn us that the value is invalid.
The record returns to readonly mode with the old value.
@robodoo
Copy link
Contributor

robodoo commented Oct 21, 2022

@C3POdoo C3POdoo requested review from a team October 21, 2022 09:57
@C3POdoo C3POdoo added the RD research & development, internal work label Oct 21, 2022
@pedrobaeza
Copy link
Collaborator

@moylop260 the Denis' initial explanation is what we are handling in OCA/odoo-pre-commit-hooks#10

@beledouxdenis
Copy link
Contributor Author

robodoo rebase-ff
robodoo r+

@robodoo
Copy link
Contributor

robodoo commented Oct 21, 2022

Merge method set to rebase and fast-forward.

robodoo pushed a commit that referenced this pull request Oct 21, 2022
Since #95729

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

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

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

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

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

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

Part-of: #103743
@robodoo robodoo closed this in 554397c Oct 21, 2022
@robodoo robodoo temporarily deployed to merge October 21, 2022 13:19 Inactive
moylop260 added a commit to vauxoo-dev/odoo-pre-commit-hooks that referenced this pull request Oct 24, 2022
moylop260 added a commit to vauxoo-dev/odoo-pre-commit-hooks that referenced this pull request Oct 24, 2022
moylop260 added a commit to OCA/odoo-pre-commit-hooks that referenced this pull request Oct 24, 2022
moylop260 added a commit to vauxoo-dev/pylint-odoo that referenced this pull request Oct 24, 2022
moylop260 added a commit to vauxoo-dev/pylint-odoo that referenced this pull request Oct 24, 2022
moylop260 added a commit to OCA/pylint-odoo that referenced this pull request Oct 24, 2022
svs-odoo added a commit to odoo-dev/odoo that referenced this pull request Nov 4, 2022
Following odoo#103743
Changes the xpath adding the `batch_id` in the picking list view from
before `company_id` to after `picking_type_id` because the linked commit
added an invisible `company_id` at the start of the list, so the
`batch_id` was wrongly placed.
robodoo pushed a commit that referenced this pull request Nov 4, 2022
Following #103743
Changes the xpath adding the `batch_id` in the picking list view from
before `company_id` to after `picking_type_id` because the linked commit
added an invisible `company_id` at the start of the list, so the
`batch_id` was wrongly placed.

closes #104888

Signed-off-by: William Henrotin (whe) <whe@odoo.com>
fw-bot pushed a commit to odoo-dev/odoo that referenced this pull request Nov 4, 2022
Following odoo#103743
Changes the xpath adding the `batch_id` in the picking list view from
before `company_id` to after `picking_type_id` because the linked commit
added an invisible `company_id` at the start of the list, so the
`batch_id` was wrongly placed.

X-original-commit: d3f6bd6
@fw-bot fw-bot deleted the 16.0-multi-edit-required-fge branch November 4, 2022 13:46
robodoo pushed a commit that referenced this pull request Nov 8, 2022
Following #103743
Changes the xpath adding the `batch_id` in the picking list view from
before `company_id` to after `picking_type_id` because the linked commit
added an invisible `company_id` at the start of the list, so the
`batch_id` was wrongly placed.

closes #104981

X-original-commit: d3f6bd6
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Steve Van Essche <svs@odoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RD research & development, internal work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants