From 5c119374eeab9d1c7607035c2980f7ab338ce601 Mon Sep 17 00:00:00 2001 From: Jonasaaaa Date: Sun, 31 May 2026 10:04:05 +0200 Subject: [PATCH] [FIX] web_view_leaflet_map: reload markers on search domain change The map renderer only loaded its records on willStart, so applying a search filter or favorite never refreshed the markers (onPatched re-rendered the same, stale records). Add onWillUpdateProps to reload the records with the new domain/context; loadRecords now accepts an optional domain/context so the filtered result is fetched before onPatched re-renders the markers. --- web_view_leaflet_map/__manifest__.py | 2 +- .../views/leaflet_map/leaflet_map_renderer.esm.js | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) 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;