odoo/odoo#163029

Created by fw-bot
label
odoo-dev:16.0-15.0-many2one-domain-fix-aab-aJRc-fw
head
e88fd467c694e53ee6cc318b16879b3d426def57
target
16.0
merged
3 weeks ago by JavaScript, Aaron Bohy (aab)
forward-port of
odoo/odoo#162983 DETACHED (Head updated from 83388e8ac0bfb30d2c108ef1ce4fd08e17f5a6c6 to e88fd467c694e53ee6cc318b16879b3d426def57)

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

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.

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: odoo/odoo#162983