search 视图
案例
<record id="lunch_product_report_view_search" model="ir.ui.view">
<field name="name">lunch.product.report.search</field>
<field name="model">lunch.product.report</field>
<field name="arch" type="xml">
<search string="Product Search">
<field name="name" string="Product"/>
<field name="category_id" string="Category"/>
<field name="supplier_id"/>
<field name="description"/>
<group expand="0" string="Group By">
<filter name="group_by_supplier" string="Vendor" context="{'group_by': 'supplier_id'}"/>
<filter name="group_by_category" string="Category" context="{'group_by': 'category_id'}"/>
</group>
<searchpanel>
<field name="category_id" select="multi" string="Categories" icon="fa-cutlery" color="#875A7B"/>
<field name="supplier_id" select="multi" string="Vendors" icon="fa-truck"/>
</searchpanel>
</search>
</field>
</record>
属性
- search属性
- < filter/ >是用户点击筛选后显示搜索的条件domain
- < group/>是用户点击分组后显示的分组条件
- 如果将多个过滤器放在同一组中并激活多个,那么它们的域将用 “ | ”操作符组合,而不在同一组中的过滤器和字段将与 “ & ” 操作符组合
- expand=0 :分组后不展开; expand=1 :分组后展开
- 分组的条件也是context中的key,如
context="{'group_by': 'supplier_id'},key即为supplier_id
- 指定案例视图为搜索视图:
<field name="search_view_id" ref="lunch_product_report_view_search" />
2.2 search panel属性
< searchpanel/>要放在< search/>标签内,field中的字段必须是 “多对一” 类型的
选择多个的属性:select=“multi”
<searchpanel>
<field name="category_id" select="multi" string="Categories" icon="fa-cutlery" color="#875A7B"/>
<field name="supplier_id" select="multi" string="Vendors" icon="fa-truck"/>
</searchpanel>