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.
I have a data xml file with a large number of zipcodes and city names that are correlated in the correct way.
I want to integrate a search into my contact form. When a user places his cursor in the field 'zipcode', a search box should appear and the user should be able to search for a zipcode of a city OR a city name itself (inside the same box). The reversed action should also be possible.
So when the user is typing names (in the field city or zipcode), the search dropdown should display the relevant data to his search. When the user places his cursor in the 'city' field. A search should be possible on zipcodes and city names. When the user selects the appropriate zipcode or city name (preferably displayed in the same line separated by a dash or so) the zipcode should be placed in the zipcode field and the city name in the city field.
How can I extend the default behavior of the search so that I can search through two columns and display the combined data in the search result box.
(PS: Yes I know, just split up the two searches... Not what I'm looking for though. PLIS NO HATE)
From what I understood, perhaps one solution would be to create a separate table with zip codes and city with the correlation between the two.
You could then try redefining the fields city and zip as many2one fields to that table, instead of the ordinary text fields that they are defined as by default.
To show a combination of city and zip code, you can override def name_get() function. You can see examples of this in hr_holidays module, where the leave type (holiday_status_id) is combined with number of days remaining.
After selection, you can try triggering an on_change, which will fetch the corresponding zip/city value and populate the other field.
Hope this approach helps.
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: 7/19/16, 5:17 AM|
|Seen: 528 times|
|Last updated: 7/20/16, 1:59 AM|