diff --git a/tryton/common/domain_parser.py b/tryton/common/domain_parser.py index 24e2eb8460..6006702303 100644 --- a/tryton/common/domain_parser.py +++ b/tryton/common/domain_parser.py @@ -117,12 +117,20 @@ def quote(value): "Quote string if needed" if not isinstance(value, basestring): return value + if '"' in value: + value = value.replace('"', '\\"') for test in (':', ' ', '(', ')') + OPERATORS: if test in value: return '"%s"' % value return value +def test_quote(): + assert quote('test') == 'test' + assert quote('foo bar') == '"foo bar"' + assert quote('"foo"') == '\\\"foo\\\"' + + def ending_clause(domain, deep=0): "Return the ending clause" if not domain: @@ -1284,6 +1292,9 @@ def test_group(): ('Name', '=', None), ('Name', None, 'Doe'), ] + assert rlist(dom.group(udlex(u'Name: \\"foo\\"'))) == [ + ('Name', None, '"foo"'), + ] def test_parse_clause():