视图¶
Views are the interface that allows displaying the data contained in a model. One model can have several views, which are simply different ways to show the same data. In Studio, views are organized into four categories: general, multiple records, timeline, and reporting.
小技巧
To change the default view of a model, access Studio, go to Views, click the (ellipsis) icon next to the desired view, and click Set as Default.
You can modify views using the built-in XML editor: Activate the Developer mode, go to the view you want to edit, select the View tab, and click </> XML.
重要
If you are editing a view using the XML editor, avoid making changes directly to standard and inherited views, as these would be reset and lost during updates or module upgrades. Always make sure you select the right Studio inherited views: When you modify a view in Studio by dragging and dropping a new field, for example, a specific Studio inherited view and its corresponding XPath, which defines the modified part of the view, are automatically generated.
常规视图¶
注解
下面描述的设置可以在视图的 View 选项卡下找到,除非另有说明。
表单¶
The Form view is used when creating and editing records, such as contacts, sales orders, products, etc.
To structure a form, drag and drop the Tabs and Columns element found under the + Add tab.
要防止用户创建、编辑或删除记录,请取消选中 Can Create 、 Can Edit 或 Can Delete 。
To add a button, click Add a button at the top of the form, enter a Label, and select the button’s action:
Run a Server Action: select the server action to be executed from the dropdown list;
Call a method: specify an existing Python method already defined in Odoo.
To change a button’s label or style, click the button and edit its Label or Class (either
btn-primary
orbtn-secondary
) in the Properties tab.To add a smart button, click the (plus) icon in the top-right corner of the form. Enter a Label, choose an Icon, and select a related field.
Example
活动¶
The Activity view is used to schedule and have an overview of activities (emails, calls, etc.) linked to records.
注解
此视图只能通过编辑 XML 代码在 Studio 中进行修改。
Example
搜索¶
The Search view is added on top of other views to filter, group, and search records.
要添加自定义 Filters 并使用 Separators 进行结构化,请转到 + Add 选项卡并将其拖放到 Filters 下方。
To add an existing field under the search dropdown menu, go to the + Add tab and drag and drop it under Autocompletion Fields.
Example
多记录视图¶
注解
下面描述的设置可以在视图的 View 选项卡下找到,除非另有说明。
看板¶
The Kanban view is often used to support business flows by moving records across stages or as an alternative way to display records inside cards.
注解
如果存在 看板 视图,则默认使用它来在移动设备上显示数据,而不是 列表视图。
要防止用户创建新记录,请取消选中 Can Create。
要在视图中直接创建记录,以简约的形式启用 快速创建。
To set a default grouping for records, select a field under Default Group By.
Example
列表¶
The List view is used to overview many records at once, look for records, and edit simple records.
要防止用户创建、编辑或删除记录,请取消选中 Can Create 、 Can Edit 或 Can Delete 。
To create and edit records directly within the view, select either Add record at the bottom, Add record on top or Open form view under When Creating Record.
注解
这样可以防止用户从 Form view 在 List 视图中打开记录。
要同时编辑多条记录,请勾选 启用批量编辑。
要更改默认排序记录的方式,请在“ Sort By ”下选择一个字段。
To set a default grouping for records, select a field under Default Group By.
To add a button, click Add a button at the top of the list, enter a Label, and select the button’s action:
Run a Server Action: select the server action to be executed from the dropdown list;
Call a method: specify an existing Python method already defined in Odoo.
小技巧
To add a (drag handle) icon to reorder records manually, add an Integer field with the Handle widget.
Example
地图¶
The Map view is used to display records on a map. For example, it is used in the Field Service app to plan an itinerary between different tasks.
注解
需要将一个与 Contact 模型链接的 Many2One field 字段与视图关联,因为联系地址用于在地图上定位记录。
To select which kind of contact should be used on the map, select it under Contact Field.
To hide the name or the address of the record, tick Hide Name or Hide Address.
要添加其他字段的信息,请在 附加字段 下选择它们。
要在不同记录之间建议一条路线,请勾选 启用路由 并选择应该用于对记录进行排序的字段。
Example
时间轴视图¶
日历¶
The Calendar view is used to overview and manage records inside a calendar.
要在视图中直接创建记录而不是打开 Form view,请启用 Quick Create。
注解
这仅适用于特定的模型,可以仅使用 名称 进行 快速创建 。然而,大多数模型不支持快速创建,而是打开 Form 视图以填写必填字段。
要在日历上为记录着色,请在 Color 下选择一个字段。所有共享该字段相同值的记录都使用相同的颜色显示。
注解
由于颜色数量有限,同一种颜色可能会被分配给不同的值。
要在日历顶部显示全天事件,请选择一个 复选框字段,指定事件是否持续一整天。
To choose the default time scale used to display events, select Day, Week, Month, or Year under Default Display Mode.
注解
You can also use a Delay Field to display the duration of the event in hours by selecting a Decimal or Integer field on the model which specifies the duration of the event. However, if you set an End Date Field, the Delay Field will not be taken into account.
Example
同期¶
The Cohort view is used to examine the life cycle of records over a time period. For example, it is used in the Subscriptions app to view the subscriptions’ retention rate.
要在视图上默认显示一个度量(即给定字段的聚合值),请选择一个 度量字段。
要选择默认用于分组结果的时间间隔,请在 Interval 下选择 Day 、 Week 、 Month 或 Year 。
要更改群体 模式,请选择 保留 在一段时间内保留的记录的百分比,它从100%开始随时间减少 或者 流失 在一段时间内移出的记录的百分比,它从0%开始随时间增加。
要更改 时间轴`(即列)的进度方式,请选择 :guilabel:`向前`(从 0 到 +15)或 :guilabel:`向后`(从 -15 到 0)。大多数情况下,使用 :guilabel:`向前 时间轴。
Example
甘特图¶
The Gantt view is used to forecast and examine the overall progress of records. Records are represented by a bar under a time scale.
要防止用户创建或编辑记录,请取消选中 Can Create 或 Can Edit。
要在不应该创建记录的单元格中填充灰色(例如,对于员工的周末),请勾选: 显示不可用。
注解
底层模型必须支持此功能,并且无法使用Studio添加对其的支持。它支持项目,休假,计划和制造应用程序。
要在底部显示总行,请勾选 显示总行。
要将多个记录折叠到一行中,请勾选 Collapse First Level。
要选择默认情况下记录在行上按哪种方式分组(例如,按员工或项目),请在 默认分组 下选择一个字段。
To define a default time scale to view records, select Day, Week, Month, or Year under Default Scale.
要在视图上为记录着色,请选择 Color 下的字段。所有具有相同字段值的记录都使用相同的颜色显示。
注解
由于颜色数量有限,同一种颜色可以分配给不同的值。
要指定每个时间刻度应该被划分的精度,选择 Quarter Hour , Half Hour 或 Hour 在 Day Precision 下,选择 Half Day 或 Day 在 Week Precision 下,以及 Month Precision 。
Example
报告视图¶
注解
下面描述的设置可以在视图的 View 选项卡下找到,除非另有说明。
透视表¶
The Pivot view is used to explore and analyze the data contained in records in an interactive manner. It is especially useful to aggregate numeric data, create categories, and drill down the data by expanding and collapsing different levels of data.
要访问所有数据在单元格下聚合的记录,请勾选 从单元格访问记录。
要将数据分成不同的类别,请在“ 列分组 ”,“ 行分组 - 第一级 ”或“ 行分组 - 第二级 ”下选择字段。
要向视图中添加不同类型的要测量的数据,请在 Measures 下选择一个字段。
要在单元格中显示构成聚合数据的记录计数,请勾选 显示计数。
Example
图表¶
The Graph view is used to showcase data from records in a bar, line, or pie chart.
要更改默认图表,请在 Type 下选择 Bar 、 Line 或 Pie 。
要选择默认的数据维度(类别),请在 第一个维度 下选择一个字段,并在需要的情况下,在 第二个维度 下选择另一个字段。
要选择使用视图进行测量的默认数据类型,请在 测量 下选择一个字段。
For Bar and Line charts only: To sort the different data categories by their value, select Ascending (from lowest to highest value) or Descending (from highest to lowest) under Sorting.
For Bar and Pie charts only: To access all records whose data is aggregated under a data category on the chart, tick Access records from graph.
For Bar charts only: When using two data dimensions (categories), display the two columns on top of each other by default by ticking Stacked graph.
Example