diff --git a/web_view_leaflet_map/__manifest__.py b/web_view_leaflet_map/__manifest__.py index 96549cd84..417e96824 100644 --- a/web_view_leaflet_map/__manifest__.py +++ b/web_view_leaflet_map/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Leaflet Map View (OpenStreetMap)", "summary": "Add new 'leaflet_map' view, to display markers.", - "version": "18.0.1.1.2", + "version": "18.0.1.1.3", "author": "GRAP, Odoo Community Association (OCA)", "maintainers": ["legalsylvain"], "website": "https://github.com/OCA/geospatial", diff --git a/web_view_leaflet_map/static/src/views/leaflet_map/leaflet_map_renderer.esm.js b/web_view_leaflet_map/static/src/views/leaflet_map/leaflet_map_renderer.esm.js index 35127a885..2feda4d8f 100644 --- a/web_view_leaflet_map/static/src/views/leaflet_map/leaflet_map_renderer.esm.js +++ b/web_view_leaflet_map/static/src/views/leaflet_map/leaflet_map_renderer.esm.js @@ -3,7 +3,7 @@ import {useService} from "@web/core/utils/hooks"; /* global L, console, document */ -const {Component, onWillStart, onMounted, onPatched, useRef} = owl; +const {Component, onWillStart, onMounted, onPatched, onWillUpdateProps, useRef} = owl; export class MapRenderer extends Component { static template = "web_view_leaflet_map.MapRenderer"; @@ -58,24 +58,30 @@ export class MapRenderer extends Component { this.renderMarkers(); } }); + + // Reload the records when the search domain/context changes (filters, + // favorites, ...) so the markers reflect the active search. + onWillUpdateProps(async (nextProps) => { + await this.loadRecords(nextProps.domain, nextProps.context); + }); } /** * Loads records from the server based on the provided domain and fields. * @returns {Promise} */ - async loadRecords() { + async loadRecords(domain, context) { const fields = this.getFields(); try { // Cargar registros usando searchRead const records = await this.orm.searchRead( this.resModel, - this.props.domain || [], + domain === undefined ? this.props.domain || [] : domain, fields, { limit: this.props.limit || 80, - context: this.props.context || {}, + context: context === undefined ? this.props.context || {} : context, } ); this.records = records;