1- /** @odoo -module **/
21// Copyright 2025 Quartile (https://www.quartile.co)
32// License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
43
5- import { patch } from "@web/core/utils/patch" ;
64import { onMounted , onWillUnmount } from "@odoo/owl" ;
75import { FormController } from "@web/views/form/form_controller" ;
86import { Record } from "@web/model/relational_model/record" ;
7+ import { patch } from "@web/core/utils/patch" ;
98
109const recRoot = ( c ) => ( c && c . model && c . model . root ) || null ;
1110const childSpan = ( el ) => {
1211 try {
1312 return ( el && el . querySelector ( ":scope > span" ) ) || null ;
14- } catch { }
13+ } catch {
14+ // Ignore
15+ }
1516 const f = el && el . firstElementChild ;
1617 return f && f . tagName === "SPAN" ? f : null ;
1718} ;
@@ -22,22 +23,30 @@ const setHtml = (el, html) => {
2223const safe = async ( fn , fb ) => {
2324 try {
2425 return await fn ( ) ;
25- } catch { }
26+ } catch {
27+ // Ignore
28+ }
2629 return fb ;
2730} ;
2831
2932function normalizeValue ( v ) {
30- if ( v === null || v === undefined ) return v ; // Null/undefined
33+ // Null/undefined
34+ if ( v === null || v === undefined ) return v ;
3135 const t = typeof v ;
3236 if ( t === "string" || t === "number" || t === "boolean" ) return v ;
3337 if ( Array . isArray ( v ) )
34- return v . length === 2 && typeof v [ 1 ] === "string" ? v [ 0 ] : [ ...v ] ; // M2o id or cloned m2m ids
38+ // M2o id or cloned m2m ids
39+ return v . length === 2 && typeof v [ 1 ] === "string" ? v [ 0 ] : [ ...v ] ;
3540 if ( t === "object" ) {
36- if ( typeof v . res_id === "number" ) return v . res_id ; // M2o snapshot
37- if ( typeof v . id === "number" ) return v . id ; // M2o env
38- if ( Array . isArray ( v . _currentIds ) ) return [ ...v . _currentIds ] ; // M2m
41+ // M2o snapshot
42+ if ( typeof v . res_id === "number" ) return v . res_id ;
43+ // M2o env
44+ if ( typeof v . id === "number" ) return v . id ;
45+ // M2m
46+ if ( Array . isArray ( v . _currentIds ) ) return [ ...v . _currentIds ] ;
3947 }
40- return undefined ; // Ignore others (e.g., command lists)
48+ // Ignore others (e.g., command lists)
49+ return undefined ;
4150}
4251function shrink ( data ) {
4352 const out = { } ;
@@ -77,7 +86,7 @@ async function refreshBanners(ctrl, extraChanges) {
7786 if ( ! nodes . length ) return ;
7887 const snap = { ...shrink ( rec . data ) , ...shrink ( extraChanges ) } ;
7988 const names = triggerNames ( ctrl ) ;
80- const vals = ! rec . resId ? snap : names . length ? sliceBy ( snap , names ) : { } ;
89+ const vals = rec . resId ? ( names . length ? sliceBy ( snap , names ) : { } ) : snap ;
8190 const orm = ctrl . env . services . orm ;
8291 for ( const el of nodes ) {
8392 const ruleId = parseInt ( el . dataset . ruleId , 10 ) ;
@@ -98,7 +107,10 @@ async function refreshBanners(ctrl, extraChanges) {
98107function scheduleRefresh ( ctrl ) {
99108 if ( ctrl . __wfbSched ) return ;
100109 ctrl . __wfbSched = true ;
101- requestAnimationFrame ( ( ) => ( ( ctrl . __wfbSched = false ) , refreshBanners ( ctrl ) ) ) ;
110+ requestAnimationFrame ( ( ) => {
111+ ctrl . __wfbSched = false ;
112+ refreshBanners ( ctrl ) ;
113+ } ) ;
102114}
103115
104116function tick ( ctrl ) {
@@ -164,7 +176,9 @@ patch(Record.prototype, {
164176 const ctrl = this . model . __controller ;
165177 if ( ctrl ) tick ( ctrl ) ;
166178 }
167- } catch { }
179+ } catch {
180+ // Ignore
181+ }
168182 return res ;
169183 } ,
170184} ) ;
0 commit comments