Skip to content

Commit ffa1859

Browse files
mmahroussfda-odoo
authored andcommitted
[FIX] server: add args for get method on fields
1 parent d9520e0 commit ffa1859

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

server/src/core/python_arch_eval_hooks.rs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -851,27 +851,39 @@ impl PythonArchEvalHooks {
851851
}
852852

853853
fn _update_get_eval(odoo: &mut SyncOdoo, entry_point: &Rc<RefCell<EntryPoint>>, symbol: Rc<RefCell<Symbol>>, tree: Tree) {
854-
let get_sym = symbol.borrow().get_symbol(&(vec![], vec![Sy!("__get__")]), u32::MAX);
855-
if get_sym.is_empty() {
854+
let get_syms = symbol.borrow().get_symbol(&(vec![], vec![Sy!("__get__")]), u32::MAX);
855+
let Some(get_sym) = get_syms.last() else {
856856
return;
857-
}
858-
let return_sym = odoo.get_symbol(odoo.config.odoo_path.as_ref().unwrap(), &tree, u32::MAX);
859-
if return_sym.is_empty() {
857+
};
858+
let return_syms = odoo.get_symbol(odoo.config.odoo_path.as_ref().unwrap(), &tree, u32::MAX);
859+
let Some(return_sym) = return_syms.last() else {
860860
let file = symbol.borrow().get_file().clone();
861861
file.as_ref().unwrap().upgrade().unwrap().borrow_mut().not_found_paths_mut().push((BuildSteps::ARCH_EVAL, flatten_tree(&tree)));
862862
entry_point.borrow_mut().not_found_symbols.insert(symbol);
863863
return;
864-
}
865-
get_sym.last().unwrap().borrow_mut().set_evaluations(vec![Evaluation {
864+
};
865+
get_sym.borrow_mut().set_evaluations(vec![Evaluation {
866866
symbol: EvaluationSymbol::new_with_symbol(
867-
Rc::downgrade(return_sym.last().unwrap()),
867+
Rc::downgrade(return_sym),
868868
Some(true),
869869
HashMap::new(),
870870
Some(PythonArchEvalHooks::eval_get)
871871
),
872872
value: None,
873873
range: None
874874
}]);
875+
876+
let tree = if compare_semver(odoo.full_version.as_str(), "18.1.0") == Ordering::Less {
877+
(vec![Sy!("odoo"), Sy!("fields")], vec![Sy!("Field"), Sy!("__get__")])
878+
} else {
879+
(vec![Sy!("odoo"), Sy!("orm"), Sy!("fields")], vec![Sy!("Field"), Sy!("__get__")])
880+
};
881+
let Some(field_get) = odoo.get_symbol(odoo.config.odoo_path.as_ref().unwrap(), &tree, u32::MAX).first().cloned()
882+
else {
883+
return;
884+
};
885+
let field_get_borrowed = field_get.borrow();
886+
get_sym.borrow_mut().as_func_mut().args = field_get_borrowed.as_func().args.clone();
875887
}
876888
fn eval_relational_with_related(session: &mut SessionInfo, related_field: &ContextValue, context: &Context) -> Option<EvaluationSymbolPtr>{
877889
let Some(ContextValue::SYMBOL(class_sym_weak)) = context.get(&S!("field_parent")) else {return None};

server/src/core/symbols/function_symbol.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{constants::{BuildStatus, BuildSteps, OYarn, SymType}, core::{evaluat
99

1010
use super::{symbol::Symbol, symbol_mgr::{SectionRange, SymbolMgr}};
1111

12-
#[derive(Debug, PartialEq)]
12+
#[derive(Debug, PartialEq, Clone)]
1313
pub enum ArgumentType {
1414
POS_ONLY,
1515
ARG,
@@ -18,7 +18,7 @@ pub enum ArgumentType {
1818
KWORD_ONLY,
1919
}
2020

21-
#[derive(Debug)]
21+
#[derive(Debug, Clone)]
2222
pub struct Argument {
2323
pub symbol: Weak<RefCell<Symbol>>, //always a weak to a symbol of the function
2424
//other informations about arg

0 commit comments

Comments
 (0)