Odoo Help


1 Answer

Mohammed Amal

--Mohammed Amal--

| 6 3 9
Malappuram, India
--Mohammed Amal--

Email : mohammedamal.n@gmail.com

Blog: https://www.blogger.com/profile/14877879550922602186

Mohammed Amal
18.07.17, 06:56


If you want to convert address to lat and long, try geopy python package. you can refer this link - geopy 

If you want to go to a link using google map you can use this format http://maps.google.com/maps?q=47.1922423,8.523348

Edit (do ignore the previous lines and the comments):

You can change the original code like this:


def google_map_link(self, zoom=10):

# params = {
# 'q': '%s, %s %s, %s' % (self.street or '', self.city or '', self.zip or '', self.country_id and self.country_id.name_get()[0][1] or ''),
# 'z': zoom,
# }

params = {
'q': '%s' % ('47.1922423,8.5496122'),
'z': zoom,
return urlplus('https://maps.google.com/maps', params)

Then you can create a new module inheriting res.partner.

If you want to use the existing fields (from the module base_geolocalize), do it like this:


def google_map_link(self, zoom=10):

        params = {
         'q': '%s,%s' % (self.partner_longitude,self.partner_latitude),
         'z': zoom,


def google_map_img(self, zoom=8, width=298, height=298):

google_maps_api_key = self.env['ir.config_parameter'].sudo().get_param('google_maps_api_key')
if not google_maps_api_key:
return False
params = {
'center': '%s,%s' % (self.partner_longitude,self.partner_latitude),
 'size': "%sx%s" % (height, width),
'zoom': zoom,
'sensor': 'false',
'key': google_maps_api_key,
return urlplus('//maps.googleapis.com/maps/api/staticmap', params)

Ermin Trevisan
18.07.17, 08:00

Thanks for your answer, but I already understand that, as you can read from my explanation. My point is: how can I change the Odoo code of the "Contact Us" page accordingly.

Mohammed Amal
18.07.17, 13:46

I'm not sure if you are looking for this.

The google map button is defined in the template with id company_description. You can inherit and replace the current button with your button

Ermin Trevisan
18.07.17, 15:04

Thank you very much for your continuing efforts. I'm not a developer, therefore it is very difficult for me to understand the basics behind it. While finding this link: https://stackoverflow.com/questions/34415906/how-do-i-add-a-google-maps-link-in-odoo I understand that I have to change the method of composing the rendered URL for the Google Map in addons/website/models/website.py and now it gets a little bit complicated for a simple minded heart as I am :-)

Ask a Question
Keep Informed
1 follower(s)
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.