了解OpenERP域过滤器? [英] Understanding OpenERP Domain Filter?

查看:83
本文介绍了了解OpenERP域过滤器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问你是否可以解释Openerp域过滤器的结构.我必须在我的项目中使用它. 请说明以下域过滤器的说明.

I would like to ask you if you could please explain the anatomy of the Openerp domain filters. I have to use it my project. Please explain the description of the following domain filter.

['|',('order_id.user_id','=',user.id),('order_id.user_id','=',False)]

我想知道(order_id.user_id','=',user.id)的确切含义,什么是order_iduser_iduser.id.他们引用任何表吗?如果是,那我应该怎么知道那个...

I want to know the exact meaning of (order_id.user_id','=',user.id), what is order_id, user_id, and user.id. Are they referencing any table. If yes then how am I supposed to know which one...

基本上,我想从下至上理解该符号,以便可以按照我的要求使用它.

Basically I want to know decipher the notation from bottom up so that can use it as per my requirement.

推荐答案

这很简单.

请考虑以下字段(这里仅提供XML,您需要管理的python)

Consider the following fields (only XML i've given here, python you got to manage)

<field name="a"/>
<field name="b"/>
<field name="c"/>

单一条件

考虑一些简单的编程条件

Consider some simple conditions in programming

if a = 5  # where a is the variable and 5 is the value

在Open ERP域过滤器中,将以这种方式编写

In Open ERP domain filter it would be written this way

[('a','=',5)] # where a should be a field in the model and 5 will be the value

所以我们得出的语法是

('field_name', 'operator', value)

现在让我们尝试应用另一个字段代替静态值5

Now let's try to apply another field in place of static value 5

[('a','=',b)] # where a and b should be the fields in the model

在上面,您必须注意,第一个变量 a用单引号引起来,而值 b则没有.要比较的变量将始终是第一个变量,并用单引号引起来,并且该值仅是字段名称.但是,如果要将变量a与值"b"进行比较,则必须执行以下操作

In the above you've to note that first variable a is enclosed with single quotes whereas the value b is not. The variable to be compared will be always first and will be enclosed with single quotes and the value will be just the field name. But if you want to compare variable a with the value 'b' you've to do the below

[('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 and b = 10

在Open ERP域过滤器中

In Open ERP domain filter

[('a','=',5),('b','=',10)]

请注意,如果您未在开头指定任何条件,则将应用条件.如果要替换静态值,只需删除5并指定字段名称(严格不带引号)

Note that if you don't specify any condition at the beginning and condition will be applied. If you want to replace static values you can simply remove the 5 and give the field name (strictly without quotes)

[('a','=',c),('b','=',c)]

条件或

在编程中

if a = 5 or b = 10

在Open ERP域过滤器中

In Open ERP domain filter

['|',('a','=',5),('b','=',10)]

请注意,表示其处于条件.如果要替换字段,只需删除5并指定字段名称(严格不带引号)

Note that the , indicates that it's and condition. If you want to replace fields you can simply remove the 5 and give the field name (strictly without quotes)

多种条件

在编程中

if a = 5 or (b != 10 and c = 12)

在Open ERP域过滤器中

In Open ERP domain filter

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

另外,来自Arya的帖子将对您有很大帮助.干杯!

Also this post from Arya will be greatly helpful to you. Cheers!!

这篇关于了解OpenERP域过滤器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