From aaaf169831a1f82cec4d19dade6a684e76b0a04b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 6 Sep 2016 09:22:08 +0200 Subject: [PATCH] Use full_address to construct the URL issue5493 review25591002 --- address.py | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/address.py b/address.py index a571782453..2f5dcc8e66 100644 --- a/address.py +++ b/address.py @@ -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))