diff --git a/server/src/core/diagnostic_codes_list.rs b/server/src/core/diagnostic_codes_list.rs index 8b45d703..c9cfec03 100644 --- a/server/src/core/diagnostic_codes_list.rs +++ b/server/src/core/diagnostic_codes_list.rs @@ -172,6 +172,10 @@ OLS03022, DiagnosticSetting::Error, "Inverse field is not a Many2one field", * -> current_model is not right */ OLS03023, DiagnosticSetting::Error, "Inverse field {0} is not pointing to the current model {1}, but rather to {2}", +/** + * Models declared in a function are not supported by OdooLS. This info is indicating that no features will be enabled for this model. + */ +OLS03024, DiagnosticSetting::Info, "Models declared in a function are not supported by OdooLS. OdooLS will use it as a normal class for the rest of the function only", /** * Form is no longer available on odoo.tests.common, thus it should not be imported from there. */ diff --git a/server/src/core/python_arch_eval.rs b/server/src/core/python_arch_eval.rs index b1e35339..3015cff1 100644 --- a/server/src/core/python_arch_eval.rs +++ b/server/src/core/python_arch_eval.rs @@ -711,8 +711,17 @@ impl PythonArchEval { self.visit_sub_stmts(session, &class_stmt.body); self.sym_stack.pop(); if !self.sym_stack[0].borrow().is_external() && self.sym_stack[0].borrow().get_entry().is_some_and(|e| e.borrow().typ == EntryPointType::MAIN) { - let odoo_builder_diags = PythonOdooBuilder::new(class_sym_rc).load(session); - self.diagnostics.extend(odoo_builder_diags); + if class_sym_rc.borrow().get_in_parents(&vec![SymType::FUNCTION], true).is_some() { + if let Some(diagnostic) = create_diagnostic(&session, DiagnosticCode::OLS03024, &[]) { + self.diagnostics.push(Diagnostic { + range: FileMgr::textRange_to_temporary_Range(&class_stmt.name.range), + ..diagnostic + }); + } + } else { + let odoo_builder_diags = PythonOdooBuilder::new(class_sym_rc).load(session); + self.diagnostics.extend(odoo_builder_diags); + } } session.current_noqa = old_noqa; }