From c5a932ebe7a37e10bdf942b0a04c44f501e50363 Mon Sep 17 00:00:00 2001 From: Andreas Osim Date: Wed, 10 Apr 2019 10:39:24 +0200 Subject: [PATCH] simple version of google maps directions (take start point of users company); take empty addresses into account --- ext/custom-addons/dp_custom/views/sale_views.xml | 1 + .../tz_routemaps/wizards/wizard_routemaps.py | 13 ++++++++++--- .../tz_routemaps/wizards/wizard_routemaps.xml | 3 ++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ext/custom-addons/dp_custom/views/sale_views.xml b/ext/custom-addons/dp_custom/views/sale_views.xml index acf45d62..77e7b577 100644 --- a/ext/custom-addons/dp_custom/views/sale_views.xml +++ b/ext/custom-addons/dp_custom/views/sale_views.xml @@ -234,6 +234,7 @@ + diff --git a/ext/custom-addons/tz_routemaps/wizards/wizard_routemaps.py b/ext/custom-addons/tz_routemaps/wizards/wizard_routemaps.py index eb166757..725d8f08 100644 --- a/ext/custom-addons/tz_routemaps/wizards/wizard_routemaps.py +++ b/ext/custom-addons/tz_routemaps/wizards/wizard_routemaps.py @@ -2,7 +2,6 @@ # License OPL-1 or later (https://www.odoo.com/documentation/user/11.0/legal/licenses/licenses.html#licenses). from odoo import api, fields, models, _ -from odoo.exceptions import ValidationError import urllib.parse @@ -26,7 +25,14 @@ class WizardRouteMaps(models.TransientModel): for so in sale_orders: if (so.partner_shipping_id.id not in sid): sid.add(so.partner_shipping_id.id) - address += "/"+urllib.parse.quote(so.partner_shipping_id.street,safe='')+","+so.partner_shipping_id.zip+","+so.partner_shipping_id.city+","+so.partner_shipping_id.country_id.name + si = so.partner_shipping_id + + street = si.street + ',' if si.street else '' + zip = ' ' + si.zip + ',' if si.zip else '' + city = ' ' + si.city + ',' if si.city else '' + country_code = ' ' + si.country_id.code + ',' if si.country_id.code else '' + + address += "/"+urllib.parse.quote(street,safe='') + zip + urllib.parse.quote(city,safe='') + country_code gomaps_link = "https://www.google.at/maps/dir/"+home_address+address # print(gomaps_link) @@ -36,5 +42,6 @@ class WizardRouteMaps(models.TransientModel): return { 'type': 'ir.actions.act_url', 'url': '%s' % gomaps_link, - 'view_mode':'form' + 'target':'new', +# 'domain': [('id', 'in', active_ids)], } diff --git a/ext/custom-addons/tz_routemaps/wizards/wizard_routemaps.xml b/ext/custom-addons/tz_routemaps/wizards/wizard_routemaps.xml index aed5fad8..51fdb732 100644 --- a/ext/custom-addons/tz_routemaps/wizards/wizard_routemaps.xml +++ b/ext/custom-addons/tz_routemaps/wizards/wizard_routemaps.xml @@ -19,7 +19,8 @@ type="object"/>