doamin filter conditions

doamin filter conditions

In odoo, the filtered data to record by using the domain

domain is a list, there are a plurality of conditions

With the proviso that an ancestral 3 elements ('字段名','比较操作符','值')

  • Field name

Current field model or by operator access point to the current model Many2one / Many2Many objects. If the left is Many2Many when the object, then left any value as long as the qualifying matches.

  • Comparison operators

Operators meaning
= equal
!= not equal to
>= greater or equal to
> more than the
<= Less than or equal
like Fuzzy query
ilike Ignore case, fuzzy queries
not like Fuzzy mismatch
in Included
not in Does not contain
child_of It determines whether the value is a subset of

 

Variable screening, the operator must be able to compare and fields.

For example, you want to filter out products for the type of service and the price is greater than 1000 products

= Domain [( 'product_type', '=', '-Service'), ( 'the unit_price', '>', 1000)] Domain acts on a model with model.search (domain)

The default domain and is connected to the above two conditions that is equal to the expression domain [ '&', ( 'product_type', '=', 'service'), ( 'unit_price', '>', 1000 )], and expressed by & (logical operator), in front of which the operator of the expression is called Polish notation

 

  • Logical Operators

    • & (AND) connected to two operands

    • | (OR) connected to two operands

    • ! (The NOT) connected to an operand

[ '|' '!', ( 'product_type', '=', 'service'),, '&', ( 'unit_price', '> =', 1000), ( 'unit_price', '<', 2000 )] readings, look at all of the conditions behind the last logical operators as operands become [ '|', ( 'product_type ', '=', 'service'),, cond] same rules [ '!' | ', (' product_type ', ' = ',' service '), cond]

Another use is in the domain of the associated field, can be defined in model.py field or in the field xml view, the filter field record associated

 

Guess you like

Origin www.cnblogs.com/itelephant/p/11819150.html