0

以下是我需要做的

(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 具有更多条件的域过滤器

附加说明 我在 openerp 源代码中找不到带有 & 运算符的单个域过滤器。

我错过了什么吗?请建议。谢谢你的时间。

4

1 回答 1

4

错误消息表明您的 XML 包含无效的实体,即裸 &&字符。由于它是一个预定义的 XML 实体,您必须将其转义为&amp;.

&在 OpenERP 源代码中你可能找不到很多使用域的原因是因为AND (&)操作符是默认的,所以在大多数情况下你可以完全省略它。由于转义问题,这很方便。尽管如此,当您组合 OR/AND 运算符时可能还是需要它,因此您可以在高级安全规则中找到示例,这些规则也使用相同的域语法,例如此处

一般来说,如果你愿意(A and B) or C,你确实可以把它写成:

   ['|',C,'&',A,B]

这意味着您的 XML 文件应包含:

   ['|',C,'&amp;',A,B]
于 2013-10-16T09:40:21.537 回答