From 1673325de3d7000bb31db588a8fe86270ba92a17 Mon Sep 17 00:00:00 2001 From: Andreas Osim Date: Tue, 9 Apr 2019 11:03:11 +0200 Subject: [PATCH] simple version of google maps directions (take start point of users company) --- .../tz_routemaps/wizards/wizard_routemaps.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ext/custom-addons/tz_routemaps/wizards/wizard_routemaps.py b/ext/custom-addons/tz_routemaps/wizards/wizard_routemaps.py index a4474965..fbc54fcd 100644 --- a/ext/custom-addons/tz_routemaps/wizards/wizard_routemaps.py +++ b/ext/custom-addons/tz_routemaps/wizards/wizard_routemaps.py @@ -3,6 +3,7 @@ from odoo import api, fields, models, _ from odoo.exceptions import ValidationError +import urllib.parse class WizardRouteMaps(models.TransientModel): @@ -13,7 +14,9 @@ class WizardRouteMaps(models.TransientModel): @api.multi def button_routemaps(self): - home_address = r'Neugasse 36, 2244 Spannberg' +# home_address = r'Neugasse 36, 2244 Spannberg' + myCompany=self.env.user.company_id + home_address = urllib.parse.quote(myCompany.street,safe='')+","+myCompany.zip+","+myCompany.city+","+myCompany.country_id.name for wizard in self: active_ids = self.env.context.get('active_ids', []) sale_orders = self.env['sale.order'].browse(active_ids) @@ -23,9 +26,10 @@ 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 += "/"+so.partner_shipping_id.street+","+so.partner_shipping_id.zip+","+so.partner_shipping_id.city+","+so.partner_shipping_id.country_id.name + 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 gomaps_link = "https://www.google.at/maps/dir/"+home_address+address + print(gomaps_link) # action = self.env.ref('sale.action_orders').read()[0] # action['domain'] = [('id', 'in', active_ids)] # return action