Filter in openerp

How to filter a lot of field in openerp.

_columns = { 'hello': fields.selection([('1','one'),('2','two')],'hello'), 'product_id': fields.many2one('product.product', 'Product', domain=[('type','=',hello)])' ... } 

If product.product is supposed to have a field called a type, which is also a choice, and its value is the same as hello, does it work in xml or python?

0
source share
4 answers

you can try the domain fields.many2one attribute as shown below

'product_id': fields.many2one('product.product', 'Product', domain=[('purchase_ok','=',True)], change_default=True),

alternative way -> you can provide the domain in XML form, as shown below,

<field name="product_id" domain="[('purchase_ok','=',True)]"/>

+8
source

You need to specify the domain in the view file that you want to filter for several fields. E.g. if you want to filter suppliers from the list of customers, just give the following in the view.

 :domain="[('supplier','=',True)]" 
+1
source

Try the context or domain options described in the developers book . I have not used them, but you can probably find examples in the main modules. The best description of the domain syntax is in the orm.search() method .

0
source

I think you want to filter product.product according to the hello fields on the right. therefore, write the onchange method on hello, filed in xml and in the method, filter out the product identifier whose type corresponds to the hello filed request.

In function / method u, you can add all identifiers, whose type corresponds to the value hello filed, in the list and after returning this list to product_id.

0
source

Source: https://habr.com/ru/post/1383861/


All Articles