@@ -7,7 +7,7 @@ use std::path::PathBuf;
77use lsp_types:: { Diagnostic , Position , Range } ;
88use crate :: core:: diagnostics:: { create_diagnostic, DiagnosticCode } ;
99use crate :: core:: evaluation:: ContextValue ;
10- use crate :: { constants:: * , Sy } ;
10+ use crate :: { constants:: * , oyarn , Sy } ;
1111use crate :: core:: symbols:: symbol:: Symbol ;
1212use crate :: core:: odoo:: SyncOdoo ;
1313use crate :: core:: symbols:: module_symbol:: ModuleSymbol ;
@@ -538,6 +538,45 @@ impl PythonValidator {
538538
539539 }
540540 }
541+ if let Some ( inverse_name) = eval_weak. as_weak ( ) . context . get ( & S ! ( "inverse_name" ) ) . map ( |ctx_val| ctx_val. as_string ( ) ) {
542+ let Some ( model_name) = eval_weak. as_weak ( ) . context . get ( & S ! ( "comodel_name" ) ) . map ( |ctx_val| ctx_val. as_string ( ) ) else {
543+ continue ;
544+ } ;
545+ let Some ( model) = session. sync_odoo . models . get ( & oyarn ! ( "{}" , model_name) ) . cloned ( ) else {
546+ continue ;
547+ } ;
548+ let Some ( module) = class_ref. find_module ( ) else {
549+ continue ;
550+ } ;
551+ let main_syms = model. borrow ( ) . get_main_symbols ( session, Some ( module. clone ( ) ) ) ;
552+ let symbols: Vec < _ > = main_syms. iter ( ) . flat_map ( |main_sym|
553+ main_sym. clone ( ) . borrow ( ) . get_member_symbol ( session, & inverse_name, Some ( module. clone ( ) ) , false , true , false , true , false ) . 0
554+ ) . collect ( ) ;
555+ let method_found = !symbols. is_empty ( ) ;
556+ if !method_found{
557+ let Some ( arg_range) = eval_weak. as_weak ( ) . context . get ( & format ! ( "inverse_name_arg_range" ) ) . map ( |ctx_val| ctx_val. as_text_range ( ) ) else {
558+ continue ;
559+ } ;
560+ if let Some ( diagnostic_base) = create_diagnostic ( & session, DiagnosticCode :: OLS03021 , & [ & inverse_name, & model_name] ) {
561+ self . diagnostics . push ( Diagnostic {
562+ range : Range :: new ( Position :: new ( arg_range. start ( ) . to_u32 ( ) , 0 ) , Position :: new ( arg_range. end ( ) . to_u32 ( ) , 0 ) ) ,
563+ ..diagnostic_base. clone ( )
564+ } ) ;
565+ }
566+ }
567+ if symbols. iter ( ) . any ( |sym| !sym. borrow ( ) . is_specific_field ( session, & [ "Many2one" ] ) ) {
568+ let Some ( arg_range) = eval_weak. as_weak ( ) . context . get ( & format ! ( "inverse_name_arg_range" ) ) . map ( |ctx_val| ctx_val. as_text_range ( ) ) else {
569+ continue ;
570+ } ;
571+ if let Some ( diagnostic_base) = create_diagnostic ( & session, DiagnosticCode :: OLS03022 , & [ ] ) {
572+ self . diagnostics . push ( Diagnostic {
573+ range : Range :: new ( Position :: new ( arg_range. start ( ) . to_u32 ( ) , 0 ) , Position :: new ( arg_range. end ( ) . to_u32 ( ) , 0 ) ) ,
574+ ..diagnostic_base. clone ( )
575+ } ) ;
576+ }
577+
578+ }
579+ }
541580 }
542581 }
543582 }
0 commit comments