Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions server/src/core/python_odoo_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ use crate::{oyarn, Sy, S};

use super::evaluation::{ContextValue, Evaluation, EvaluationSymbolPtr, EvaluationValue};

pub const MAGIC_FIELDS: [&str; 6] = [
"id",
"display_name",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How possible would it be for display_name to go to any _compute_display_name methods associated with the model?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andg-odoo, Well, I think it is possible, it is a bit of a custom behavior though, but it has some sense to it. I shall discuss with @fda-odoo and see what we think about implementing that.
Thanks for the suggestion

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's indeed a good idea, I added it to our todolist :)

"create_uid",
"create_date",
"write_uid",
"write_date"
];

pub struct PythonOdooBuilder {
symbol: Rc<RefCell<Symbol>>,
}
Expand Down
15 changes: 15 additions & 0 deletions server/src/features/definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::constants::SymType;
use crate::core::evaluation::{Evaluation, EvaluationValue};
use crate::core::file_mgr::{FileInfo, FileMgr};
use crate::core::odoo::SyncOdoo;
use crate::core::python_odoo_builder::MAGIC_FIELDS;
use crate::core::symbols::symbol::Symbol;
use crate::features::ast_utils::AstUtils;
use crate::features::features_utils::FeaturesUtils;
Expand Down Expand Up @@ -161,6 +162,20 @@ impl DefinitionFeature {
}
let mut links = vec![];
let mut evaluations = analyse_ast_result.evaluations.clone();
// Filter out magic fields
evaluations.retain(|eval| {
// Filter out, variables, whose parents are a class, whose name is one of the magic fields, and have the same range as their parent
let eval_sym = eval.symbol.get_symbol(session, &mut None, &mut vec![], None);
let Some(eval_sym) = eval_sym.upgrade_weak() else { return true; };
if !MAGIC_FIELDS.contains(&eval_sym.borrow().name().as_str()) || eval_sym.borrow().typ() != SymType::VARIABLE || !eval_sym.borrow().is_field(session) {
return true;
}
let Some(parent_sym) = eval_sym.borrow().parent().and_then(|parent| parent.upgrade()) else { return true; };
if parent_sym.borrow().typ() != SymType::CLASS {
return true;
}
eval_sym.borrow().range() != parent_sym.borrow().range()
});
let mut index = 0;
while index < evaluations.len() {
let eval = evaluations[index].clone();
Expand Down