Browse Source

[IMP] partner_external_map: black, isort, prettier

14.0
João Marques 4 years ago
committed by Alexis de Lattre
parent
commit
d2e8358975
  1. 1
      partner_external_map/__init__.py
  2. 38
      partner_external_map/__manifest__.py
  3. 119
      partner_external_map/data/map_website_data.xml
  4. 27
      partner_external_map/hooks.py
  5. 1
      partner_external_map/models/__init__.py
  6. 28
      partner_external_map/models/map_website.py
  7. 114
      partner_external_map/models/res_partner.py
  8. 48
      partner_external_map/models/res_users.py
  9. 1
      partner_external_map/tests/__init__.py
  10. 88
      partner_external_map/tests/test_partner_external_map.py
  11. 85
      partner_external_map/views/map_website_view.xml
  12. 49
      partner_external_map/views/res_partner_view.xml
  13. 62
      partner_external_map/views/res_users_view.xml

1
partner_external_map/__init__.py

@ -1,3 +1,2 @@
from . import models
from .hooks import set_default_map_settings

38
partner_external_map/__manifest__.py

@ -4,26 +4,22 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Partner External Maps',
'version': '12.0.1.0.1',
'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',
"name": "Partner External Maps",
"version": "12.0.1.0.1",
"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",
],
'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,
"post_init_hook": "set_default_map_settings",
"installable": True,
}

119
partner_external_map/data/map_website_data.xml

@ -1,55 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 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&amp;q={ADDRESS}</field>
<field name="lat_lon_url">https://www.google.com/maps?z=15&amp;q={LATITUDE},{LONGITUDE}</field>
<field name="route_address_url">https://www.google.com/maps?saddr={START_ADDRESS}&amp;daddr={DEST_ADDRESS}&amp;directionsmode=driving</field>
<field name="route_lat_lon_url">https://www.google.com/maps?saddr={START_LATITUDE},{START_LONGITUDE}&amp;daddr={DEST_LATITUDE},{DEST_LONGITUDE}&amp;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&amp;mlat={LATITUDE}&amp;mlon={LONGITUDE}</field>
<field name="route_lat_lon_url">https://www.openstreetmap.org/directions/?engine=orsm_car&amp;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&amp;lat={LATITUDE}&amp;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}&amp;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}&amp;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
<!-- 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&amp;q={ADDRESS}</field>
<field
name="lat_lon_url"
>https://www.google.com/maps?z=15&amp;q={LATITUDE},{LONGITUDE}</field>
<field
name="route_address_url"
>https://www.google.com/maps?saddr={START_ADDRESS}&amp;daddr={DEST_ADDRESS}&amp;directionsmode=driving</field>
<field
name="route_lat_lon_url"
>https://www.google.com/maps?saddr={START_LATITUDE},{START_LONGITUDE}&amp;daddr={DEST_LATITUDE},{DEST_LONGITUDE}&amp;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&amp;mlat={LATITUDE}&amp;mlon={LONGITUDE}</field>
<field
name="route_lat_lon_url"
>https://www.openstreetmap.org/directions/?engine=orsm_car&amp;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&amp;lat={LATITUDE}&amp;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}&amp;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}&amp;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>

27
partner_external_map/hooks.py

@ -2,9 +2,9 @@
# Copyright 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
from odoo import SUPERUSER_ID, api
logger = logging.getLogger(__name__)
@ -16,17 +16,22 @@ def set_default_map_settings(cr, registry):
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),
})
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("""
cr.execute(
"""
UPDATE res_users
SET context_route_start_partner_id = partner_id
WHERE context_route_start_partner_id IS NULL;
""")
"""
)

1
partner_external_map/models/__init__.py

@ -1,4 +1,3 @@
from . import map_website
from . import res_partner
from . import res_users

28
partner_external_map/models/map_website.py

