- Odoo 11 Development Essentials(Third Edition)
- Daniel Reis
- 220字
- 2021-08-27 19:32:44
Adding list and search views
When viewing a model in list mode, a <tree> view is used. Tree views are capable of displaying lines organized in hierarchies, but most of the time they are used to display plain lists.
We can add the following <tree> view definition to todo_view.xml:
<record id="view_tree_todo_task" model="ir.ui.view"> <field name="name">To-do Task Tree</field> <field name="model">todo.task</field> <field name="arch" type="xml"> <tree colors="decoration-muted:is_done==True"> <field name="name"/> <field name="is_done"/> </tree> </field> </record>
This defines a list with only two columns: name and is_done. We also added a nice touch: the lines for done tasks (is_done==True) are shown as grayed out. This is done by applying the muted Bootstrap class. Check http://getbootstrap.com/docs/3.3/css/#helper-classes-colors for more information on Bootstrap and its contextual colors.
At the top-right corner of the list, Odoo displays a search box. The fields it searches in and the available filters are defined by a <search> view.
As before, we will add this to todo_view.xml:
<record id="view_filter_todo_task" model="ir.ui.view"> <field name="name">To-do Task Filter</field> <field name="model">todo.task</field> <field name="arch" type="xml"> <search> <field name="user_id"/> <filter string="Not Done" domain="[('is_done','=',False)]"/> <filter string="Done" domain="[('is_done','!=',False)]"/> </search> </field> </record>
The <field> elements define fields that are also searched when typing in the search box. We added user_id to automatically suggest searching in the Responsible field. The <filter> elements add predefined filter conditions, which can be toggled with a user click, defined using a specific syntax. This will be addressed in more detail in Chapter 9, Backend Views - Design the User Interface.
- Linux操作系統(tǒng)與服務(wù)配置
- Word/Excel/PPT 2021辦公應(yīng)用從入門到精通
- Android網(wǎng)上班級管理實例:“我的班班”APP平臺建設(shè)
- Office 2019高效辦公三合一從入門到精通(視頻自學(xué)版)
- 辦公自動化軟件
- OpenCV Computer Vision Application Programming Cookbook Second Edition
- 非常Easy:Office高效辦公
- Excel 2016數(shù)據(jù)透視表從入門到精通
- 現(xiàn)用現(xiàn)查:電腦BIOS/注冊表設(shè)置實戰(zhàn)秘籍
- 金融精英Word實操手冊:世界知名公司這樣制作研究報告
- 電腦辦公從入門到精通
- 魔法數(shù)學(xué)(第1季)
- Word 2010辦公應(yīng)用實戰(zhàn)從入門到精通
- Premiere視頻編輯立體化教程:Premiere Pro 2021(微課版)
- Word/Excel/PPT 2016完全自學(xué)教程