Odoo Help

Welcome!

This community 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.

1

Add fields for autocomplete function in search view

By
Robert Klüsener
on 9/16/13, 10:35 AM 3,684 views

When I start typing in the search box of my contact list OpenERP suggests me companies that contain the letters I have already typed. How can add other fields like for e.g. city to this autocomplete functionality?

I already created the following inherited view

<?xml version="1.0"?>
<filter string="Country" position="after">
<filter string="City" context="{'group_by': 'city'}"/>
<field name="street" filter_domain="[('street','ilike',self)]"/>
<field name="zip" filter_domain="[('zip','ilike',self)]"/>
<field name="city" filter_domain="[('city','ilike',self)]"/>
<field name="comment" filter_domain="[('comment','ilike',self)]"/>
</filter>

This allows to search the fields street, zip, city and comment. But you have to select manually that you want to search in this field. It not automatically suggests you content from this fields. For example when I type in "Brux" I can selext to search for "Brux" in the city field but it does not suggest me "Bruxelles". If I would have a company in the database with the name "Bruxelles Best S.A." it would automatically suggest me this company.

image description

Here is an example. I type "Bru" in the search view and it suggest me two companies that contain "bru". I want the same suggestion for the city.

Feuerwear GmbH & Co. KG, Robert Klüsener
on 9/17/13, 7:23 AM

Note that it's not suggesting "Companies", it's suggesting "Related Companies" (parent_id many2one field). You would have the same effect for "City" if it were a many2one instead of a text box. You can confirm this by adding the "country_id" field to the Search View: since it's a many2one, it will show expanded descriptions.

Daniel Reis
on 9/17/13, 9:18 AM
1

Daniel Reis

--Daniel Reis--
3436
| 6 7 9
Lisbon, Portugal
--Daniel Reis--

Author of the "Odoo Development Essentials" book.

Applications Manager at Securitas Portugal

Github: https://github.com/dreispt

Twitter; @reis_pt


Daniel Reis
On 9/16/13, 1:05 PM

That's defined on the Search View. Activate de Developer Mode, go to Sales » Customers and then:

  • In the "Debug View combobox, select "Edit Search View". This will bring you a dialog window with the Search's XML structure.r
  • After <field name="name" ... add new line with: <field name="city"/>

Save, and that's it: you just made the "City" field searchable. Reload the Customers view and try it.

Thanks for the quick answer. I have already created an inherited view that allows to search the fields (see update of my question). This allows to search the fields street, zip, city and comment. But you have to select manually that you want to search in this field. It not automatically suggests you content from this fields. For example when I type in "Brux" I can selext to search for "Brux" in the city field but it does not suggest me "Bruxelles". If I would have a company in the database with the name "Bruxelles Best S.A." it would automatically suggest me this company.

Feuerwear GmbH & Co. KG, Robert Klüsener
on 9/17/13, 5:03 AM

I don't see the point for that behaviour in the search box. Maybe you mean the search feature on a form field, such as the "Customer" field on "Opportunity" form ? You want that to suggest results also based on other Customer fields?

Daniel Reis
on 9/17/13, 7:03 AM

I added a screenshoot to explain my point. Please see comment below.

Feuerwear GmbH & Co. KG, Robert Klüsener
on 9/17/13, 7:23 AM

Your Answer

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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 9/16/13, 10:35 AM
Seen: 3684 times
Last updated: 5/21/16, 1:53 PM