Odoo 域错误中的多个条件

Odoo multiple condition in domain error

我正在尝试做条件: A 或(B 和 C)

我的代码:

<field name="x" attrs="{'readonly': ['|',('state','!=', 'ok'), (('state', '=', 'fine'), ('participate_process', '=', False))]}" >

我从 web 得到 js 错误:

Error: unknown field state,=,to_approve_second domain ["|",["state","!=","ok"],[["state","=","fine"],["participate_process","=",false]]]

我也在尝试另一种方式:

<field name="x" attrs="{'readonly': ['|', '&amp;', ('state','!=', 'ok'), ('state', '=', 'fine'), ('participate_process', '=', False)]}" >

但是没用..

这些多域有什么问题?

我找到了决定:

<field name="x" attrs="{'readonly': [('participate_process', '=', False), ('state', '=', 'fine'), '|', ('state','!=', 'ok')]}" >

应该是:

<field name="x" attrs="{'readonly': ['|', ('state', '=', 'ok'), '&amp;', ('state', '=', 'fine'), ('participate_process','=', False)]}" >

你也应该这样写,

<field name="x" attrs="{'readonly': [('participate_process', '=', False), '|', ('state', '=', 'fine'), ('state','!=', 'ok')]}" >

会转换成这样

Where participate_process = False and 
(state = 'fine' or state != 'ok')

你好 fueggit,

OpenERP 使用波兰语表示域过滤器。

首先你应该明白什么是波兰语。您可以在维基百科中找到有关波兰表示法的详细信息。 http://en.wikipedia.org/wiki/Polish_notation

关于你的问题

( A OR B ) AND ( C OR D OR E )

应该转换为波兰语表示法

AND OR A B OR OR C D E

并且应该用以下顺序的算法来解决[]表示操作

AND [OR A B] OR OR C D E         Result of [OR A B] is F

AND F OR [OR C D] E              Result of [OR C D] is G

AND F [OR G E]                   Result of [OR G E] is H

[AND F H]

开始到

"If another operator is found before two operands are found, then the old operator is placed aside until this new operator is resolved. This process iterates until an operator is resolved, which must happen eventually, as there must be one more operand than there are operators in a complete statement." 来自维基百科文章。

您也可以使用 in 运算符,而不用像

那样用 OR 运算符编写三个单独的元组
['&',('field2', 'in', ['A', 'B']),('state', 'in', ['open', 'closed', 'draft'])]

解决方案

    <field name="x" attrs="{'readonly': [('participate_process', '=', False),'|',('state','!=', 'ok'),('state', '=', 'fine')]}" >  

<field name="x" attrs="{'readonly': ['&',('participate_process', '=', False),'|',('state','!=', 'ok'),('state', '=', 'fine')]}" >  

希望我的回答对您有所帮助。
如果有任何疑问,请评论。