Reviewers: ,


Please review this at http://codereview.tryton.org/353002/

Affected files:
  M trytond/model/fields/property.py
  M trytond/model/modelsql.py


Index: trytond/model/fields/property.py
===================================================================

--- a/trytond/model/fields/property.py
+++ b/trytond/model/fields/property.py
@@ -119,11 +119,13 @@
                 break

         if not default \
-                or (clause[2] is False and clause[1] in ['=', '!=']) \
+                or ((clause[2] is False or clause[2] is None)
+                    and clause[1] in ['=', '!=']) \
or (clause[1] in ['not like', 'not ilike', 'not in', '!=']):
             operator = 'in'  # default operator
-            if ((clause[2] is False and clause[1] == '=')
-                    or (clause[2] is not False
+            if (((clause[2] is False or clause[2] is None)
+                        and clause[1] == '=')
+                    or ((clause[2] is not False and clause[2] is not None)
                         and clause[1] in [
                             'not like', 'not ilike', 'not in', '!='])):
                 operator = 'not in'
@@ -161,7 +163,8 @@
             operator = operator % '%%s'
             return ("(CAST(SPLIT_PART(value,',',2) AS %s) IN ("
+ ",".join((operator,) * len(clause[2])) + ")) ") % sql_type
-        elif clause[2] is False and clause[1] in ['=', '!=']:
+        elif ((clause[2] is False or clause[2] is None)
+                and clause[1] in ['=', '!=']):
             return "((cast(split_part(value,',',2) as %s) IS NULL " \
                 ") = %%s) " % sql_type
         elif clause[1] in ['not like', 'not ilike']:
@@ -179,6 +182,8 @@
         res = []
         if clause[1] in ('in', 'not in'):
             res.extend(clause[2])
+        elif clause[2] is None:
+            res.append(False)
         else:
             res.append(clause[2])
         return res

Index: trytond/model/modelsql.py
===================================================================

--- a/trytond/model/modelsql.py
+++ b/trytond/model/modelsql.py
@@ -1554,7 +1554,7 @@
domain[i] = ('id', 'not in', ids2 + _rec_get(ids2,
                                 table, domain[i][0]))
                 else:
-                    if isinstance(domain[i][2], bool):
+ if isinstance(domain[i][2], bool) or domain[i][2] is None:
                         relation_obj = pool.get(field.relation_name)
                         query1 = 'SELECT "' + field.origin + '" ' \
                                 'FROM "' + relation_obj._table + '" '\



--
[email protected] mailing list

Reply via email to