@@ -8,6 +8,7 @@ use crate::constants::SymType;
88use crate :: core:: evaluation:: { Evaluation , EvaluationValue } ;
99use crate :: core:: file_mgr:: { FileInfo , FileMgr } ;
1010use crate :: core:: odoo:: SyncOdoo ;
11+ use crate :: core:: python_odoo_builder:: MAGIC_FIELDS ;
1112use crate :: core:: symbols:: symbol:: Symbol ;
1213use crate :: features:: ast_utils:: AstUtils ;
1314use crate :: features:: features_utils:: FeaturesUtils ;
@@ -161,6 +162,20 @@ impl DefinitionFeature {
161162 }
162163 let mut links = vec ! [ ] ;
163164 let mut evaluations = analyse_ast_result. evaluations . clone ( ) ;
165+ // Filter out magic fields
166+ evaluations. retain ( |eval| {
167+ // Filter out, variables, whose parents are a class, whose name is one of the magic fields, and have the same range as their parent
168+ let eval_sym = eval. symbol . get_symbol ( session, & mut None , & mut vec ! [ ] , None ) ;
169+ let Some ( eval_sym) = eval_sym. upgrade_weak ( ) else { return true ; } ;
170+ if !MAGIC_FIELDS . contains ( & eval_sym. borrow ( ) . name ( ) . as_str ( ) ) || eval_sym. borrow ( ) . typ ( ) != SymType :: VARIABLE || !eval_sym. borrow ( ) . is_field ( session) {
171+ return true ;
172+ }
173+ let Some ( parent_sym) = eval_sym. borrow ( ) . parent ( ) . and_then ( |parent| parent. upgrade ( ) ) else { return true ; } ;
174+ if parent_sym. borrow ( ) . typ ( ) != SymType :: CLASS {
175+ return true ;
176+ }
177+ eval_sym. borrow ( ) . range ( ) != parent_sym. borrow ( ) . range ( )
178+ } ) ;
164179 let mut index = 0 ;
165180 while index < evaluations. len ( ) {
166181 let eval = evaluations[ index] . clone ( ) ;
0 commit comments