Use full_address to construct the URL

issue5493
review25591002
This commit is contained in:
Cédric Krier committed 2016-09-06 09:22:08 +02:00
1 parent 70a40ece7b
commit aaaf169831
1 file changed
+4 -19
+4 -19
View File
@@ -17,27 +17,12 @@ class Address:
google_maps_url = fields.Function(fields.Char('Google Maps'),
'on_change_with_google_maps_url')
@fields.depends('street', 'streetbis', 'zip', 'city', 'country',
'subdivision')
@fields.depends('street', 'zip', 'city', 'country', 'subdivision')
def on_change_with_google_maps_url(self, name=None):
lang = Transaction().language[:2]
url = ''
for value in (
self.street,
self.streetbis,
self.zip,
self.city,
self.country.name if self.country else None,
self.subdivision.name if self.subdivision else None,
):
if value:
if isinstance(value, str) and sys.version_info < (3,):
url += ' ' + value.decode('utf-8')
else:
url += ' ' + value
url = url.strip()
if url:
if sys.version_info < (3,):
url = ''.join(self.full_address.splitlines())
if url.strip():
if isinstance(url, str) and sys.version_info < (3,):
url = url.encode('utf-8')
return 'http://maps.google.com/maps?hl=%s&q=%s' % \
(lang, urllib.quote(url))