Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
Whenever a user is trying to search sale order, quotation, lead, contract or invoice (in the top right corner), as the typing goes on the suggestions are shown for both customers and contacts within this company. In our installation we are looking for limiting that search to show only companies, which have is_company set to true. Any idea how to approach that?
Make sure you are logged in as a user with administration rights and technical features activated.
Go to: Settings -> Technical -> User Interface -> Views
Search for the view with view type 'Search' and for the object you want to change the search behaviour (in your case that might be sale.order or quotation, etc)
Duplicate the view and edit it:
- Change the View Name (to whatever you like)
- Set Inherited View to the exact view you just duplicated
Edit the Architecture as follows:
- Add a xpath tag arround the outer <search> tag with expr="/search" and position="replace".
- Add a domain attribute inside the field tag for those fields you want to change the behaviour.
Example for Partner Search View:
<?xml version="1.0"?> <xpath expr="/search" position="replace"> <search string="Search Partner"> <field name="name" string="Name" domain="[('is_company','=',True),]" filter_domain="['|','|',('name','ilike',self),('parent_id','ilike',self),('ref','=',self)]"/> ... other fields and filters ... </search> </xpath>
- Save the new View and try it.
You might find the documentation helpful.
In Default Sale order search view the below code used:-
<field name="partner_id" filter_domain="[('partner_id', 'child_of', self)]"/>
Based on your requirement inherit search view and add the domain:-
<field name="partner_id" domain="[('is_company','=',True)]" filter_domain="[('partner_id', 'child_of', self)]"/>
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 3/5/14, 8:17 AM|
|Seen: 1272 times|
|Last updated: 3/16/15, 8:10 AM|