以下是我需要做的事情
(Condition A and Condition B) or Condition C
(partner_id = partner_id **and** user_ids = context.get(uid)) **or** userid = 1
我尝试过的可能的域名过滤器是
domain="['|',('user_ids','=',1),'&',('partner_id','=',partner_id),('user_ids','=',context.get('uid'))]"
domain="['|','&',('partner_id','=',partner_id),('user_ids','=',context.get('uid')),('user_ids','=',1)]"
没有任何结果,我得到的错误在
之下 File "D:\workspace\Techtalk\openerp\modules\loading.py", line 76, in <lambda>
load_data = lambda *args: _load_data(cr, *args, kind='data')
File "D:\workspace\Techtalk\openerp\modules\loading.py", line 124, in _load_data
tools.convert_xml_import(cr, module_name, fp, idref, mode, noupdate, report)
File "D:\workspace\Techtalk\openerp\tools\convert.py", line 941, in convert_xml_import
doc = etree.parse(xmlfile)
File "lxml.etree.pyx", line 2698, in lxml.etree.parse (src/lxml/lxml.etree.c:49590)
File "parser.pxi", line 1513, in lxml.etree._parseDocument (src/lxml/lxml.etree.c:71423)
File "parser.pxi", line 1543, in lxml.etree._parseFilelikeDocument (src/lxml/lxml.etree.c:71733)
File "parser.pxi", line 1426, in lxml.etree._parseDocFromFilelike (src/lxml/lxml.etree.c:70648)
File "parser.pxi", line 997, in lxml.etree._BaseParser._parseDocFromFilelike (src/lxml/lxml.etree.c:67944)
File "parser.pxi", line 539, in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/lxml.etree.c:63820)
File "parser.pxi", line 625, in lxml.etree._handleParseResult (src/lxml/lxml.etree.c:64741)
File "parser.pxi", line 565, in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:64084)
XMLSyntaxError: xmlParseEntityRef: no name, line 144, column 12
我提到的链接是
http://help.openerp.com/question/2170/domain-notation-using-multiple-and-nested-and/
OpenERP ver 7 Domain filter with more conditions
附加说明 我找不到一个带有&amp;的单域过滤器openerp source中的操作符。
我错过了什么吗?请建议。谢谢你的时间。
答案 0 :(得分:4)
错误消息表明您的XML包含无效实体,即裸露的&符号&
字符。由于它是预定义的XML实体,因此必须将其作为&
转义。
您在OpenERP源代码中找不到使用&
的域名的原因是因为AND (&)
运算符是默认运算符,因此在大多数情况下您可以完全省略它。由于逃避问题,这很方便。
但是,当您组合OR / AND运算符时,可能需要这样做,因此您可以在高级安全规则中找到示例,这些规则也使用相同的域语法,例如here。
一般情况下,如果你想要(A and B) or C
,你可以把它写成:
['|',C,'&',A,B]
表示您的XML文件应包含:
['|',C,'&',A,B]