@@ -4,15 +4,16 @@ import { Domain } from "@web/core/domain";
44import { getDomainDisplayedOperators } from "@web/core/domain_selector/domain_selector_operator_editor" ;
55import { _t } from "@web/core/l10n/translation" ;
66import { ModelFieldSelector } from "@web/core/model_field_selector/model_field_selector" ;
7- import { condition , formatValue } from "@web/core/tree_editor/condition_tree" ;
8- import { constructTreeFromDomain } from "@web/core/tree_editor/construct_tree_from_domain" ;
7+ import {
8+ areEqualTrees ,
9+ condition ,
10+ connector ,
11+ formatValue ,
12+ } from "@web/core/tree_editor/condition_tree" ;
913import { domainFromTree } from "@web/core/tree_editor/domain_from_tree" ;
1014import { TreeEditor } from "@web/core/tree_editor/tree_editor" ;
1115import { getOperatorEditorInfo } from "@web/core/tree_editor/tree_editor_operator_editor" ;
12- import { treeFromDomain } from "@web/core/tree_editor/tree_from_domain" ;
13- import { useMakeGetFieldDef } from "@web/core/tree_editor/utils" ;
1416import { useService } from "@web/core/utils/hooks" ;
15- import { deepEqual } from "@web/core/utils/objects" ;
1617import { getDefaultCondition } from "./utils" ;
1718
1819const ARCHIVED_CONDITION = condition ( "active" , "in" , [ true , false ] ) ;
@@ -41,7 +42,7 @@ export class DomainSelector extends Component {
4142
4243 setup ( ) {
4344 this . fieldService = useService ( "field" ) ;
44- this . makeGetFieldDef = useMakeGetFieldDef ( this . fieldService ) ;
45+ this . treeProcessor = useService ( "tree_processor" ) ;
4546
4647 this . tree = null ;
4748 this . showArchivedCheckbox = false ;
@@ -66,23 +67,19 @@ export class DomainSelector extends Component {
6667 return ;
6768 }
6869
69- const getFieldDef = await this . makeGetFieldDef (
70- p . resModel ,
71- constructTreeFromDomain ( domain ) ,
72- [ "active" ]
73- ) ;
70+ const [ tree , { fieldDef : activeFieldDef } ] = await Promise . all ( [
71+ this . treeProcessor . treeFromDomain ( p . resModel , domain , ! p . isDebugMode ) ,
72+ this . fieldService . loadFieldInfo ( p . resModel , "active" ) ,
73+ ] ) ;
7474
75- this . tree = treeFromDomain ( domain , {
76- getFieldDef,
77- distributeNot : ! p . isDebugMode ,
78- } ) ;
75+ this . tree = tree ;
76+ this . showArchivedCheckbox = this . getShowArchivedCheckBox ( Boolean ( activeFieldDef ) , p ) ;
7977
80- this . showArchivedCheckbox = this . getShowArchivedCheckBox ( Boolean ( getFieldDef ( "active" ) ) , p ) ;
8178 this . includeArchived = false ;
8279 if ( this . showArchivedCheckbox ) {
8380 if ( this . tree . value === "&" ) {
8481 this . tree . children = this . tree . children . filter ( ( child ) => {
85- if ( deepEqual ( child , ARCHIVED_CONDITION ) ) {
82+ if ( areEqualTrees ( child , ARCHIVED_CONDITION ) ) {
8683 this . includeArchived = true ;
8784 return false ;
8885 }
@@ -91,9 +88,9 @@ export class DomainSelector extends Component {
9188 if ( this . tree . children . length === 1 ) {
9289 this . tree = this . tree . children [ 0 ] ;
9390 }
94- } else if ( deepEqual ( this . tree , ARCHIVED_CONDITION ) ) {
91+ } else if ( areEqualTrees ( this . tree , ARCHIVED_CONDITION ) ) {
9592 this . includeArchived = true ;
96- this . tree = treeFromDomain ( `[]` ) ;
93+ this . tree = connector ( "&" ) ;
9794 }
9895 }
9996 }
0 commit comments