Skip to content

Commit 865c25a

Browse files
committed
[FIX] avoid exiting test_symbol_is_model if CachedModel is not there
1 parent acfde92 commit 865c25a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

server/src/core/python_odoo_builder.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ 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() {
401+
if base_model_syms.is_empty(){
402402
//one of them is not already loaded, but that's not really an issue, as now odoo step has been merged
403403
//with arch eval step, some files will be odooed before loading the orm fully. In this case we should
404404
//ignore this error. Moreover if a base is set on the class, it means that the base has been loaded, so
@@ -409,16 +409,16 @@ impl PythonOdooBuilder {
409409
// });
410410
return false;
411411
}
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])
412+
if base_model_syms.first().map_or(false, |first| Rc::ptr_eq(symbol, first))
413+
|| model_syms.first().map_or(false, |first| Rc::ptr_eq(symbol, first))
414+
|| transient_syms.first().map_or(false, |first| Rc::ptr_eq(symbol, first))
415415
{
416416
return false;
417417
}
418418
if compare_semver(session.sync_odoo.full_version.as_str(), "19.1") >= Ordering::Equal{
419419
let cached_model_tree = (vec![Sy!("odoo"), Sy!("orm"), Sy!("models_cached")], vec![Sy!("CachedModel")]);
420420
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]){
421+
if cached_model.first().map_or(false, |first| Rc::ptr_eq(symbol, first)){
422422
return false;
423423
}
424424

0 commit comments

Comments
 (0)