Fix child_of domain on empty MPTT

When the MPTT search returns no row, the SQL query generated has an invalid
syntax because it uses an empty Or() clause. We replace this empty Or() by a
Literal(False) to select nothing.

issue5011
review18651002
This commit is contained in:
Cédric Krier committed 2015-10-03 11:50:56 +02:00
1 parent 87f9fbea6e
commit f01f0d5871
1 file changed
+3 -1
+3 -1
View File
@@ -1,7 +1,7 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from types import NoneType
from sql import Query, Expression
from sql import Query, Expression, Literal
from sql.operators import Or
from .field import Field, SQLType
@@ -109,6 +109,8 @@ class Many2One(Field):
where = Or()
for l, r in cursor.fetchall():
where.append((left >= l) & (right <= r))
if not where:
where = Literal(False)
if operator == 'not child_of':
return ~where
return where