@ -3,28 +3,32 @@
# Copyright 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields
from odoo import fields, models
class MapWebsite(models.Model):
_name = 'map.website'
_description = 'Map Website'
_name = "map.website"
_description = "Map Website"
name = fields.Char(string='Map Website Name', required=True)
name = fields.Char(string="Map Website Name", required=True)
address_url = fields.Char(
string='URL that uses the address',
help="In this URL, {ADDRESS} will be replaced by the address.")
string="URL that uses the address",
help="In this URL, {ADDRESS} will be replaced by the address.",
)
lat_lon_url = fields.Char(
string='URL that uses latitude and longitude',
string="URL that uses latitude and longitude",
help="In this URL, {LATITUDE} and {LONGITUDE} will be replaced by "
"the latitude and longitude (requires the module 'base_geolocalize')")
"the latitude and longitude (requires the module 'base_geolocalize')",
)
route_address_url = fields.Char(
string='Route URL that uses the addresses',
string="Route URL that uses the addresses",
help="In this URL, {START_ADDRESS} and {DEST_ADDRESS} will be "
"replaced by the start and destination addresses.")
"replaced by the start and destination addresses.",
)
route_lat_lon_url = fields.Char(
string='Route URL that uses latitude and longitude',
string="Route URL that uses latitude and longitude",
help="In this URL, {START_LATITUDE}, {START_LONGITUDE}, "
"{DEST_LATITUDE} and {DEST_LONGITUDE} will be replaced by the "
"latitude and longitude of the start and destination adresses "
"(requires the module 'base_geolocalize').")
"(requires the module 'base_geolocalize').",
)

114
partner_external_map/models/res_partner.py

@ -3,16 +3,16 @@
# Copyright 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, api, _
from odoo.exceptions import UserError
import logging
from odoo import _, api, models
from odoo.exceptions import UserError
logger = logging.getLogger(__name__)
class ResPartner(models.Model):
_inherit = 'res.partner'
_inherit = "res.partner"
@api.multi
def _address_as_string(self):
@ -30,17 +30,17 @@ class ResPartner(models.Model):
addr.append(self.country_id.name)
if not addr:
raise UserError(_("Address missing on partner '%s'.") % self.name)
return ' '.join(addr)
return " ".join(addr)
@api.model
def _prepare_url(self, url, replace):
assert url, 'Missing URL'
assert url, "Missing URL"
for key, value in replace.items():
if not isinstance(value, str):
# for latitude and longitude which are floats
value = str(value)
url = url.replace(key, value)
logger.debug('Final URL: %s', url)
logger.debug("Final URL: %s", url)
return url
@api.multi
@ -49,26 +49,37 @@ class ResPartner(models.Model):
map_website = self.env.user.context_map_website_id
if not map_website:
raise UserError(
_('Missing map provider: '
'you should set it in your preferences.'))
if (map_website.lat_lon_url and hasattr(self, 'partner_latitude') and
self.partner_latitude and self.partner_longitude):
_("Missing map provider: " "you should set it in your preferences.")
)
if (
map_website.lat_lon_url
and hasattr(self, "partner_latitude")
and self.partner_latitude
and self.partner_longitude
):
url = self._prepare_url(
map_website.lat_lon_url, {
'{LATITUDE}': self.partner_latitude,
'{LONGITUDE}': self.partner_longitude})
map_website.lat_lon_url,
{
"{LATITUDE}": self.partner_latitude,
"{LONGITUDE}": self.partner_longitude,
},
)
else:
if not map_website.address_url:
raise UserError(
_("Missing parameter 'URL that uses the address' "
"for map website '%s'.") % map_website.name)
_(
"Missing parameter 'URL that uses the address' "
"for map website '%s'."
)
% map_website.name
)
url = self._prepare_url(
map_website.address_url,
{'{ADDRESS}': self._address_as_string()})
map_website.address_url, {"{ADDRESS}": self._address_as_string()}
)
return {
'type': 'ir.actions.act_url',
'url': url,
'target': 'new',
"type": "ir.actions.act_url",
"url": url,
"target": "new",
}
@api.multi
@ -76,36 +87,55 @@ class ResPartner(models.Model):
self.ensure_one()
if not self.env.user.context_route_map_website_id:
raise UserError(
_('Missing route map website: '
'you should set it in your preferences.'))
_(
"Missing route map website: "
"you should set it in your preferences."
)
)
map_website = self.env.user.context_route_map_website_id
if not self.env.user.context_route_start_partner_id:
raise UserError(
_('Missing start address for route map: '
'you should set it in your preferences.'))
_(
"Missing start address for route map: "
"you should set it in your preferences."
)
)
start_partner = self.env.user.context_route_start_partner_id
if (map_website.route_lat_lon_url and
hasattr(self, 'partner_latitude') and
self.partner_latitude and self.partner_longitude and
start_partner.partner_latitude and
start_partner.partner_longitude):
if (
map_website.route_lat_lon_url
and hasattr(self, "partner_latitude")
and self.partner_latitude
and self.partner_longitude
and start_partner.partner_latitude
and start_partner.partner_longitude
):
url = self._prepare_url( # pragma: no cover
map_website.route_lat_lon_url, {
'{START_LATITUDE}': start_partner.partner_latitude,
'{START_LONGITUDE}': start_partner.partner_longitude,
'{DEST_LATITUDE}': self.partner_latitude,
'{DEST_LONGITUDE}': self.partner_longitude})
map_website.route_lat_lon_url,
{
"{START_LATITUDE}": start_partner.partner_latitude,
"{START_LONGITUDE}": start_partner.partner_longitude,
"{DEST_LATITUDE}": self.partner_latitude,
"{DEST_LONGITUDE}": self.partner_longitude,
},
)
else:
if not map_website.route_address_url:
raise UserError(
_("Missing route URL that uses the addresses "
"for the map website '%s'") % map_website.name)
_(
"Missing route URL that uses the addresses "
"for the map website '%s'"
)
% map_website.name
)
url = self._prepare_url(
map_website.route_address_url, {
'{START_ADDRESS}': start_partner._address_as_string(),
'{DEST_ADDRESS}': self._address_as_string()})
map_website.route_address_url,
{
"{START_ADDRESS}": start_partner._address_as_string(),
"{DEST_ADDRESS}": self._address_as_string(),
},
)
return {
'type': 'ir.actions.act_url',
'url': url,
'target': 'new',
"type": "ir.actions.act_url",
"url": url,
"target": "new",
}

