Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/371.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Odoo 理解OpenERP域过滤器?_Odoo - Fatal编程技术网

Odoo 理解OpenERP域过滤器?

Odoo 理解OpenERP域过滤器?,odoo,Odoo,我想问您是否可以解释Openerp域过滤器的结构。我必须把它用在我的项目上。 请解释以下域筛选器的说明 ['|',('order_id.user_id','=',user.id),('order_id.user_id','=',False)] 我想知道(order\u id.user\u id','=',user.id)的确切含义,什么是order\u id,user\u id,以及user.id。它们是否引用了任何表。如果是,那我怎么知道是哪一个 基本上,我想知道如何从下到上破译符号,以便根

我想问您是否可以解释Openerp域过滤器的结构。我必须把它用在我的项目上。 请解释以下域筛选器的说明

['|',('order_id.user_id','=',user.id),('order_id.user_id','=',False)]
我想知道
(order\u id.user\u id','=',user.id)
的确切含义,什么是
order\u id
user\u id
,以及
user.id
。它们是否引用了任何表。如果是,那我怎么知道是哪一个


基本上,我想知道如何从下到上破译符号,以便根据我的要求使用它。

这个“|”是一个OR,用于下一次比较。(…,'=',False)被转换为IS NULL,因此用于此的SQL将为

WHERE order_id.user_id = x OR order_id.user_id is NULL
默认值为,这就是为什么您没有在任何地方看到('&',('field1','=',1),('field2','=',2)

请注意,另一个有用的参数是('field1','!=',False),它被转换为其中field1不为NULL


关于这方面的文档并不多,而且它们在使用多个运算符时会变得相当棘手,因为您必须反向使用这些运算符来处理元组。我发现我很少使用复杂的元组,所以我只需在Postgres中打开查询日志,并使用反复试验的方法来观察生成的查询,直到正确为止

这个很简单

考虑以下字段(这里只提供XML,需要管理python)

在OpenERP域筛选器中,它将以这种方式编写

[('a','=',5)] # where a should be a field in the model and 5 will be the value
所以我们推导的语法是

('field_name', 'operator', value)
现在,让我们尝试应用另一个字段来代替静态值5

[('a','=',b)] # where a and b should be the fields in the model
在上面,您必须注意,第一个变量a用单引号括起来,而b的值不是。要比较的变量将始终是第一个,并用单引号括起来,值将只是字段名。但是,如果您要将变量a与值“b”进行比较,则不必这样做他在下面

[('a','=','b')] # where only a is the field name and b is the value (field b's value will not be taken for comparison in this case)
条件和

在编程中

if a = 5  # where a is the variable and 5 is the value
if a = 5 and b = 10
if a = 5 or b = 10
if a = 5 or (b != 10 and c = 12)
开放式ERP域过滤器

[('a','=',5),('b','=',10)]
['|',('a','=',5),('b','=',10)]
['|',('a','=',5),('&',('b','!=',10),('c','=',12))]
请注意,如果在开头未指定任何条件,则将应用条件。。如果要替换静态值,只需删除5并给出字段名(严格无引号

条件或

在编程中

if a = 5  # where a is the variable and 5 is the value
if a = 5 and b = 10
if a = 5 or b = 10
if a = 5 or (b != 10 and c = 12)
开放式ERP域过滤器

[('a','=',5),('b','=',10)]
['|',('a','=',5),('b','=',10)]
['|',('a','=',5),('&',('b','!=',10),('c','=',12))]
请注意,表示它是条件。如果要替换字段,只需删除5并给出字段名(严格不带引号

多个条件

[('a','=',c),('b','=',c)]
在编程中

if a = 5  # where a is the variable and 5 is the value
if a = 5 and b = 10
if a = 5 or b = 10
if a = 5 or (b != 10 and c = 12)
开放式ERP域过滤器

[('a','=',5),('b','=',10)]
['|',('a','=',5),('b','=',10)]
['|',('a','=',5),('&',('b','!=',10),('c','=',12))]

另外,来自Arya的这封邮件将对您大有帮助。干杯!!

嗨,Vivek,请分享您的电子邮件id。我将在这封邮件上向您发送我的模块。嗨,您将向我发送什么模块vivekjustthink@gmail.com是我的电子邮件id。我已向您发送了需要修复域筛选器的模块。谢谢您是否尝试过Multiple上的最后一个域条件?它不工作给出错误值错误:无效的叶['b','!=',10],'c','=','12']]请给出完整的筛选器,这是错误的“['b','!=',10],'c','=','12'].”。