Skip to content

Commit e61a497

Browse files
committed
Merge PR #415 into 17.0
Signed-off-by legalsylvain
2 parents 15ab361 + 61779c3 commit e61a497

23 files changed

Lines changed: 1498 additions & 0 deletions

web_view_leaflet_map/README.rst

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
================================
2+
Leaflet Map View (OpenStreetMap)
3+
================================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:f494ec35cbd29ae4bcc5e46a7a30bf5b2261bd449a3b0ba08a95a70d45dbea12
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Alpha
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fgeospatial-lightgray.png?logo=github
20+
:target: https://github.com/OCA/geospatial/tree/17.0/web_view_leaflet_map
21+
:alt: OCA/geospatial
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/geospatial-17-0/geospatial-17-0-web_view_leaflet_map
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/geospatial&target_branch=17.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module extends odoo views, to add a new kind of view, named
32+
``leaflet_map`` that is using the Leaflet javascript library to use
33+
maps. (https://leafletjs.com/) This library is for exemple, used in the
34+
OpenStreetMap project. (https://www.openstreetmap.org/)
35+
36+
You can see a simple usage in the module
37+
``web_view_leaflet_map_partner`` in the same OCA repository that
38+
displays your contact in a map, if latitude and longitude are defined.
39+
(To define latitude and longitude, refer to the Odoo module
40+
``base_geolocalize``)
41+
42+
|image1|
43+
44+
|image2|
45+
46+
.. |image1| image:: https://raw.githubusercontent.com/OCA/geospatial/17.0/web_view_leaflet_map/static/description/view_res_partner_map_1.png
47+
.. |image2| image:: https://raw.githubusercontent.com/OCA/geospatial/17.0/web_view_leaflet_map/static/description/view_res_partner_map_2.png
48+
49+
.. IMPORTANT::
50+
This is an alpha version, the data model and design can change at any time without warning.
51+
Only for development or testing purpose, do not use in production.
52+
`More details on development status <https://odoo-community.org/page/development-status>`_
53+
54+
**Table of contents**
55+
56+
.. contents::
57+
:local:
58+
59+
Configuration
60+
=============
61+
62+
- See configuration of the module ``web_leaflet_lib``.
63+
64+
Development
65+
===========
66+
67+
Create a new view :
68+
69+
.. code:: xml
70+
71+
<record id="view_my_model_map" model="ir.ui.view">
72+
<field name="model">my.model</field>
73+
<field name="arch" type="xml">
74+
<leaflet_map
75+
field_latitude="FIELD_LATITUDE"
76+
field_longitude="FIELD_LONGITUDE"
77+
field_title="FIELD_TITLE"
78+
field_address="FIELD_ADDRESS"
79+
field_marker_icon_image="FIELD_MARKER_ICON_IMAGE"
80+
>
81+
<field name="__last_update"/>
82+
<field name="FIELD_LATITUDE"/>
83+
<field name="FIELD_LONGITUDE"/>
84+
<field name="FIELD_TITLE"/>
85+
<field name="FIELD_ADDRESS"/>
86+
</leaflet_map>
87+
</field>
88+
</record>
89+
90+
1. FIELD_LATITUDE and FIELD_LONGITUDE are the name of the fields that
91+
contains GPS coordinates of the model.
92+
2. FIELD_TITLE will be used when the popup is displayed, as a title.
93+
3. FIELD_ADDRESS will be used when the popup is displayed to display the
94+
adress.
95+
4. (optional) FIELD_MARKER_ICON_IMAGE, is the name of the image field to
96+
place as an icon of the marker. Note: You can set extra settings
97+
``marker_icon_size_x``, ``marker_icon_size_y``, to define the size of
98+
the image, and ``marker_popup_anchor_x``, ``marker_popup_anchor_y``
99+
to define the position of the popup.
100+
101+
Map options :
102+
103+
- ``default_zoom`` : define the default zoom value. (7 if not defined)
104+
- ``max_zoom`` : define the max zoom value. (19 if not defined)
105+
- ``zoom_snap`` : define the zoom level in each change. (1 if not
106+
defined)
107+
- Create or update an action for the model
108+
109+
.. code:: xml
110+
111+
<record id="my_module.action_my_model" model="ir.actions.act_window">
112+
<field name="view_mode">tree,form,leaflet_map</field>
113+
</record>
114+
115+
**Library Update**
116+
117+
For the time being, the module embed the lealflet.js library version
118+
1.8.0 ( released on April 18, 2022.)
119+
120+
If a new release is out:
121+
122+
- please download it here https://leafletjs.com/download.html
123+
- update the javascript, css and images, present in the folder
124+
``static/lib/leaflet``
125+
- test the features
126+
- make a Pull Request
127+
128+
**Default position in the map**
129+
130+
By default, the position of the map is defined by the user, in the
131+
function ``get_default_leaflet_position``. It returns the position of
132+
the current company, if defined. you can overload this function
133+
globally, or per model.
134+
135+
Known issues / Roadmap
136+
======================
137+
138+
- For the time being, at the start of the map loading, the call of
139+
``invalidateSize()`` is required. We should investigate why and try
140+
to remove that call. see
141+
https://github.com/Leaflet/Leaflet/issues/3002#issuecomment-93836022
142+
- For the time being, the map has "Markers" and allow to display odoo
143+
items if longitude and latitude are available. We could imagine other
144+
kind of usages, with Polylines, Polygons, etc... See all the leaflet
145+
options : https://leafletjs.com/reference.html
146+
147+
Bug Tracker
148+
===========
149+
150+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/geospatial/issues>`_.
151+
In case of trouble, please check there if your issue has already been reported.
152+
If you spotted it first, help us to smash it by providing a detailed and welcomed
153+
`feedback <https://github.com/OCA/geospatial/issues/new?body=module:%20web_view_leaflet_map%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
154+
155+
Do not contact contributors directly about support or help with technical issues.
156+
157+
Credits
158+
=======
159+
160+
Authors
161+
-------
162+
163+
* GRAP
164+
165+
Contributors
166+
------------
167+
168+
- Sylvain LE GAL (https://www.twitter.com/legalsylvain)
169+
170+
Maintainers
171+
-----------
172+
173+
This module is maintained by the OCA.
174+
175+
.. image:: https://odoo-community.org/logo.png
176+
:alt: Odoo Community Association
177+
:target: https://odoo-community.org
178+
179+
OCA, or the Odoo Community Association, is a nonprofit organization whose
180+
mission is to support the collaborative development of Odoo features and
181+
promote its widespread use.
182+
183+
.. |maintainer-legalsylvain| image:: https://github.com/legalsylvain.png?size=40px
184+
:target: https://github.com/legalsylvain
185+
:alt: legalsylvain
186+
187+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
188+
189+
|maintainer-legalsylvain|
190+
191+
This module is part of the `OCA/geospatial <https://github.com/OCA/geospatial/tree/17.0/web_view_leaflet_map>`_ project on GitHub.
192+
193+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

web_view_leaflet_map/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import models
2+
from .hooks import uninstall_hook
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (C) 2022 - Today: GRAP (http://www.grap.coop)
2+
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
4+
5+
{
6+
"name": "Leaflet Map View (OpenStreetMap)",
7+
"summary": "Add new 'leaflet_map' view, to display markers.",
8+
"version": "17.0.1.0.0",
9+
"development_status": "Alpha",
10+
"author": "GRAP, Odoo Community Association (OCA)",
11+
"maintainers": ["legalsylvain"],
12+
"website": "https://github.com/OCA/geospatial",
13+
"license": "AGPL-3",
14+
"category": "Extra Tools",
15+
"depends": [
16+
"base_geolocalize",
17+
"web_leaflet_lib",
18+
],
19+
"assets": {
20+
"web.assets_backend": [
21+
"web_view_leaflet_map/static/src/components/map-component/map_view.esm.js",
22+
"web_view_leaflet_map/static/src/components/map-component/map_view.xml",
23+
"web_view_leaflet_map/static/src/components/map-component/web_view_leaflet_map.css",
24+
],
25+
},
26+
"installable": True,
27+
"uninstall_hook": "uninstall_hook",
28+
}

web_view_leaflet_map/hooks.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (C) 2019, Open Source Integrators
2+
# Copyright (C) 2022 - Today: GRAP (http://www.grap.coop)
3+
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
4+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
5+
6+
7+
def uninstall_hook(env):
8+
env.cr.execute(
9+
"UPDATE ir_act_window "
10+
"SET view_mode=replace(view_mode, ',leaflet_map', '')"
11+
"WHERE view_mode LIKE '%,leaflet_map%';"
12+
)
13+
env.cr.execute(
14+
"UPDATE ir_act_window "
15+
"SET view_mode=replace(view_mode, 'leaflet_map,', '')"
16+
"WHERE view_mode LIKE '%leaflet_map,%';"
17+
)
18+
env.cr.execute("DELETE FROM ir_act_window " "WHERE view_mode = 'leaflet_map';")

web_view_leaflet_map/i18n/fr.po

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * web_view_leaflet_map
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 12.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2022-09-18 19:56+0000\n"
10+
"PO-Revision-Date: 2022-09-18 19:56+0000\n"
11+
"Last-Translator: <>\n"
12+
"Language-Team: \n"
13+
"Language: \n"
14+
"MIME-Version: 1.0\n"
15+
"Content-Type: text/plain; charset=UTF-8\n"
16+
"Content-Transfer-Encoding: \n"
17+
"Plural-Forms: \n"
18+
19+
#. module: web_view_leaflet_map
20+
#: model:ir.model,name:web_view_leaflet_map.model_ir_actions_act_window_view
21+
msgid "Action Window View"
22+
msgstr "Vue de la Fenêtre d'Action"
23+
24+
#. module: web_view_leaflet_map
25+
#: model:ir.model.fields.selection,name:web_view_leaflet_map.selection__ir_actions_act_window_view__view_mode__leaflet_map
26+
#: model:ir.model.fields.selection,name:web_view_leaflet_map.selection__ir_ui_view__type__leaflet_map
27+
msgid "Leaflet Map"
28+
msgstr "Carte Leaflet"
29+
30+
#. module: web_view_leaflet_map
31+
#. odoo-javascript
32+
#: code:addons/web_view_leaflet_map/static/src/js/view/map/map_view.js:0
33+
#, python-format
34+
msgid "Map"
35+
msgstr "Carte"
36+
37+
#. module: web_view_leaflet_map
38+
#: model:ir.model,name:web_view_leaflet_map.model_res_users
39+
msgid "User"
40+
msgstr ""
41+
42+
#. module: web_view_leaflet_map
43+
#: model:ir.model,name:web_view_leaflet_map.model_ir_ui_view
44+
msgid "View"
45+
msgstr "Vue"
46+
47+
#. module: web_view_leaflet_map
48+
#: model:ir.model.fields,field_description:web_view_leaflet_map.field_ir_actions_act_window_view__view_mode
49+
#: model:ir.model.fields,field_description:web_view_leaflet_map.field_ir_ui_view__type
50+
#: model:ir.model.fields,field_description:web_view_leaflet_map.field_website_page__type
51+
msgid "View Type"
52+
msgstr "Type de Vue"
53+
54+
#~ msgid "Activity"
55+
#~ msgstr "Activité"
56+
57+
#~ msgid "Calendar"
58+
#~ msgstr "Calendrier"
59+
60+
#~ msgid "Diagram"
61+
#~ msgstr "Diagramme"
62+
63+
#~ msgid "Form"
64+
#~ msgstr "Formulaire"
65+
66+
#~ msgid "Graph"
67+
#~ msgstr "Graphique"
68+
69+
#~ msgid "Pivot"
70+
#~ msgstr "Tableau croisé dynamique"
71+
72+
#~ msgid "Search"
73+
#~ msgstr "Rechercher"
74+
75+
#~ msgid "Tree"
76+
#~ msgstr "Arborescence"
77+
78+
#~ msgid "Users"
79+
#~ msgstr "Utilisateurs"

web_view_leaflet_map/i18n/it.po

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * web_view_leaflet_map
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 16.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"PO-Revision-Date: 2024-01-26 08:36+0000\n"
10+
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
11+
"Language-Team: none\n"
12+
"Language: it\n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
17+
"X-Generator: Weblate 4.17\n"
18+
19+
#. module: web_view_leaflet_map
20+
#: model:ir.model,name:web_view_leaflet_map.model_ir_actions_act_window_view
21+
msgid "Action Window View"
22+
msgstr "Vista maschera azione"
23+
24+
#. module: web_view_leaflet_map
25+
#: model:ir.model.fields.selection,name:web_view_leaflet_map.selection__ir_actions_act_window_view__view_mode__leaflet_map
26+
#: model:ir.model.fields.selection,name:web_view_leaflet_map.selection__ir_ui_view__type__leaflet_map
27+
msgid "Leaflet Map"
28+
msgstr "Mappa Leaflet"
29+
30+
#. module: web_view_leaflet_map
31+
#. odoo-javascript
32+
#: code:addons/web_view_leaflet_map/static/src/js/view/map/map_view.js:0
33+
#, python-format
34+
msgid "Map"
35+
msgstr "Mappa"
36+
37+
#. module: web_view_leaflet_map
38+
#: model:ir.model,name:web_view_leaflet_map.model_res_users
39+
msgid "User"
40+
msgstr "Utente"
41+
42+
#. module: web_view_leaflet_map
43+
#: model:ir.model,name:web_view_leaflet_map.model_ir_ui_view
44+
msgid "View"
45+
msgstr "Vista"
46+
47+
#. module: web_view_leaflet_map
48+
#: model:ir.model.fields,field_description:web_view_leaflet_map.field_ir_actions_act_window_view__view_mode
49+
#: model:ir.model.fields,field_description:web_view_leaflet_map.field_ir_ui_view__type
50+
#: model:ir.model.fields,field_description:web_view_leaflet_map.field_website_page__type
51+
msgid "View Type"
52+
msgstr "Tipo vista"

0 commit comments

Comments
 (0)