@@ -398,27 +398,22 @@ impl PythonOdooBuilder {
398398 let base_model_syms = session. sync_odoo . get_symbol ( session. sync_odoo . config . odoo_path . as_ref ( ) . unwrap ( ) , & base_model_tree, u32:: MAX ) ;
399399 let model_syms = session. sync_odoo . get_symbol ( session. sync_odoo . config . odoo_path . as_ref ( ) . unwrap ( ) , & model_tree, u32:: MAX ) ;
400400 let transient_syms = session. sync_odoo . get_symbol ( session. sync_odoo . config . odoo_path . as_ref ( ) . unwrap ( ) , & transient_tree, u32:: MAX ) ;
401- if base_model_syms. is_empty ( ) || model_syms. is_empty ( ) || transient_syms. is_empty ( ) {
402- //one of them is not already loaded, but that's not really an issue, as now odoo step has been merged
403- //with arch eval step, some files will be odooed before loading the orm fully. In this case we should
404- //ignore this error. Moreover if a base is set on the class, it means that the base has been loaded, so
405- //it is NOT a model.
406- // session.send_notification(ShowMessage::METHOD, ShowMessageParams{
407- // typ: MessageType::ERROR,
408- // message: "Odoo base models are not found. OdooLS will be unable to generate valid diagnostics".to_string()
409- // });
401+ if base_model_syms. is_empty ( ) {
402+ // base_model_syms empty so sym cannot be a model, otherwise we would have found it earlier
410403 return false ;
411404 }
412- if Rc :: ptr_eq ( symbol, & base_model_syms[ 0 ] ) ||
413- Rc :: ptr_eq ( symbol, & model_syms[ 0 ] ) ||
414- Rc :: ptr_eq ( symbol, & transient_syms[ 0 ] )
405+ // Check if the symbol is exactly BaseModel, Model or TransientModel
406+ // BaseModel, Model, or TransientModel are abstract base classes, we don't want to mark them as models
407+ if Rc :: ptr_eq ( symbol, & base_model_syms[ 0 ] )
408+ || model_syms. first ( ) . is_some_and ( |first| Rc :: ptr_eq ( symbol, first) )
409+ || transient_syms. first ( ) . is_some_and ( |first| Rc :: ptr_eq ( symbol, first) )
415410 {
416411 return false ;
417412 }
418413 if compare_semver ( session. sync_odoo . full_version . as_str ( ) , "19.1" ) >= Ordering :: Equal {
419414 let cached_model_tree = ( vec ! [ Sy !( "odoo" ) , Sy !( "orm" ) , Sy !( "models_cached" ) ] , vec ! [ Sy !( "CachedModel" ) ] ) ;
420- let cached_model = session. sync_odoo . get_symbol ( session. sync_odoo . config . odoo_path . as_ref ( ) . unwrap ( ) , & cached_model_tree, u32:: MAX ) ;
421- if cached_model . is_empty ( ) | | Rc :: ptr_eq ( symbol, & cached_model [ 0 ] ) {
415+ let cached_model_syms = session. sync_odoo . get_symbol ( session. sync_odoo . config . odoo_path . as_ref ( ) . unwrap ( ) , & cached_model_tree, u32:: MAX ) ;
416+ if cached_model_syms . first ( ) . is_some_and ( |first | Rc :: ptr_eq ( symbol, first ) ) {
422417 return false ;
423418 }
424419
@@ -427,6 +422,7 @@ impl PythonOdooBuilder {
427422 return false ;
428423 }
429424 sym. as_class_sym_mut ( ) . _model = Some ( ModelData :: new ( ) ) ;
425+ // Check if we have a _register = False
430426 let register = sym. get_symbol ( & ( vec ! [ ] , vec ! [ Sy !( "_register" ) ] ) , u32:: MAX ) ;
431427 if let Some ( register) = register. last ( ) {
432428 let loc_register = register. borrow ( ) ;
0 commit comments