48
partner_external_map/models/res_users.py

@ -3,43 +3,57 @@
# Copyright 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields, api
import logging
from odoo import api, fields, models
logger = logging.getLogger(__name__)
class ResUsers(models.Model):
_inherit = 'res.users'
_inherit = "res.users"
@api.model
def _default_map_website(self):
return self.env['map.website'].search([
'|', ('address_url', '!=', False), ('lat_lon_url', '!=', False)],
limit=1)
return self.env["map.website"].search(
["|", ("address_url", "!=", False), ("lat_lon_url", "!=", False)], limit=1
)
@api.model
def _default_route_map_website(self):
return self.env['map.website'].search([
'|', ('route_address_url', '!=', False),
('route_lat_lon_url', '!=', False)], limit=1)
return self.env["map.website"].search(
[
"|",
("route_address_url", "!=", False),
("route_lat_lon_url", "!=", False),
],
limit=1,
)
# begin with context_ to allow user to change it by himself
context_map_website_id = fields.Many2one(
'map.website', string='Map Website', default=_default_map_website,
domain=['|', ('address_url', '!=', False),
('lat_lon_url', '!=', False)])
"map.website",
string="Map Website",
default=_default_map_website,
domain=["|", ("address_url", "!=", False), ("lat_lon_url", "!=", False)],
)
# We want to give the possibility to the user to have one map provider for
# regular maps and another one for routing
context_route_map_website_id = fields.Many2one(
'map.website', string='Route Map Website',
domain=['|', ('route_address_url', '!=', False),
('route_lat_lon_url', '!=', False)],
"map.website",
string="Route Map Website",
domain=[
"|",
("route_address_url", "!=", False),
("route_lat_lon_url", "!=", False),
],
default=_default_route_map_website,
help="Map provided used when you click on the car icon on the partner "
"form to display an itinerary.")
"form to display an itinerary.",
)
context_route_start_partner_id = fields.Many2one(
'res.partner', string='Start Address for Route Map')
"res.partner", string="Start Address for Route Map"
)
@api.model
def create(self, vals):
@ -47,6 +61,6 @@ class ResUsers(models.Model):
created one.
"""
user = super(ResUsers, self).create(vals)
if not vals.get('context_route_start_partner_id'):
if not vals.get("context_route_start_partner_id"):
user.context_route_start_partner_id = user.partner_id.id
return user

1
partner_external_map/tests/__init__.py

@ -1,2 +1 @@
from . import test_partner_external_map

88
partner_external_map/tests/test_partner_external_map.py

@ -1,57 +1,66 @@
# Copyright 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.tests import common
from odoo.exceptions import UserError
from odoo.tests import common
from ..hooks import set_default_map_settings
class TestPartnerExternalMap(common.TransactionCase):
def setUp(self):
super(TestPartnerExternalMap, self).setUp()
self.user = self.env['res.users'].create({
'name': 'Test user',
'login': 'test_login',
'context_map_website_id': self.ref(
'partner_external_map.google_maps'),
'context_route_map_website_id': self.ref(
'partner_external_map.google_maps'),
})
self.user.partner_id.city = 'Tomelloso'
self.partner = self.env['res.partner'].create({
'name': 'Test partner',
'city': 'Madrid',
'street': 'street_test',
'street2': 'street2_test',
'state_id': self.ref('base.state_es_m'),
'country_id': self.ref('base.es'),
})
self.user = self.env["res.users"].create(
{
"name": "Test user",
"login": "test_login",
"context_map_website_id": self.ref("partner_external_map.google_maps"),
"context_route_map_website_id": self.ref(
"partner_external_map.google_maps"
),
}
)
self.user.partner_id.city = "Tomelloso"
self.partner = self.env["res.partner"].create(
{
"name": "Test partner",
"city": "Madrid",
"street": "street_test",
"street2": "street2_test",
"state_id": self.ref("base.state_es_m"),
"country_id": self.ref("base.es"),
}
)
def test_post_init_hook(self):
# Call this again for coverage purposes, but it has been already run
set_default_map_settings(self.cr, self.registry)
usrs = self.env['res.users'].search([])
usrs = self.env["res.users"].search([])
self.assertTrue(all([u.context_map_website_id.id for u in usrs]))
self.assertTrue(all([u.context_route_map_website_id.id for u in usrs]))
self.assertEqual(self.env.user.partner_id,
self.env.user.context_route_start_partner_id)
self.assertEqual(
self.env.user.partner_id, self.env.user.context_route_start_partner_id
)
def test_create_user(self):
self.assertEqual(
self.user.partner_id, self.user.context_route_start_partner_id)
self.assertEqual(self.user.partner_id, self.user.context_route_start_partner_id)
def test_open_map(self):
action = self.partner.sudo(self.user.id).open_map()
self.assertEqual(
action['url'], "https://www.google.com/maps?ie=UTF8"
"&q=street_test street2_test Madrid Madrid Spain")
action["url"],
"https://www.google.com/maps?ie=UTF8"
"&q=street_test street2_test Madrid Madrid Spain",
)
def test_open_route_map(self):
action = self.partner.sudo(self.user.id).open_route_map()
self.assertEqual(
action['url'], "https://www.google.com/maps?saddr=Tomelloso"
"&daddr=street_test street2_test Madrid Madrid "
"Spain&directionsmode=driving")
action["url"],
"https://www.google.com/maps?saddr=Tomelloso"
"&daddr=street_test street2_test Madrid Madrid "
"Spain&directionsmode=driving",
)
def test_open_map_with_coordinates(self):
# Simulate that we have the base_geolocalize module installed creating
@ -60,19 +69,20 @@ class TestPartnerExternalMap(common.TransactionCase):
partner.partner_latitude = 39.15837
partner.partner_longitude = -3.02145
action = partner.open_map()
self.assertTrue(
action["url"].startswith("https://www.google.com/maps?z="))
self.assertIn("39.15837", action['url'])
self.assertIn("-3.02145", action['url'])
self.assertTrue(action["url"].startswith("https://www.google.com/maps?z="))
self.assertIn("39.15837", action["url"])
self.assertIn("-3.02145", action["url"])
def test_exception_no_addr(self):
self.partner.write({
'city': False,
'street': False,
'street2': False,
'state_id': False,
'country_id': False,
})
self.partner.write(
{
"city": False,
"street": False,
"street2": False,
"state_id": False,
"country_id": False,
}
)
with self.assertRaises(UserError):
self.partner.sudo(self.user.id).open_route_map()

85
partner_external_map/views/map_website_view.xml

@ -1,51 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2015-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="map_website_form" model="ir.ui.view">
<field name="name">map.website.form</field>
<field name="model">map.website</field>
<field name="arch" type="xml">
<form string="Map Website">
<group name="main">
<field name="name"/>
<field name="address_url"/>
<field name="lat_lon_url"/>
<field name="route_address_url"/>
<field name="route_lat_lon_url"/>
</group>
</form>
</field>
</record>
<record id="map_website_tree" model="ir.ui.view">
<field name="name">map.website.tree</field>
<field name="model">map.website</field>
<field name="arch" type="xml">
<tree string="Map Websites">
<field name="name"/>
<field name="address_url"/>
</tree>
</field>
</record>
<record id="map_website_action" model="ir.actions.act_window">
<field name="name">Map Websites</field>
<field name="res_model">map.website</field>
<field name="view_mode">tree,form</field>
</record>
<!-- Menu entry under Settings > Technical
<record id="map_website_form" model="ir.ui.view">
<field name="name">map.website.form</field>
<field name="model">map.website</field>
<field name="arch" type="xml">
<form string="Map Website">
<group name="main">
<field name="name" />
<field name="address_url" />
<field name="lat_lon_url" />
<field name="route_address_url" />
<field name="route_lat_lon_url" />
</group>
</form>
</field>
</record>
<record id="map_website_tree" model="ir.ui.view">
<field name="name">map.website.tree</field>
<field name="model">map.website</field>
<field name="arch" type="xml">
<tree string="Map Websites">
<field name="name" />
<field name="address_url" />
</tree>
</field>
</record>
<record id="map_website_action" model="ir.actions.act_window">
<field name="name">Map Websites</field>
<field name="res_model">map.website</field>
<field name="view_mode">tree,form</field>
</record>
<!-- Menu entry under Settings > Technical
We prefered the menu entry of previous Odoo versions under
Sales > Config > Address Book > Localization, but in v10 that
would required a dependency on sales_team, and we don't want that -->
<menuitem id="root_map_website_menu" name="Map Websites" parent="base.menu_custom" sequence="100"/>
<menuitem id="map_website_menu" action="map_website_action"
parent="root_map_website_menu"/>
<menuitem
id="root_map_website_menu"
name="Map Websites"
parent="base.menu_custom"
sequence="100"
/>
<menuitem
id="map_website_menu"
action="map_website_action"
parent="root_map_website_menu"
/>
</odoo>

49
partner_external_map/views/res_partner_view.xml

@ -1,28 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2015-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<!-- Inherit partner view to add 'Map' and 'Route Map' buttons -->
<record id="view_partner_form" model="ir.ui.view">
<field name="name">map.button.res.partner.form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='button_box']" position="inside">
<button class="oe_inline oe_stat_button"
name="open_map" type="object" string="Map"
attrs="{'invisible': [('city', '=', False)]}"
icon="fa-map-marker"/>
<button class="oe_inline oe_stat_button"
name="open_route_map" type="object" string="Route Map"
attrs="{'invisible': [('city', '=', False)]}"
icon="fa-car"/>
</xpath>
</field>
</record>
<!-- Inherit partner view to add 'Map' and 'Route Map' buttons -->
<record id="view_partner_form" model="ir.ui.view">
<field name="name">map.button.res.partner.form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<xpath expr="//div[@name='button_box']" position="inside">
<button
class="oe_inline oe_stat_button"
name="open_map"
type="object"
string="Map"
attrs="{'invisible': [('city', '=', False)]}"
icon="fa-map-marker"
/>
<button
class="oe_inline oe_stat_button"
name="open_route_map"
type="object"
string="Route Map"
attrs="{'invisible': [('city', '=', False)]}"
icon="fa-car"
/>
</xpath>
</field>
</record>
</odoo>

62
partner_external_map/views/res_users_view.xml

@ -1,39 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2015-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="view_users_form" model="ir.ui.view">
<field name="name">map.res.users.form</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form"/>
<field name="arch" type="xml">
<group name="messaging" position="after">
<group name="maps" string="Maps">
<field name="context_map_website_id" widget="selection"/>
<field name="context_route_map_website_id" widget="selection"/>
<field name="context_route_start_partner_id"/>
<record id="view_users_form" model="ir.ui.view">
<field name="name">map.res.users.form</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form" />
<field name="arch" type="xml">
<group name="messaging" position="after">
<group name="maps" string="Maps">
<field name="context_map_website_id" widget="selection" />
<field name="context_route_map_website_id" widget="selection" />
<field name="context_route_start_partner_id" />
</group>
</group>
</group>
</field>
</record>
<record id="view_users_form_simple_modif" model="ir.ui.view">
<field name="name">map.preferences.res.users.form</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form_simple_modif"/>
<field name="arch" type="xml">
<group name="preferences" position="inside">
<field name="context_map_website_id"
readonly="0" widget="selection"/>
<field name="context_route_map_website_id"
readonly="0" widget="selection"/>
<field name="context_route_start_partner_id" readonly="0"/>
</group>
</field>
</record>
</field>
</record>
<record id="view_users_form_simple_modif" model="ir.ui.view">
<field name="name">map.preferences.res.users.form</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form_simple_modif" />
<field name="arch" type="xml">
<group name="preferences" position="inside">
<field name="context_map_website_id" readonly="0" widget="selection" />
<field
name="context_route_map_website_id"
readonly="0"
widget="selection"
/>
<field name="context_route_start_partner_id" readonly="0" />
</group>
</field>
</record>
</odoo>
Loading…
Cancel
Save