Ini hal kecil yang baru saya sadari malam ini...
Awalnya Filter di OE 7.0 ini hanya bisa pakai OR...
tapi ternyata bisa pakai AND...
dan trick nya benar2 simple,
hanya menambahkan separator -__'-
Contoh:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<record id="product_search_form_view" model="ir.ui.view"> | |
<field name="name">product.search.form</field> | |
<field name="model">product.product</field> | |
<field name="arch" type="xml"> | |
<search string="Product"> | |
<field name="name" string="Product" filter_domain="['|',('name','ilike',self),('default_code','ilike',self)]"/> | |
<filter string="Services" icon="terp-accessories-archiver" domain="[('type','=','service')]"/> | |
<filter string="Consumable" name="consumable" icon="terp-accessories-archiver" domain="[('type','=','consu')]" help="Consumable products"/> | |
<separator/> | |
<filter string="Can be Sold" name="filter_to_sell" icon="terp-accessories-archiver-minus" domain="[('sale_ok','=',1)]"/> | |
<field name="categ_id"/> | |
<group expand="0" string="Context..."> | |
<field name="pricelist_id" widget="selection" context="{'pricelist': self}" filter_domain="[]" groups="product.group_sale_pricelist"/> <!-- Keep widget=selection on this field to pass numeric `self` value, which is not the case for regular m2o widgets! --> | |
<field name="company_id" groups="base.group_multi_company"/> | |
</group> | |
<group expand='0' string='Group by...'> | |
<filter string='Category' icon="terp-stock_symbol-selection" domain="[]" context="{'group_by' : 'categ_id'}"/> | |
<filter string='Default Unit of Measure' icon="terp-mrp" domain="[]" context="{'group_by' : 'uom_id'}"/> | |
<filter string='Type' icon="terp-stock_symbol-selection" domain="[]" context="{'group_by' : 'type'}"/> | |
<filter string='Company' icon="terp-go-home" domain="[]" context="{'group_by' : 'company_id'}" groups="base.group_multi_company"/> | |
</group> | |
</search> | |
</field> | |
</record> |
Nah cek bagian
<filter string="Services" icon="terp-accessories-archiver" domain="[('type','=','service')]"/>
<filter string="Consumable" name="consumable" icon="terp-accessories-archiver" domain="[('type','=','consu')]" help="Consumable products"/>
<separator/>
<filter string="Can be Sold" name="filter_to_sell" icon="terp-accessories-archiver-minus" domain="[('sale_ok','=',1)]"/>
Filter di atas menunjukan filter
untuk (Services OR Consumable) AND Can Be Sold
Jadi, hanya dengan menambahkan <separator/>
menjadikan query filter dengan clause AND...
Contoh gambar berikut, ada 3 AND condition
Jadi kira2 begini:
(Services OR Products OR Consumable) AND (To Purchase OR Can be SOld OR Can be Purchased) AND Available.
Kalau OR Filter nya dempet seperti Can be Sold OR To Purchase,
Sedangkan AND Filter nya dipisah..
Kira-kira begitu...
Selamat mencoba...
CMIIW