@@ -236,10 +236,23 @@ def _exec_exists(self, p: ExistsThrough) -> list[int]:
236236 dom = self ._and_domains (dom , mem_dom )
237237 if child_subplan is not None :
238238 child_domain , requires_exec_child = self ._plan_to_domain (p .child_model , child_subplan )
239+ try :
240+ self ._logger .info (
241+ "[CEL EXISTS] child_subplan model=%s plan=%s requires_exec=%s" ,
242+ getattr (child_subplan , "model" , None ),
243+ getattr (child_subplan , "domain" , None ),
244+ requires_exec_child ,
245+ )
246+ except Exception :
247+ pass
239248 if requires_exec_child :
240249 child_ids = self ._execute_plan (p .child_model , child_subplan )
241250 else :
242251 child_domain = self ._ensure_domain_list (child_domain )
252+ try :
253+ self ._logger .info ("[CEL EXISTS] applying child domain=%s on model=%s" , child_domain , p .child_model )
254+ except Exception :
255+ pass
243256 child_ids = self .env [p .child_model ].search (child_domain ).ids
244257 child_ids = [int (i ) for i in child_ids if i ]
245258 if not child_ids :
@@ -302,8 +315,28 @@ def _exec_count(self, p: CountThrough) -> list[int]: # noqa: C901
302315 child_ids = self ._execute_plan (p .child_model , child_subplan )
303316 else :
304317 child_domain = self ._ensure_domain_list (child_domain )
318+ try :
319+ self ._logger .info ("[CEL EXISTS] applying child domain=%s on model=%s" , child_domain , p .child_model )
320+ except Exception :
321+ pass
305322 child_ids = self .env [p .child_model ].search (child_domain ).ids
306323 child_ids = [int (i ) for i in child_ids if i ]
324+ try :
325+ sample_labels = []
326+ if child_ids :
327+ records = self .env [p .child_model ].browse (child_ids [:5 ])
328+ sample_labels = [
329+ getattr (rec , "name" , None ) or getattr (rec , "display_name" , None ) for rec in records
330+ ]
331+ self ._logger .info (
332+ "[CEL EXISTS] child filter results child_model=%s domain=%s ids=%s sample=%s" ,
333+ p .child_model ,
334+ child_domain ,
335+ child_ids [:10 ],
336+ sample_labels ,
337+ )
338+ except Exception :
339+ pass
307340 if not child_ids :
308341 # No matching children; counts are zero for all candidate parents
309342 if not candidate_parents and parent_model_name :
@@ -386,7 +419,7 @@ def _exec_metric(self, model: str, p: MetricCompare, metrics_info: list[dict[str
386419 # Resolve flags
387420 ICP = self .env ["ir.config_parameter" ].sudo ()
388421 enable_sql = bool (int (ICP .get_param ("cel.enable_sql_metrics" , "1" )))
389- preview_cache_only = bool (int (ICP .get_param ("cel.preview_cache_only" , "1 " )))
422+ preview_cache_only = bool (int (ICP .get_param ("cel.preview_cache_only" , "0 " )))
390423 async_threshold = int (ICP .get_param ("cel.async_threshold" , "50000" ) or 50000 )
391424 allow_any_provider = self ._allow_any_provider_fallback ()
392425 # Provider resolution
@@ -483,12 +516,17 @@ def _exec_metric(self, model: str, p: MetricCompare, metrics_info: list[dict[str
483516 if total_requested :
484517 stats_total ["requested" ] = total_requested
485518 stats_total ["coverage" ] = len (aggregated_values ) / float (base_count or 1 )
519+ incomplete_cache = eval_mode == "cache_only" and total_requested and len (aggregated_values ) < total_requested
486520 if eval_mode == "cache_only" :
487521 path_flag = "cache_only"
488522 else :
489523 path_flag = "python" if status .get ("status" ) != "fresh" else "cache"
524+ stats_total .update ({"path" : path_flag })
525+ if incomplete_cache :
526+ if metrics_info is not None :
527+ metrics_info .append (stats_total )
528+ return []
490529 if metrics_info is not None :
491- stats_total .update ({"path" : path_flag })
492530 metrics_info .append (stats_total )
493531 res = []
494532 for sid , val in aggregated_values .items ():
@@ -498,7 +536,7 @@ def _exec_metric(self, model: str, p: MetricCompare, metrics_info: list[dict[str
498536 return res
499537
500538 def _metric_registry_info (self , metric : str ) -> tuple [str , str ]:
501- info = self .env ["openspp.metric .registry" ].get (metric ) or {}
539+ info = self .env ["openspp.indicator .registry" ].get (metric ) or {}
502540 provider = info .get ("provider" ) or metric
503541 return_type = info .get ("return_type" ) or "json"
504542 return provider , return_type
0 commit comments