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

[FW][FIX] web: SearchView of many2one is not getting the form domain #163029

Closed

Conversation

fw-bot
Copy link
Contributor

@fw-bot fw-bot commented Apr 23, 2024

Steps to reproduce the problem:

  1. Add a many2one field to lines of a model, example: sale.order.line
  2. Add it to form view of the lines with a domain
  3. Click on Search more... option
  4. You will see results out of the scope of the domain

In the getDomain is passed an object that has only the key fieldName but for knew in what view is the field placed it needs to be provided the key viewType, this both are placed on the class object this.recordParams builded at:

this.recordParams = {fieldName: this.name, viewType: this.viewType};

If this key is not provided the viewType is beeing filled with the element viewType, this element is the record opened placed in the parent view, so by default if will be kanban or list. So if the domain is filled just in the form view, the search panel will get the domain [], so all the entries will be displayed and they will be able to be selected.

If we see the next line:

context: _.extend({}, this.record.getContext(this.recordParams), context || {}),
We will see that getContext is getting this.recordParams as argument, for the same reason that the domain should have it.

With this changes the getDomain method is getting the viewType to take the domain instead of the viewType of the lines displayed on the parent view.

Description of the issue/feature this PR addresses:

Current behavior before PR:

Desired behavior after PR is merged:


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

Forward-Port-Of: #162983

@robodoo
Copy link
Contributor

robodoo commented Apr 23, 2024

@fw-bot
Copy link
Contributor Author

fw-bot commented Apr 23, 2024

This PR targets 16.0 and is part of the forward-port chain. Further PRs will be created up to master.

More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port

@C3POdoo C3POdoo added the RD research & development, internal work label Apr 23, 2024
@robodoo robodoo added the forwardport This PR was created by @fw-bot label Apr 23, 2024
@fw-bot
Copy link
Contributor Author

fw-bot commented Apr 23, 2024

@aab-odoo ci/runbot failed on this forward-port PR

Steps to reproduce the problem:

1. Add a many2one field to lines of a model, example: sale.order.line
2. Add it to form view of the lines with a domain
3. Click on Search more... option
4. You will see results out of the scope of the domain

In the getDomain is passed an object that has only the key
fieldName but for knew in what view is the field placed
it needs to be provided the key viewType, this both are placed
on the class object this.recordParams builded at:
https://github.com/odoo/odoo/blob/b8a5175b6c92749bd3bb7b9f869b1ecff78e133f/addons/web/static/src/legacy/js/fields/relational_fields.js#L129

If this key is not provided the viewType is beeing filled
with the element viewType, this element is the record opened placed
in the parent view, so by default if will be kanban or list. So
if the domain is filled just in the form view, the search panel
will get the domain [], so all the entries will be displayed and
they will be able to be selected.

If we see the next line:
https://github.com/odoo/odoo/blob/b8a5175b6c92749bd3bb7b9f869b1ecff78e133f/addons/web/static/src/legacy/js/fields/relational_fields.js#L431
We will see that getContext is getting this.recordParams as
argument, for the same reason that the domain should have it.

With this changes the getDomain method is getting the viewType
to take the domain instead of the viewType of the lines displayed
on the parent view.

X-original-commit: 2506a06
Co-authored-by: Aaron Bohy <aab@odoo.com>
@aab-odoo aab-odoo force-pushed the 16.0-15.0-many2one-domain-fix-aab-aJRc-fw branch from 83388e8 to e88fd46 Compare April 24, 2024 05:59
@aab-odoo
Copy link
Contributor

robodoo r+

@fw-bot
Copy link
Contributor Author

fw-bot commented Apr 24, 2024

@aab-odoo this PR was modified / updated and has become a normal PR. It should be merged the normal way (via @robodoo)

@C3POdoo C3POdoo requested review from a team, Iucapad and juliusc2066 and removed request for a team April 24, 2024 06:01
robodoo pushed a commit that referenced this pull request Apr 24, 2024
Steps to reproduce the problem:

1. Add a many2one field to lines of a model, example: sale.order.line
2. Add it to form view of the lines with a domain
3. Click on Search more... option
4. You will see results out of the scope of the domain

In the getDomain is passed an object that has only the key
fieldName but for knew in what view is the field placed
it needs to be provided the key viewType, this both are placed
on the class object this.recordParams builded at:
https://github.com/odoo/odoo/blob/b8a5175b6c92749bd3bb7b9f869b1ecff78e133f/addons/web/static/src/legacy/js/fields/relational_fields.js#L129

If this key is not provided the viewType is beeing filled
with the element viewType, this element is the record opened placed
in the parent view, so by default if will be kanban or list. So
if the domain is filled just in the form view, the search panel
will get the domain [], so all the entries will be displayed and
they will be able to be selected.

If we see the next line:
https://github.com/odoo/odoo/blob/b8a5175b6c92749bd3bb7b9f869b1ecff78e133f/addons/web/static/src/legacy/js/fields/relational_fields.js#L431
We will see that getContext is getting this.recordParams as
argument, for the same reason that the domain should have it.

With this changes the getDomain method is getting the viewType
to take the domain instead of the viewType of the lines displayed
on the parent view.

closes #163029

X-original-commit: 2506a06
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Aaron Bohy <aab@odoo.com>
@robodoo robodoo closed this Apr 24, 2024
MohammedBasioni pushed a commit to odoo-dev/odoo that referenced this pull request Apr 29, 2024
Steps to reproduce the problem:

1. Add a many2one field to lines of a model, example: sale.order.line
2. Add it to form view of the lines with a domain
3. Click on Search more... option
4. You will see results out of the scope of the domain

In the getDomain is passed an object that has only the key
fieldName but for knew in what view is the field placed
it needs to be provided the key viewType, this both are placed
on the class object this.recordParams builded at:
https://github.com/odoo/odoo/blob/b8a5175b6c92749bd3bb7b9f869b1ecff78e133f/addons/web/static/src/legacy/js/fields/relational_fields.js#L129

If this key is not provided the viewType is beeing filled
with the element viewType, this element is the record opened placed
in the parent view, so by default if will be kanban or list. So
if the domain is filled just in the form view, the search panel
will get the domain [], so all the entries will be displayed and
they will be able to be selected.

If we see the next line:
https://github.com/odoo/odoo/blob/b8a5175b6c92749bd3bb7b9f869b1ecff78e133f/addons/web/static/src/legacy/js/fields/relational_fields.js#L431
We will see that getContext is getting this.recordParams as
argument, for the same reason that the domain should have it.

With this changes the getDomain method is getting the viewType
to take the domain instead of the viewType of the lines displayed
on the parent view.

closes odoo#163029

X-original-commit: 2506a06
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Aaron Bohy <aab@odoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
forwardport This PR was created by @fw-bot RD research & development, internal work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants