Commit ef234da2 authored by Ayush Tiwari's avatar Ayush Tiwari

mixin/expression: Only create expression_instance for not None value of expression

In case of catalog methods where we have expression empty or None, trying to get
expression_instance raises an error. So, as to keep the compatibilty with how it
used to check for value of expression as shown in this diff :
nexedi/erp5@04f331a2
its better to check the same in mixin.
parent 220e0c37
......@@ -45,7 +45,13 @@ class ExpressionMixin:
try:
return self._v_expression_instance
except AttributeError:
result = Expression(self.getExpression())
expression = self.getExpression()
# Check if the expression is not None, because Expression(<expression>)
# raises an error in case `expression` is empty or None.
if expression:
result = Expression(expression)
else:
result = None
self._v_expression_instance = result
return result
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment