-
-
Notifications
You must be signed in to change notification settings - Fork 815
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #505 from Tecnativa/11.0-partner_external_map
[11.0] [MIG] partner_external_map: Migration to 11.0
- Loading branch information
Showing
85 changed files
with
17,194 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
===================== | ||
Partner External Maps | ||
===================== | ||
|
||
In the old days of Odoo/OpenERP, back in version 6.1, there was an official | ||
*google_map* module ; this module added a *Map* button on the partner form view | ||
and, when the user clicked on that button, it would open a new tab on its web | ||
browser and go to Google Map with a search on the address of the partner. | ||
|
||
This module aims at restoring this feature with several improvements: | ||
|
||
* Each user can select the map website he wants to use in its preferences | ||
* There are now two buttons on the partner form view: one to open a regular map | ||
on the address of the partner, and another one to open an itinerary map from | ||
the start address configured in the preferences of the user to the address of | ||
the partner. | ||
|
||
This module supports several map websites: | ||
|
||
* `Google Maps <https://www.google.com/maps>` | ||
* `OpenStreetMap <https://www.openstreetmap.org/>` | ||
* `Bing Maps <https://www.bing.com/maps/>` | ||
* `Here Maps <https://www.here.com/>` | ||
* `MapQuest <http://www.mapquest.com/>` | ||
|
||
If the module *base_geolocalize* from the official addons is installed on the | ||
system, it will use the latitude and longitude to localize the partner (instead | ||
of the address) if this information is present on the partner. | ||
|
||
Configuration | ||
============= | ||
|
||
If you want to create additional map websites, go to the menu | ||
*Settings > Technical > Map Websites > Map Websites*. You are | ||
invited to send the configuration information of your additional map websites | ||
to one of the authors of the module, so that the module can be updated with | ||
more pre-configured map websites. | ||
|
||
Usage | ||
===== | ||
|
||
First, you need to configure in your preferences: | ||
|
||
* The map website to use for the regular maps, | ||
* The map website to use for the route maps, | ||
* The start address for the route maps. | ||
|
||
Then you can use the two new buttons on the partner form to open a regular map | ||
or a route map. | ||
|
||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
:alt: Try me on Runbot | ||
:target: https://runbot.odoo-community.org/runbot/134/11.0 | ||
|
||
Known issues / Roadmap | ||
====================== | ||
|
||
* Let decide if the user prefers to use addresses instead coordinates when | ||
*base_geolocalize* is installed. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/OCA/partner-contact/issues>`_. In case of trouble, please | ||
check there if your issue has already been reported. If you spotted it first, | ||
help us smashing it by providing a detailed and welcomed feedback. | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
|
||
* Akretion (http://www.akretion.com): | ||
* Alexis de Lattre <alexis.delattre@akretion.com> | ||
* Tecnativa (https://www.tecnativa.com): | ||
* Pedro M. Baeza <pedro.baeza@tecnativa.com> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
To contribute to this module, please visit https://odoo-community.org. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import models | ||
from .hooks import set_default_map_settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2015-2016 Akretion - Alexis de Lattre | ||
# Copyright 2016-2017 Tecnativa - Pedro M. Baeza | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
'name': 'Partner External Maps', | ||
'version': '11.0.1.0.0', | ||
'category': 'Extra Tools', | ||
'license': 'AGPL-3', | ||
'summary': 'Add Map and Map Routing buttons on partner form to ' | ||
'open GMaps, OSM, Bing and others', | ||
'author': 'Akretion, ' | ||
'Tecnativa, ' | ||
'Odoo Community Association (OCA)', | ||
'website': 'https://github.com/OCA/partner-contact', | ||
'depends': [ | ||
'base', | ||
], | ||
'data': [ | ||
'views/res_partner_view.xml', | ||
'views/map_website_view.xml', | ||
'data/map_website_data.xml', | ||
'views/res_users_view.xml', | ||
'security/ir.model.access.csv', | ||
], | ||
'post_init_hook': 'set_default_map_settings', | ||
'installable': True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- © 2015-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>) | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3). --> | ||
|
||
<odoo> | ||
|
||
<!-- Interesting source of information: http://northwestspatial.com/wp/?p=38 --> | ||
<record id="google_maps" model="map.website"> | ||
<field name="name">Google Maps</field> | ||
<field name="address_url">https://www.google.com/maps?ie=UTF8&q={ADDRESS}</field> | ||
<field name="lat_lon_url">https://www.google.com/maps?z=15&q={LATITUDE},{LONGITUDE}</field> | ||
<field name="route_address_url">https://www.google.com/maps?saddr={START_ADDRESS}&daddr={DEST_ADDRESS}&directionsmode=driving</field> | ||
<field name="route_lat_lon_url">https://www.google.com/maps?saddr={START_LATITUDE},{START_LONGITUDE}&daddr={DEST_LATITUDE},{DEST_LONGITUDE}&directionsmode=driving</field> | ||
</record> | ||
|
||
<record id="openstreetmap" model="map.website"> | ||
<field name="name">OpenStreetMap</field> | ||
<field name="address_url">https://nominatim.openstreetmap.org/search?q={ADDRESS}</field> | ||
<field name="lat_lon_url">https://www.openstreetmap.org/?zoom=15&mlat={LATITUDE}&mlon={LONGITUDE}</field> | ||
<field name="route_lat_lon_url">https://www.openstreetmap.org/directions/?engine=orsm_car&route={START_LATITUDE},{START_LONGITUDE};{DEST_LATITUDE},{DEST_LONGITUDE}</field> | ||
</record> | ||
|
||
<record id="openstreetmap_fr" model="map.website"> | ||
<field name="name">OpenStreetMap FR</field> | ||
<field name="address_url">http://tile.openstreetmap.fr/?q={ADDRESS}</field> | ||
<field name="lat_lon_url">http://tile.openstreetmap.fr/?zoom=15&lat={LATITUDE}&lon={LONGITUDE}</field> | ||
</record> | ||
|
||
<record id="bing_maps" model="map.website"> | ||
<field name="name">Bing Maps</field> | ||
<field name="address_url">https://www.bing.com/maps/default.aspx?where1={ADDRESS}</field> | ||
<field name="lat_lon_url">https://www.bing.com/maps/default.aspx?where1={LATITUDE},{LONGITUDE}&lvl=15</field> | ||
</record> | ||
|
||
<record id="here" model="map.website"> | ||
<field name="name">Here Maps</field> | ||
<field name="address_url">https://here.com/search/{ADDRESS}</field> | ||
<field name="lat_lon_url">https://www.here.com/?map={LATITUDE},{LONGITUDE},15,normal</field> | ||
<!-- TODO : for here maps, try to find a lat_lon_url with dot --> | ||
<field name="route_lat_lon_url">https://www.here.com/directions/drive/:{START_LATITUDE},{START_LONGITUDE}/:{DEST_LATITUDE},{DEST_LONGITUDE}</field> | ||
</record> | ||
|
||
<record id="mapquest" model="map.website"> | ||
<field name="name">MapQuest</field> | ||
<field name="address_url">https://www.mapquest.com/?center={ADDRESS}</field> | ||
<field name="lat_lon_url">https://www.mapquest.com/?center={LATITUDE},{LONGITUDE}</field> | ||
<field name="route_address_url">https://www.mapquest.com/directions?q1={START_ADDRESS}&q2={DEST_ADDRESS}</field> | ||
<field name="route_lat_lon_url">https://www.mapquest.com/directions/from/near-{START_LATITUDE},{START_LONGITUDE}/to/near-{DEST_LATITUDE},{DEST_LONGITUDE}</field> | ||
</record> | ||
|
||
<!-- On June 4, 2015, Yahoo! announced that Yahoo! Maps would be shut down | ||
https://www.cnet.com/news/yahoo-to-shut-down-its-maps-site/ | ||
--> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2015 Alexis de Lattre <alexis.delattre@akretion.com> | ||
# © 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, SUPERUSER_ID | ||
import logging | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def set_default_map_settings(cr, registry): | ||
"""Method called as post-install script | ||
The default method on the field can't be used, because it would be executed | ||
before loading map_website_data.xml, so it would not be able to set a | ||
value""" | ||
with api.Environment.manage(): | ||
env = api.Environment(cr, SUPERUSER_ID, {}) | ||
user_model = env['res.users'] | ||
users = user_model.search([('context_map_website_id', '=', False)]) | ||
logger.info('Updating user settings for maps...') | ||
users.write({ | ||
'context_map_website_id': user_model._default_map_website().id, | ||
'context_route_map_website_id': ( | ||
user_model._default_route_map_website().id), | ||
}) | ||
# Update the starting partner this way that is faster | ||
cr.execute(""" | ||
UPDATE res_users | ||
SET context_route_start_partner_id = partner_id | ||
WHERE context_route_start_partner_id IS NULL; | ||
""") |
Oops, something went wrong.