@@ -80,13 +80,30 @@ def match(self, context, domain, attrs, metas):
8080 conditions = context .values ["conditions" ]
8181 all_vars = attrs .copy ()
8282 all_vars .update (metas )
83- # Use this after 2022/2/2:
84- # if all(all_vars.get(name) == tpe for name, tpe, *_ in conditions):
85- if all (all_vars .get (name ) == tpe if len (rest ) == 2 else name in all_vars
86- for name , tpe , * rest in conditions ):
87- return 0.5
83+ matched = [all_vars .get (name ) == tpe
84+ # After 2022/2/2 remove this line:
85+ if len (rest ) == 2 else name in all_vars
86+ for name , tpe , * rest in conditions ]
87+ if any (matched ):
88+ return 0.5 * sum (matched ) / len (matched )
8889 return self .NO_MATCH
8990
91+ def filter_value (self , setting , data , domain , attrs , metas ):
92+ if setting .name != "conditions" :
93+ super ().filter_value (setting , data , domain , attrs , metas )
94+ return
95+
96+ all_vars = attrs .copy ()
97+ all_vars .update (metas )
98+ conditions = data ["conditions" ]
99+ # Use this after 2022/2/2: if any(all_vars.get(name) == tpe:
100+ # conditions[:] = [(name, tpe, *rest) for name, tpe, *rest in conditions
101+ # if all_vars.get(name) == tpe]
102+ conditions [:] = [
103+ (name , tpe , * rest ) for name , tpe , * rest in conditions
104+ if (all_vars .get (name ) == tpe if len (rest ) == 2
105+ else name in all_vars )]
106+
90107
91108class FilterDiscreteType (enum .Enum ):
92109 Equal = "Equal"
0 commit comments