- Odoo 11 Development Essentials(Third Edition)
- Daniel Reis
- 322字
- 2021-08-27 19:32:44
Extending views
Forms, lists, and search views are defined using the arch XML structures. To extend views, we need a way to modify this XML. This means locating XML elements and then introducing modifications at those points.
The XML record for view inheritance is just like the one for regular views, but also using the inherit_id attribute, with a reference to the view to be extended.
As an example of this, we will extend the Partner view to make the todo_ids field visible, showing all the Tasks that person is involved in.
The first thing to do is to find the XML ID for the view to be extended. We can find that by looking up the view in the Settings app and the Technical | User Interface | Views menu. The XML ID for the Partner form is . While there, we should also find the XML element where we want to insert our changes. We will be adding the list of collaborators at the end of the right columns, after the Language field. We usually identify the element to use by its name attribute. In this case, we have <field name="lang" />.
We will add an XML file for the extensions made to the Partner views, views/res_partner_view.xml, with this content:
<?xml version="1.0"?>
<odoo>
<record id="my_inherited_view" model="ir.ui.view">
<field name="name">Add To-Dos to Partner Form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<field name="lang" position="after">
<field name="todo_ids" />
</field>
</field>
</record>
</odoo>
The inherit_id record field identifies the view to be extended by referring to its external identifier using the special ref attribute. External identifiers will be discussed in more detail in Chapter 5, Import, Export, and Module Data.
Usually, XPath is used to locate XML elements. Odoo also uses XPath for this, but it also has the simpler form we just used available. View extension and XPath are discussed further in Chapter 9, Backend Views - Design the User Interface.
The other view types, such as list and search views, also have an arch field and can be extended the same way as form views can.
- 善用圖表:一看就懂的商業(yè)數(shù)據(jù)表達(dá)術(shù)
- Excel函數(shù)與公式標(biāo)準(zhǔn)教程(實(shí)戰(zhàn)微課版)
- 新編Excel 2010從入門到精通
- 新手易學(xué):電腦辦公
- Word/Excel/PPT 商務(wù)辦公效率手冊(cè):從小白到辦公大神
- 對(duì)比Excel,輕松學(xué)習(xí)Python報(bào)表自動(dòng)化
- Excel高效辦公:公司表格設(shè)計(jì)(修訂版)
- Excel 2010基礎(chǔ)入門與辦公應(yīng)用
- Excel函數(shù)與公式應(yīng)用技巧
- Mastering Office 365 Administration
- Office 2013應(yīng)用技巧實(shí)例大全
- 電腦辦公實(shí)戰(zhàn)從入門到精通(超值版)
- PowerPoint 2016從入門到精通
- 中老年人學(xué)用智能手機(jī)
- Office 2010辦公高級(jí)應(yīng)用(慕課版)