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.
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
|Asked: 7/19/16, 5:17 AM|
|Seen: 251 times|
|Last updated: 7/20/16, 1:59 AM|