odoo-addon-web-view-leaflet-map 16.0.2.0.0.3__py3-none-any.whl → 18.0.1.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- odoo/addons/web_view_leaflet_map/README.rst +79 -77
- odoo/addons/web_view_leaflet_map/__manifest__.py +4 -5
- odoo/addons/web_view_leaflet_map/hooks.py +4 -4
- odoo/addons/web_view_leaflet_map/i18n/web_view_leaflet_map.pot +1 -9
- odoo/addons/web_view_leaflet_map/models/ir_ui_view.py +3 -0
- odoo/addons/web_view_leaflet_map/readme/CONFIGURE.md +1 -0
- odoo/addons/web_view_leaflet_map/readme/CONTRIBUTORS.md +1 -0
- odoo/addons/web_view_leaflet_map/readme/DESCRIPTION.md +13 -0
- odoo/addons/web_view_leaflet_map/readme/DEVELOP.md +53 -0
- odoo/addons/web_view_leaflet_map/readme/ROADMAP.md +8 -0
- odoo/addons/web_view_leaflet_map/static/description/index.html +55 -56
- odoo/addons/web_view_leaflet_map/static/src/components/map-component/map_view.esm.js +331 -0
- odoo/addons/web_view_leaflet_map/static/src/components/map-component/map_view.xml +19 -0
- {odoo_addon_web_view_leaflet_map-16.0.2.0.0.3.dist-info → odoo_addon_web_view_leaflet_map-18.0.1.0.1.dist-info}/METADATA +86 -83
- odoo_addon_web_view_leaflet_map-18.0.1.0.1.dist-info/RECORD +26 -0
- {odoo_addon_web_view_leaflet_map-16.0.2.0.0.3.dist-info → odoo_addon_web_view_leaflet_map-18.0.1.0.1.dist-info}/WHEEL +1 -1
- odoo_addon_web_view_leaflet_map-18.0.1.0.1.dist-info/top_level.txt +1 -0
- odoo/addons/web_view_leaflet_map/readme/CONFIGURE.rst +0 -1
- odoo/addons/web_view_leaflet_map/readme/CONTRIBUTORS.rst +0 -1
- odoo/addons/web_view_leaflet_map/readme/DESCRIPTION.rst +0 -11
- odoo/addons/web_view_leaflet_map/readme/DEVELOP.rst +0 -62
- odoo/addons/web_view_leaflet_map/readme/ROADMAP.rst +0 -8
- odoo/addons/web_view_leaflet_map/static/src/js/view/map/map_renderer.js +0 -178
- odoo/addons/web_view_leaflet_map/static/src/js/view/map/map_view.js +0 -34
- odoo/addons/web_view_leaflet_map/static/src/js/view/view_registry.js +0 -8
- odoo_addon_web_view_leaflet_map-16.0.2.0.0.3.dist-info/RECORD +0 -27
- odoo_addon_web_view_leaflet_map-16.0.2.0.0.3.dist-info/top_level.txt +0 -1
- /odoo/addons/web_view_leaflet_map/static/src/{css → components/map-component}/web_view_leaflet_map.css +0 -0
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import {registry} from "@web/core/registry";
|
|
2
|
+
import {useService} from "@web/core/utils/hooks";
|
|
3
|
+
import {Layout} from "@web/search/layout";
|
|
4
|
+
import {session} from "@web/session";
|
|
5
|
+
|
|
6
|
+
/* global L, console, document, DOMParser */
|
|
7
|
+
|
|
8
|
+
const {Component, useSubEnv, onWillStart, onMounted, onPatched, useRef} = owl;
|
|
9
|
+
|
|
10
|
+
export class MapRenderer extends Component {
|
|
11
|
+
/**
|
|
12
|
+
* Initializes the MapRenderer component, setting up services, references, and configuration.
|
|
13
|
+
*/
|
|
14
|
+
setup() {
|
|
15
|
+
console.log(this.props);
|
|
16
|
+
this.orm = useService("orm");
|
|
17
|
+
this.action = useService("action");
|
|
18
|
+
this.mapRef = useRef("mapContainer");
|
|
19
|
+
this.leafletTileUrl = session["leaflet.tile_url"];
|
|
20
|
+
this.leafletCopyright = session["leaflet.copyright"];
|
|
21
|
+
|
|
22
|
+
const archAttrs = this.props.archInfo.arch.attributes;
|
|
23
|
+
|
|
24
|
+
this.resModel = this.props.resModel;
|
|
25
|
+
this.defaultZoom = parseInt(archAttrs.default_zoom, 10) || 7;
|
|
26
|
+
this.maxZoom = parseInt(archAttrs.max_zoom, 10) || 19;
|
|
27
|
+
this.zoomSnap = parseInt(archAttrs.zoom_snap, 10) || 1;
|
|
28
|
+
|
|
29
|
+
this.fieldLatitude = archAttrs.field_latitude?.value;
|
|
30
|
+
this.fieldLongitude = archAttrs.field_longitude?.value;
|
|
31
|
+
this.fieldTitle = archAttrs.field_title?.value;
|
|
32
|
+
this.fieldAddress = archAttrs.field_address?.value;
|
|
33
|
+
this.fieldMarkerIconImage = archAttrs.field_marker_icon_image?.value;
|
|
34
|
+
|
|
35
|
+
this.markerIconSizeX = parseInt(archAttrs.marker_icon_size_x?.value, 10) || 64;
|
|
36
|
+
this.markerIconSizeY = parseInt(archAttrs.marker_icon_size_y?.value, 10) || 64;
|
|
37
|
+
this.markerPopupAnchorX =
|
|
38
|
+
parseInt(archAttrs.marker_popup_anchor_x?.value, 10) || 0;
|
|
39
|
+
this.markerPopupAnchorY =
|
|
40
|
+
parseInt(archAttrs.marker_popup_anchor_y?.value, 10) || -32;
|
|
41
|
+
|
|
42
|
+
this.leafletMap = null;
|
|
43
|
+
this.leafletFeatureGroup = null;
|
|
44
|
+
|
|
45
|
+
onWillStart(async () => {
|
|
46
|
+
await this.initDefaultPosition();
|
|
47
|
+
await this.loadRecords();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
onMounted(() => {
|
|
51
|
+
this.initMap();
|
|
52
|
+
this.renderMarkers();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
onPatched(() => {
|
|
56
|
+
console.log("onPatched");
|
|
57
|
+
if (this.leafletMap) {
|
|
58
|
+
this.renderMarkers();
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Loads records from the server based on the provided domain and fields.
|
|
65
|
+
* @returns {Promise<void>}
|
|
66
|
+
*/
|
|
67
|
+
async loadRecords() {
|
|
68
|
+
const fields = this.getFields();
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
// Cargar registros usando searchRead
|
|
72
|
+
const records = await this.orm.searchRead(
|
|
73
|
+
this.resModel,
|
|
74
|
+
this.props.domain || [],
|
|
75
|
+
fields,
|
|
76
|
+
{
|
|
77
|
+
limit: this.props.limit || 80,
|
|
78
|
+
context: this.props.context || {},
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
this.records = records;
|
|
82
|
+
} catch (error) {
|
|
83
|
+
console.error("Error loading records:", error);
|
|
84
|
+
this.records = [];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Gathers the required fields for the map view.
|
|
90
|
+
* @returns {any[]}
|
|
91
|
+
*/
|
|
92
|
+
getFields() {
|
|
93
|
+
const fields = new Set();
|
|
94
|
+
|
|
95
|
+
// Required fields
|
|
96
|
+
fields.add("id");
|
|
97
|
+
fields.add("display_name");
|
|
98
|
+
fields.add("date_localization");
|
|
99
|
+
|
|
100
|
+
// Optional fields based on arch attributes
|
|
101
|
+
if (this.fieldLatitude) fields.add(this.fieldLatitude);
|
|
102
|
+
if (this.fieldLongitude) fields.add(this.fieldLongitude);
|
|
103
|
+
if (this.fieldTitle) fields.add(this.fieldTitle);
|
|
104
|
+
if (this.fieldAddress) fields.add(this.fieldAddress);
|
|
105
|
+
if (this.fieldMarkerIconImage) fields.add(this.fieldMarkerIconImage);
|
|
106
|
+
|
|
107
|
+
return Array.from(fields);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Initializes the default position of the map by calling the server method.
|
|
112
|
+
* @returns {Promise<void>}
|
|
113
|
+
*/
|
|
114
|
+
async initDefaultPosition() {
|
|
115
|
+
const result = await this.orm.call(
|
|
116
|
+
"res.users",
|
|
117
|
+
"get_default_leaflet_position",
|
|
118
|
+
[this.props.resModel]
|
|
119
|
+
);
|
|
120
|
+
this.defaultLatLng = L.latLng(result.lat, result.lng);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Initializes the Leaflet map in the container.
|
|
125
|
+
*/
|
|
126
|
+
initMap() {
|
|
127
|
+
const mapDiv = this.mapRef.el;
|
|
128
|
+
if (!mapDiv) {
|
|
129
|
+
console.error("Map container not found");
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
this.leafletMap = L.map(mapDiv, {
|
|
134
|
+
zoomSnap: this.zoomSnap,
|
|
135
|
+
}).setView(this.defaultLatLng, this.defaultZoom);
|
|
136
|
+
|
|
137
|
+
L.tileLayer(this.leafletTileUrl, {
|
|
138
|
+
maxZoom: this.maxZoom,
|
|
139
|
+
attribution: this.leafletCopyright,
|
|
140
|
+
}).addTo(this.leafletMap);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Renders the markers on the map based on the loaded records.
|
|
145
|
+
*/
|
|
146
|
+
renderMarkers() {
|
|
147
|
+
if (!this.leafletMap) {
|
|
148
|
+
console.warn("Map not initialized yet");
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (this.leafletFeatureGroup) {
|
|
153
|
+
this.leafletMap.removeLayer(this.leafletFeatureGroup);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
this.leafletFeatureGroup = L.featureGroup().addTo(this.leafletMap);
|
|
157
|
+
|
|
158
|
+
for (const record of this.records) {
|
|
159
|
+
const marker = this.prepareMarker(record);
|
|
160
|
+
if (marker) {
|
|
161
|
+
marker.addTo(this.leafletFeatureGroup);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
const bounds = this.leafletFeatureGroup.getBounds();
|
|
165
|
+
if (bounds.isValid()) {
|
|
166
|
+
this.leafletMap.fitBounds(bounds.pad(0.1));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Prepares a Leaflet marker for the given record.
|
|
172
|
+
* @param {Object} record - The record object containing marker data
|
|
173
|
+
* @returns {*}
|
|
174
|
+
*/
|
|
175
|
+
prepareMarker(record) {
|
|
176
|
+
const lat = record[this.fieldLatitude];
|
|
177
|
+
const lng = record[this.fieldLongitude];
|
|
178
|
+
let marker = null;
|
|
179
|
+
if (!lat || !lng) {
|
|
180
|
+
console.log(`Record ${record.id} has no coordinates`);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const latlng = L.latLng(lat, lng);
|
|
185
|
+
if (latlng.lat !== 0 && latlng.lng !== 0) {
|
|
186
|
+
const markerOptions = this.prepareMarkerOptions(record);
|
|
187
|
+
|
|
188
|
+
marker = L.marker(latlng, markerOptions);
|
|
189
|
+
const popup = L.popup().setContent(this.preparePopUpData(record));
|
|
190
|
+
|
|
191
|
+
marker.bindPopup(popup).on("popupopen", () => {
|
|
192
|
+
const selector = document.querySelector(".o_map_selector");
|
|
193
|
+
if (selector) {
|
|
194
|
+
selector.addEventListener("click", (ev) => {
|
|
195
|
+
ev.preventDefault();
|
|
196
|
+
this.onClickLeafletPopup(record);
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
return marker;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Prepares the Leaflet icon for the marker using the image field.
|
|
207
|
+
* @param {Object} record - The record object containing marker data
|
|
208
|
+
* @returns {*}
|
|
209
|
+
*/
|
|
210
|
+
prepareMarkerIcon(record) {
|
|
211
|
+
const lastUpdate = record.date_localization || new Date().toISOString();
|
|
212
|
+
const unique = lastUpdate.replace(/[^0-9]/g, "");
|
|
213
|
+
const iconUrl = `/web/image?model=${this.resModel}&id=${record.id}&field=${this.fieldMarkerIconImage}&unique=${unique}`;
|
|
214
|
+
|
|
215
|
+
return L.icon({
|
|
216
|
+
iconUrl: iconUrl,
|
|
217
|
+
className: "leaflet_marker_icon",
|
|
218
|
+
iconSize: [this.markerIconSizeX, this.markerIconSizeY],
|
|
219
|
+
popupAnchor: [this.markerPopupAnchorX, this.markerPopupAnchorY],
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Prepares the options for the leaflet marker.
|
|
225
|
+
* @param {Object} record - The record object containing marker data
|
|
226
|
+
* @returns {{riseOnHover: Boolean, alt: (*|string), title: (*|string)}}
|
|
227
|
+
*/
|
|
228
|
+
prepareMarkerOptions(record) {
|
|
229
|
+
const title = record[this.fieldTitle] || "";
|
|
230
|
+
const result = {
|
|
231
|
+
title: title,
|
|
232
|
+
alt: title,
|
|
233
|
+
riseOnHover: true,
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
if (this.fieldMarkerIconImage) {
|
|
237
|
+
result.icon = this.prepareMarkerIcon(record);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return result;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Prepares the HTML content for the leaflet popup.
|
|
245
|
+
* @param {Object} record - The record object containing marker data
|
|
246
|
+
* @returns {String}
|
|
247
|
+
*/
|
|
248
|
+
preparePopUpData(record) {
|
|
249
|
+
const title = record[this.fieldTitle] || "";
|
|
250
|
+
const address = record[this.fieldAddress] || "";
|
|
251
|
+
|
|
252
|
+
return `
|
|
253
|
+
<div class='o_map_selector' data-res-id='${record.resId}'>
|
|
254
|
+
<b>${title}</b><br/>
|
|
255
|
+
${address ? ` - ${address}` : ""}
|
|
256
|
+
</div>
|
|
257
|
+
`;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Handles click on the leaflet popup to open the record form view.
|
|
262
|
+
* @param {Object} record - The record object containing marker data
|
|
263
|
+
*/
|
|
264
|
+
onClickLeafletPopup(record) {
|
|
265
|
+
this.action.doAction({
|
|
266
|
+
type: "ir.actions.act_window",
|
|
267
|
+
res_model: this.resModel,
|
|
268
|
+
res_id: record.id,
|
|
269
|
+
views: [[false, "form"]],
|
|
270
|
+
target: "current",
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
MapRenderer.template = "web_view_leaflet_map.MapRenderer";
|
|
276
|
+
MapRenderer.components = {};
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Controller class for the Map view, setting up the environment configuration.
|
|
280
|
+
*/
|
|
281
|
+
export class MapController extends Component {
|
|
282
|
+
setup() {
|
|
283
|
+
useSubEnv({
|
|
284
|
+
config: {
|
|
285
|
+
...this.env.config,
|
|
286
|
+
},
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
MapController.template = "web_view_leaflet_map.MapView";
|
|
292
|
+
MapController.components = {Layout, MapRenderer};
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Helper function that normalize the architecture input to ensure it is an HTMLElement.
|
|
296
|
+
* @param arch
|
|
297
|
+
* @returns {HTMLElement|*}
|
|
298
|
+
*/
|
|
299
|
+
function normalizeArch(arch) {
|
|
300
|
+
if (arch && typeof arch !== "string") return arch;
|
|
301
|
+
const xml = String(arch || "");
|
|
302
|
+
const doc = new DOMParser().parseFromString(xml, "text/xml");
|
|
303
|
+
return doc.documentElement;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Definition of the map view for Odoo, including its properties and components.
|
|
308
|
+
* @type {{searchMenuTypes: string[], icon: string, Renderer: MapRenderer, multiRecord: boolean, type: string, display_name: string, Controller: MapController, props: (function(*, *): *&{archInfo: {arch: *}, Renderer: MapRenderer})}}
|
|
309
|
+
*/
|
|
310
|
+
export const mapView = {
|
|
311
|
+
type: "leaflet_map",
|
|
312
|
+
display_name: "Map",
|
|
313
|
+
icon: "fa fa-map-o",
|
|
314
|
+
multiRecord: true,
|
|
315
|
+
Controller: MapController,
|
|
316
|
+
Renderer: MapRenderer,
|
|
317
|
+
searchMenuTypes: ["filter", "favorite"],
|
|
318
|
+
|
|
319
|
+
props: (genericProps) => {
|
|
320
|
+
const archEl = normalizeArch(genericProps.arch);
|
|
321
|
+
return {
|
|
322
|
+
...genericProps,
|
|
323
|
+
Renderer: MapRenderer,
|
|
324
|
+
archInfo: {
|
|
325
|
+
arch: archEl,
|
|
326
|
+
},
|
|
327
|
+
};
|
|
328
|
+
},
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
registry.category("views").add("leaflet_map", mapView);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
|
2
|
+
<templates xml:space="preserve">
|
|
3
|
+
|
|
4
|
+
<t t-name="web_view_leaflet_map.MapView" owl="1">
|
|
5
|
+
<Layout display="props.display" className="'h-100'">
|
|
6
|
+
<t t-set-slot="control-panel-bottom-right">
|
|
7
|
+
<div />
|
|
8
|
+
</t>
|
|
9
|
+
<MapRenderer t-props="props" />
|
|
10
|
+
</Layout>
|
|
11
|
+
</t>
|
|
12
|
+
|
|
13
|
+
<t t-name="web_view_leaflet_map.MapRenderer" owl="1">
|
|
14
|
+
<div class="o_leaflet_main_container h-100">
|
|
15
|
+
<div t-ref="mapContainer" class="o_leaflet_map_container h-100" />
|
|
16
|
+
</div>
|
|
17
|
+
</t>
|
|
18
|
+
|
|
19
|
+
</templates>
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: odoo-addon-web_view_leaflet_map
|
|
3
|
-
Version:
|
|
3
|
+
Version: 18.0.1.0.1
|
|
4
|
+
Requires-Python: >=3.10
|
|
5
|
+
Requires-Dist: odoo-addon-web_leaflet_lib==18.0.*
|
|
6
|
+
Requires-Dist: odoo==18.0.*
|
|
4
7
|
Summary: Add new 'leaflet_map' view, to display markers.
|
|
5
8
|
Home-page: https://github.com/OCA/geospatial
|
|
9
|
+
License: AGPL-3
|
|
6
10
|
Author: GRAP, Odoo Community Association (OCA)
|
|
7
11
|
Author-email: support@odoo-community.org
|
|
8
|
-
License: AGPL-3
|
|
9
12
|
Classifier: Programming Language :: Python
|
|
10
13
|
Classifier: Framework :: Odoo
|
|
11
|
-
Classifier: Framework :: Odoo ::
|
|
14
|
+
Classifier: Framework :: Odoo :: 18.0
|
|
12
15
|
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
|
|
13
16
|
Classifier: Development Status :: 3 - Alpha
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
Description-Content-Type: text/x-rst
|
|
18
|
+
|
|
19
|
+
.. image:: https://odoo-community.org/readme-banner-image
|
|
20
|
+
:target: https://odoo-community.org/get-involved?utm_source=readme
|
|
21
|
+
:alt: Odoo Community Association
|
|
17
22
|
|
|
18
23
|
================================
|
|
19
24
|
Leaflet Map View (OpenStreetMap)
|
|
@@ -24,38 +29,44 @@ Leaflet Map View (OpenStreetMap)
|
|
|
24
29
|
!! This file is generated by oca-gen-addon-readme !!
|
|
25
30
|
!! changes will be overwritten. !!
|
|
26
31
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
27
|
-
!! source digest: sha256:
|
|
32
|
+
!! source digest: sha256:b819c0e0d0b447189a53096676a3ce5eb62eb32e5dbeed12d05c5ab3a187d5f5
|
|
28
33
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
29
34
|
|
|
30
35
|
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
|
|
31
36
|
:target: https://odoo-community.org/page/development-status
|
|
32
37
|
:alt: Alpha
|
|
33
|
-
.. |badge2| image:: https://img.shields.io/badge/
|
|
38
|
+
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
|
|
34
39
|
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
|
35
40
|
:alt: License: AGPL-3
|
|
36
41
|
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fgeospatial-lightgray.png?logo=github
|
|
37
|
-
:target: https://github.com/OCA/geospatial/tree/
|
|
42
|
+
:target: https://github.com/OCA/geospatial/tree/18.0/web_view_leaflet_map
|
|
38
43
|
:alt: OCA/geospatial
|
|
39
44
|
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
|
40
|
-
:target: https://translation.odoo-community.org/projects/geospatial-
|
|
45
|
+
:target: https://translation.odoo-community.org/projects/geospatial-18-0/geospatial-18-0-web_view_leaflet_map
|
|
41
46
|
:alt: Translate me on Weblate
|
|
42
47
|
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
|
|
43
|
-
:target: https://runboat.odoo-community.org/builds?repo=OCA/geospatial&target_branch=
|
|
48
|
+
:target: https://runboat.odoo-community.org/builds?repo=OCA/geospatial&target_branch=18.0
|
|
44
49
|
:alt: Try me on Runboat
|
|
45
50
|
|
|
46
51
|
|badge1| |badge2| |badge3| |badge4| |badge5|
|
|
47
52
|
|
|
48
|
-
This module extends odoo views, to add a new kind of view, named
|
|
49
|
-
that is using the Leaflet javascript library to use
|
|
50
|
-
This library is for exemple, used in the
|
|
53
|
+
This module extends odoo views, to add a new kind of view, named
|
|
54
|
+
``leaflet_map`` that is using the Leaflet javascript library to use
|
|
55
|
+
maps. (https://leafletjs.com/) This library is for exemple, used in the
|
|
56
|
+
OpenStreetMap project. (https://www.openstreetmap.org/)
|
|
57
|
+
|
|
58
|
+
You can see a simple usage in the module
|
|
59
|
+
``web_view_leaflet_map_partner`` in the same OCA repository that
|
|
60
|
+
displays your contact in a map, if latitude and longitude are defined.
|
|
61
|
+
(To define latitude and longitude, refer to the Odoo module
|
|
62
|
+
``base_geolocalize``)
|
|
51
63
|
|
|
52
|
-
|
|
53
|
-
same OCA repository that displays your contact in a map, if latitude and longitude are
|
|
54
|
-
defined. (To define latitude and longitude, refer to the Odoo module ``base_geolocalize``)
|
|
64
|
+
|image1|
|
|
55
65
|
|
|
56
|
-
|
|
66
|
+
|image2|
|
|
57
67
|
|
|
58
|
-
..
|
|
68
|
+
.. |image1| image:: https://raw.githubusercontent.com/OCA/geospatial/18.0/web_view_leaflet_map/static/description/view_res_partner_map_1.png
|
|
69
|
+
.. |image2| image:: https://raw.githubusercontent.com/OCA/geospatial/18.0/web_view_leaflet_map/static/description/view_res_partner_map_2.png
|
|
59
70
|
|
|
60
71
|
.. IMPORTANT::
|
|
61
72
|
This is an alpha version, the data model and design can change at any time without warning.
|
|
@@ -70,85 +81,77 @@ defined. (To define latitude and longitude, refer to the Odoo module ``base_geol
|
|
|
70
81
|
Configuration
|
|
71
82
|
=============
|
|
72
83
|
|
|
73
|
-
|
|
84
|
+
- See configuration of the module ``web_leaflet_lib``.
|
|
74
85
|
|
|
75
86
|
Development
|
|
76
87
|
===========
|
|
77
88
|
|
|
78
89
|
Create a new view :
|
|
79
90
|
|
|
80
|
-
.. code
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
1. FIELD_LATITUDE and FIELD_LONGITUDE are the name of the fields that
|
|
91
|
+
.. code:: xml
|
|
92
|
+
|
|
93
|
+
<record id="view_my_model_map" model="ir.ui.view">
|
|
94
|
+
<field name="model">my.model</field>
|
|
95
|
+
<field name="arch" type="xml">
|
|
96
|
+
<leaflet_map
|
|
97
|
+
field_latitude="FIELD_LATITUDE"
|
|
98
|
+
field_longitude="FIELD_LONGITUDE"
|
|
99
|
+
field_title="FIELD_TITLE"
|
|
100
|
+
field_address="FIELD_ADDRESS"
|
|
101
|
+
field_marker_icon_image="FIELD_MARKER_ICON_IMAGE"
|
|
102
|
+
>
|
|
103
|
+
<field name="__last_update"/>
|
|
104
|
+
<field name="FIELD_LATITUDE"/>
|
|
105
|
+
<field name="FIELD_LONGITUDE"/>
|
|
106
|
+
<field name="FIELD_TITLE"/>
|
|
107
|
+
<field name="FIELD_ADDRESS"/>
|
|
108
|
+
</leaflet_map>
|
|
109
|
+
</field>
|
|
110
|
+
</record>
|
|
111
|
+
|
|
112
|
+
1. FIELD_LATITUDE and FIELD_LONGITUDE are the name of the fields that
|
|
113
|
+
contains GPS coordinates of the model.
|
|
102
114
|
2. FIELD_TITLE will be used when the popup is displayed, as a title.
|
|
103
|
-
3. FIELD_ADDRESS will be used when the popup is displayed to display the
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
Note: You can set extra settings
|
|
107
|
-
|
|
108
|
-
the
|
|
115
|
+
3. FIELD_ADDRESS will be used when the popup is displayed to display the
|
|
116
|
+
adress.
|
|
117
|
+
4. (optional) FIELD_MARKER_ICON_IMAGE, is the name of the image field to
|
|
118
|
+
place as an icon of the marker. Note: You can set extra settings
|
|
119
|
+
``marker_icon_size_x``, ``marker_icon_size_y``, to define the size of
|
|
120
|
+
the image, and ``marker_popup_anchor_x``, ``marker_popup_anchor_y``
|
|
121
|
+
to define the position of the popup.
|
|
109
122
|
|
|
110
123
|
Map options :
|
|
111
124
|
|
|
112
125
|
- ``default_zoom`` : define the default zoom value. (7 if not defined)
|
|
113
126
|
- ``max_zoom`` : define the max zoom value. (19 if not defined)
|
|
114
|
-
- ``zoom_snap`` : define the zoom level in each change. (1 if not
|
|
127
|
+
- ``zoom_snap`` : define the zoom level in each change. (1 if not
|
|
128
|
+
defined)
|
|
129
|
+
- Create or update an action for the model
|
|
115
130
|
|
|
116
|
-
|
|
131
|
+
.. code:: xml
|
|
117
132
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
<field name="view_mode">tree,form,leaflet_map</field>
|
|
122
|
-
</record>
|
|
123
|
-
|
|
124
|
-
**Library Update**
|
|
125
|
-
|
|
126
|
-
For the time being, the module embed the lealflet.js library version 1.8.0 ( released on April 18, 2022.)
|
|
127
|
-
|
|
128
|
-
If a new release is out:
|
|
129
|
-
|
|
130
|
-
- please download it here https://leafletjs.com/download.html
|
|
131
|
-
- update the javascript, css and images, present in the folder ``static/lib/leaflet``
|
|
132
|
-
- test the features
|
|
133
|
-
- make a Pull Request
|
|
133
|
+
<record id="my_module.action_my_model" model="ir.actions.act_window">
|
|
134
|
+
<field name="view_mode">tree,form,leaflet_map</field>
|
|
135
|
+
</record>
|
|
134
136
|
|
|
135
137
|
**Default position in the map**
|
|
136
138
|
|
|
137
|
-
By default, the position of the map is defined by the user, in the
|
|
138
|
-
``get_default_leaflet_position``. It returns the position of
|
|
139
|
-
you can overload this function
|
|
139
|
+
By default, the position of the map is defined by the user, in the
|
|
140
|
+
function ``get_default_leaflet_position``. It returns the position of
|
|
141
|
+
the current company, if defined. you can overload this function
|
|
142
|
+
globally, or per model.
|
|
140
143
|
|
|
141
144
|
Known issues / Roadmap
|
|
142
145
|
======================
|
|
143
146
|
|
|
144
|
-
|
|
145
|
-
is required. We should investigate why and try to
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if longitude and latitude are available. We could imagine other
|
|
150
|
-
with Polylines, Polygons, etc...
|
|
151
|
-
|
|
147
|
+
- For the time being, at the start of the map loading, the call of
|
|
148
|
+
``invalidateSize()`` is required. We should investigate why and try to
|
|
149
|
+
remove that call. see
|
|
150
|
+
https://github.com/Leaflet/Leaflet/issues/3002#issuecomment-93836022
|
|
151
|
+
- For the time being, the map has "Markers" and allow to display odoo
|
|
152
|
+
items if longitude and latitude are available. We could imagine other
|
|
153
|
+
kind of usages, with Polylines, Polygons, etc... See all the leaflet
|
|
154
|
+
options : https://leafletjs.com/reference.html
|
|
152
155
|
|
|
153
156
|
Bug Tracker
|
|
154
157
|
===========
|
|
@@ -156,7 +159,7 @@ Bug Tracker
|
|
|
156
159
|
Bugs are tracked on `GitHub Issues <https://github.com/OCA/geospatial/issues>`_.
|
|
157
160
|
In case of trouble, please check there if your issue has already been reported.
|
|
158
161
|
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
|
159
|
-
`feedback <https://github.com/OCA/geospatial/issues/new?body=module:%20web_view_leaflet_map%0Aversion:%
|
|
162
|
+
`feedback <https://github.com/OCA/geospatial/issues/new?body=module:%20web_view_leaflet_map%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
|
160
163
|
|
|
161
164
|
Do not contact contributors directly about support or help with technical issues.
|
|
162
165
|
|
|
@@ -164,17 +167,17 @@ Credits
|
|
|
164
167
|
=======
|
|
165
168
|
|
|
166
169
|
Authors
|
|
167
|
-
|
|
170
|
+
-------
|
|
168
171
|
|
|
169
172
|
* GRAP
|
|
170
173
|
|
|
171
174
|
Contributors
|
|
172
|
-
|
|
175
|
+
------------
|
|
173
176
|
|
|
174
|
-
|
|
177
|
+
- Sylvain LE GAL (https://www.twitter.com/legalsylvain)
|
|
175
178
|
|
|
176
179
|
Maintainers
|
|
177
|
-
|
|
180
|
+
-----------
|
|
178
181
|
|
|
179
182
|
This module is maintained by the OCA.
|
|
180
183
|
|
|
@@ -194,6 +197,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|
|
|
194
197
|
|
|
195
198
|
|maintainer-legalsylvain|
|
|
196
199
|
|
|
197
|
-
This module is part of the `OCA/geospatial <https://github.com/OCA/geospatial/tree/
|
|
200
|
+
This module is part of the `OCA/geospatial <https://github.com/OCA/geospatial/tree/18.0/web_view_leaflet_map>`_ project on GitHub.
|
|
198
201
|
|
|
199
202
|
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
odoo/addons/web_view_leaflet_map/README.rst,sha256=kq8tmjmnL_RW85jL0D7i0QEJMGRONyCKdYq6cFgKA0g,7032
|
|
2
|
+
odoo/addons/web_view_leaflet_map/__init__.py,sha256=lHbcD_3Jhk02gKyANjQ1Bif8uknO8qLtRSK4lJNPeeQ,55
|
|
3
|
+
odoo/addons/web_view_leaflet_map/__manifest__.py,sha256=NQEcfUofTU7necxdAidm3Tr3rqsX8_gp4fqpwzbQdLY,1052
|
|
4
|
+
odoo/addons/web_view_leaflet_map/hooks.py,sha256=VWhMUWedPCg8oZxqJCladNBaU9NvJMBJI6BlYKXNcEM,685
|
|
5
|
+
odoo/addons/web_view_leaflet_map/i18n/fr.po,sha256=xSXoIxogfegwOztumHeW5R4xxUooxHsDPCcoqQEgm0k,2102
|
|
6
|
+
odoo/addons/web_view_leaflet_map/i18n/it.po,sha256=RjAJVMbLRt2eJZ-YG2gb_yGGEfB9idHfZZt7Y_ehU0Y,1761
|
|
7
|
+
odoo/addons/web_view_leaflet_map/i18n/web_view_leaflet_map.pot,sha256=GRdgXiphYPs5XratOBcLF4t50oeVlIt56N8ieFm0FHU,1291
|
|
8
|
+
odoo/addons/web_view_leaflet_map/models/__init__.py,sha256=K0P7QAr_t6UHNt0nbpDhqpH4-zILR1hpfNip3VUtouc,82
|
|
9
|
+
odoo/addons/web_view_leaflet_map/models/ir_act_window_view.py,sha256=NfjklK_VNBCuuXn0X22uQzWr9iOJWeT2oN-qXwwDhqQ,499
|
|
10
|
+
odoo/addons/web_view_leaflet_map/models/ir_ui_view.py,sha256=6K_zmkC44ymIDNycqo2KxFq3brsrd6tvm_JpjIlebdw,518
|
|
11
|
+
odoo/addons/web_view_leaflet_map/models/res_users.py,sha256=SmYcwiVXifiT8pDlb1pdAYnlvnodZ8oOrJHr6GQlle4,545
|
|
12
|
+
odoo/addons/web_view_leaflet_map/readme/CONFIGURE.md,sha256=X0jv_nRhCoSaQ3ZqwOqr8g03pGHv-elXfhX6gIN4ilg,53
|
|
13
|
+
odoo/addons/web_view_leaflet_map/readme/CONTRIBUTORS.md,sha256=MBsB-NNU4QMO7gTa_ZRympiiIQwyMPYqq4M3-PbwbHM,58
|
|
14
|
+
odoo/addons/web_view_leaflet_map/readme/DESCRIPTION.md,sha256=Ubg66tabR4lkMIhbfKTQqyl33dOHRLXlIgYe1ReZv_E,629
|
|
15
|
+
odoo/addons/web_view_leaflet_map/readme/DEVELOP.md,sha256=kiVt9qT6SC6Uh9fY0qqSpaI9HSeC67Ppi0b7O7iGPfg,1968
|
|
16
|
+
odoo/addons/web_view_leaflet_map/readme/ROADMAP.md,sha256=PuCMzJS_OKS0w9YBe1r4k3sIJnuvhcrS7qiuUwzwBzk,499
|
|
17
|
+
odoo/addons/web_view_leaflet_map/static/description/icon.png,sha256=6xBPJauaFOF0KDHfHgQopSc28kKvxMaeoQFQWZtfZDo,9455
|
|
18
|
+
odoo/addons/web_view_leaflet_map/static/description/index.html,sha256=h1-cZFdpWwUWqkZ-bQ1Y2kFy1Y27G2LiywohmWtZBZI,20542
|
|
19
|
+
odoo/addons/web_view_leaflet_map/static/description/res_partner_map.png,sha256=vyOw2l7n7k4-jYgTT-r31vA4h8kSnjMo0WW0iNEzRi4,390800
|
|
20
|
+
odoo/addons/web_view_leaflet_map/static/src/components/map-component/map_view.esm.js,sha256=77rRNW5R5KokooVkKrgOjTCgbxYKK0owy10_02Nat4Y,10535
|
|
21
|
+
odoo/addons/web_view_leaflet_map/static/src/components/map-component/map_view.xml,sha256=bVHRZOFSKUDKBybx0BzZRgwgJh7DvlKtsMI2fNhrqrc,586
|
|
22
|
+
odoo/addons/web_view_leaflet_map/static/src/components/map-component/web_view_leaflet_map.css,sha256=Tp3SfDNuSPCN32sh_HlSmiF3AYWlvxlzSp8u3NCAHiA,1527
|
|
23
|
+
odoo_addon_web_view_leaflet_map-18.0.1.0.1.dist-info/METADATA,sha256=vXCHetE3w4r5zdAtU-KDf2gLaHHOyqYjBYcW5NCu3w8,7689
|
|
24
|
+
odoo_addon_web_view_leaflet_map-18.0.1.0.1.dist-info/WHEEL,sha256=ZhOvUsYhy81Dx67gN3TV0RchQWBIIzutDZaJODDg2Vo,81
|
|
25
|
+
odoo_addon_web_view_leaflet_map-18.0.1.0.1.dist-info/top_level.txt,sha256=QE6RBQ0QX5f4eFuUcGgU5Kbq1A_qJcDs-e_vpr6pmfU,4
|
|
26
|
+
odoo_addon_web_view_leaflet_map-18.0.1.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
odoo
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
* See configuration of the module ``web_leaflet_lib``.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
* Sylvain LE GAL (https://www.twitter.com/legalsylvain)
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
This module extends odoo views, to add a new kind of view, named ``leaflet_map``
|
|
2
|
-
that is using the Leaflet javascript library to use maps. (https://leafletjs.com/)
|
|
3
|
-
This library is for exemple, used in the OpenStreetMap project. (https://www.openstreetmap.org/)
|
|
4
|
-
|
|
5
|
-
You can see a simple usage in the module ``web_view_leaflet_map_partner`` in the
|
|
6
|
-
same OCA repository that displays your contact in a map, if latitude and longitude are
|
|
7
|
-
defined. (To define latitude and longitude, refer to the Odoo module ``base_geolocalize``)
|
|
8
|
-
|
|
9
|
-
.. figure:: ../static/description/view_res_partner_map_1.png
|
|
10
|
-
|
|
11
|
-
.. figure:: ../static/description/view_res_partner_map_2.png
|