Skip to content
Browse files

[IMP] base_geolocalize,web_editor,doc: create map_view

In order for the map view to work properly:
- I moved scss property to a  file only scoped to website module.
- moved the definiton of "partner_latitude" and "partner_longitude" from
base_geolocalise to base/res.partner
  • Loading branch information...
Thomas Werland authored and VincentSchippefilt committed May 6, 2019
1 parent b9ec983 commit 50e4931174c76dfa043858cde83291eb1ab8f0c8
@@ -4,8 +4,6 @@
class ResPartner(models.Model):
_inherit = "res.partner"

partner_latitude = fields.Float(string='Geo Latitude', digits=(16, 5))
partner_longitude = fields.Float(string='Geo Longitude', digits=(16, 5))
date_localization = fields.Date(string='Geolocation Date')

@@ -165,11 +165,8 @@ html[data-browser^="msie"] div.media_iframe_video iframe {
margin-left: 0;

@include media-breakpoint-down(sm) {
img, .media_iframe_video, span.fa, i.fa {
transform: none !important;

// Fields
address {
@@ -0,0 +1,5 @@
@include media-breakpoint-down(sm) {
img, .media_iframe_video, span.fa, i.fa {
transform: none !important;
@@ -134,6 +134,7 @@
<template id="assets_frontend" inherit_id="web.assets_frontend" name="Web Editor Frontend Assets (used in public odoo)" priority="15">
<xpath expr="//link[last()]" position="after">
<link rel="stylesheet" type="text/scss" href="/web_editor/static/src/scss/web_editor.common.scss"/> <!-- not in common because compiled differently with context -->
<link rel="stylesheet" type ="text/scss" href="/web_editor/static/src/scss/web_editor.frontend.scss"/>

@@ -1945,6 +1945,7 @@ Possible children elements of the search view are:

.. _reference/views/search/defaults:

Search defaults

@@ -1963,6 +1964,64 @@ assuming ``foo`` is a field and ``bar`` is a filter an action context of:
will automatically enable the ``bar`` filter and search the ``foo`` field for

.. _reference/views/map:


This view is able to display records on a map and the routes between them. The record are represented by pins. It also allows the visualization of fields from the model in a popup tied to the record's pin.

.. note::

The model on which the view is applied should contains a res.partner many2one since the view relies on the res.partner's address and coordinates fields to localize the records.

.. warning::

The Map view is only available in Odoo Enterprise

.. _reference/views/map/api:


The view uses location data plateforms' api to fetch the tiles (the map's background), do the geoforwarding (converting addresses to a set of coordinates) and fetch the routes.
The view implements two api, the default one, openstreet map is able to fetch `tiles`_ and do `geoforwarding`_. This api does not require a token.
As soon as a valid `MapBox`_ token is provided in the general settings the view switches to the Mapbox api. This api is faster and allows the computation of routes. The token are avalaible by `signing up`_ to MapBox

.. _reference/views/structural components:

Structural components

The view's root element is ``<map>`` multiple attributes are allowed

Contains the res.partner many2one. If not provided the view will resort to create an empty map.
If a field is provided the view will override the model's default order. The field must be apart of the model on which the view is applied not from res.partner
if ``true`` the routes between the records will be shown. The view still needs a valid MapBox token and at least two located records. (i.e the records has a res.partner many2one and the partner has a address or valid coordinates)

The only element allowed within the ``<map>`` element is the ``<marker-popup>``. This element is able to contain multiple ``<field>`` elements. Each of these elements whill be interpreted as a line in the marker's popup. The field's attributes are the following:

The field to display.
This string will be displayed before the field's content. It Can be used as a description.

No attribute or element is mandatory but as stated above if no res.partner many2one is provided the view won't be able to locate records.

For example here is a map:
.. code-block:: xml
<map res_partner="partner_id" default_order="date_begin" routing="true">
<field name="name" string="Task: "/>
.. _reference/views/qweb:

@@ -2019,6 +2078,10 @@ The main additions of qweb-as-view to the basic qweb-as-template are:
should only contain xpath elements
.. _geoforwarding:
.. _tiles:
.. _MapBox:
.. _signing up:
.. _accesskey:
.. _CSS color unit:
.. _floats:
@@ -193,6 +193,8 @@ def _split_street_with_params(self, street_raw, street_format):
city = fields.Char()
state_id = fields.Many2one("", string='State', ondelete='restrict', domain="[('country_id', '=?', country_id)]")
country_id = fields.Many2one('', string='Country', ondelete='restrict')
partner_latitude = fields.Float(string='Geo Latitude', digits=(16, 5))
partner_longitude = fields.Float(string='Geo Longitude', digits=(16, 5))
email = fields.Char()
email_formatted = fields.Char(
'Formatted Email', compute='_compute_email_formatted',

0 comments on commit 50e4931

Please sign in to comment.
You can’t perform that action at this time.