查看

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.

一般视图

注解

除非另有规定,否则在视图的:guilabel:`视图’选项卡下可以找到下述设置。

窗体

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.

  • 要防止用户创建、编辑或删除记录,取消勾选:guilabel:可创建可编辑`或:guilalb:`可删除

  • 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 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.

注解

在Studio中,仅能通过编辑XML代码更改此视图。

Example

潜在客户/商机模型的活动视图

多项记录视图

注解

除非另有规定,否则在视图的:guilabel:`视图’选项卡下可以找到下述设置。

看板

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.

注解

如果存在:guilable:`看板`视图,在默认情况下,用于在移动设备而非:ref:`List view <studio/views/multiple-records/list>`上显示数据。

  • 要防止用户创建新记录,取消勾选:guilabel:可创建

  • 要直接在视图中创建记录,在极简表单中,启用:guilabel:快速创建

  • 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.

  • 要防止用户创建、编辑或删除记录,取消勾选:guilabel:可创建可编辑`或:guilalb:`可删除

  • 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.

    注解

    这将防止用户从:guilabel:`列表`视图打开:ref:`Form view <studio/views/general/form>`中的记录。

  • 要一次编辑多个记录,勾选:guilabel:启用批量编辑

  • 要更改记录的默认排序方式,在:guilabel:`排序方式`下选择一个字段。

  • 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.

注解

链接至*联系人*模型的:ref:`Many2One field <studio/fields/relational-fields/many2one>`需要激活该视图,因为联系人地址用于在地图上定位记录。

  • 在:guilabel:`联系人字段`下选择在地图上使用的联系人类型。

  • To hide the name or the address of the record, tick Hide Name or Hide Address.

  • 在:guilabel:`其他字段`下选择要从其他字段添加的信息。

  • 要在不同记录间建议路由,勾选:guilabel:启用路由,并选择用于对路由记录进行排序的字段。

Example

任务模型的地图视图

时间线视图

注解

  • 首次激活一个时间线视图时,需要选择模型中的:ref:Date <studio/fields/simple-fields/date>`或:ref:`Date & Time <studio/fields/simple-fields/date-time>`字段,以定义在视图上开始和停止显示记录的时间。激活视图后,可以修改:guilabel:`开始日期字段`和:guilabel:`结束日期字段

  • 除非另有规定,否则在视图的:guilabel:`视图’选项卡下可以找到下述设置。

日历

The Calendar view is used to overview and manage records inside a calendar.

  • 要直接在视图中创建记录,而不打开:ref:Form view <studio/views/general/form>,启用guilabel:快速创建

    注解

    此操作只适用于仅使用*名称*即可*快速创建*的特定模型。多数模型不支持快速创建和:guilabel:`表单`视图填写所需的字段。

  • 要为日历中的记录设置颜色,在:guilabel:`颜色`下选择一个字段,与该字段值相同的所有记录将显示为设置颜色。

    注解

    由于颜色数量有限,同一颜色可能分配给不同的值。

  • 要在日历顶部显示全天的事件,选择指定事件是否持续整天的:ref:Checkbox field <studio/fields/simple-fields/checkbox>

  • 要选择显示事件的默认时间刻度,在:guilabel:默认显示模式`下选择:guilabel:`日月`或:guilabel:`年

注解

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.

  • 要在视图上默认显示测量值(即给定字段的聚合值),选择:guilabel:测量字段

  • 要选择默认情况下对结果进行分组的时间间隔,在:guilabel:间隔`下选择:guilabel:`日月`或:guilabel:`年

  • 要更改群组:guilabel:模式,选择:guilabel:Retention the percentage of records staying over a period of time, it starts at 100% and decreases with time`或:guilabel:`Churn the percentage of records moving out over a period of time - it starts at 0% and increases with time

  • 要更改:guilabel:时间线`(即列)前进的方式,选择:guilabel:`Forward`(0~+15)或:guilabel:`Backward`(-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.

  • 要防止用户创建或编辑记录,取消勾选:guilabel:可创建`或:guilabel:`可编辑

  • 要填写不应创建记录的(例如,周末)灰色单元格,勾选:guilabel:显示不可用

    注解

    基础模型须支持该功能,且不能使用Studio添加支持。支持项目、休息、计划和生产应用程序。

  • 要在底部显示总计行,勾选 显示总计行

  • 要在一行中折叠多条记录,勾选:guilabel:折叠第一级

  • 要选择记录的默认分组方式(例如,按员工或项目),在:guilabel:`默认分组方式`下选择一个字段。

  • 要定义查看记录的默认时间刻度,在:guilabel:默认刻度`下选择:guilabel:`日月`或:guilabel:`年

  • 要为视图中的记录设置颜色,在:guilabel:`颜色`下选择一个字段,与该字段值相同的所有记录将显示为设置颜色。

    注解

    由于颜色数量有限,同一颜色可能分配给不同的值。

  • 要规定各时间刻度除以的精度,选择 日精度`下的:guilabel:`一刻钟半小时`或:guilabel:`小时周精度`下的:guilabel:`半天`或:guilabel:`全天,以及:guilabel:月精度

Example

计划班次模型的甘特视图

报告视图

注解

除非另有规定,否则在视图的:guilabel:`视图’选项卡下可以找到下述设置。

轴心

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.

  • 要查看在单元格内聚合数据的所有记录,勾选:guilabel:Access records from cell

  • 要将数据划分为不同类别,选择:guilabel:Column grouping、:guilabel:`Row grouping - First level`或:guilabel:`Row grouping - Second level`下的字段。

  • 要使用视图添加要测量的、不同类型的数据,在:guilabel:`测量`下选择一个字段。

  • 要显示构成单元格内聚合数据的记录计数,勾选:guilabel:显示计数

Example

采购报告模型的数据透视视图

图表

The Graph view is used to showcase data from records in a bar, line, or pie chart.

  • 要更改默认图表,在:guilabel:类型`下选择:guilabel:`条形图拆线图`或:guilabel:`饼图

  • 要选择默认数据维度(类别),在:guilabel:`First dimension`下选择一个字段,如果需要,在:guilabel:`Second dimension`下选择另一个字段。

  • 要选择使用视图测量的默认数据类型,在:guilabel:`测量`下选择一个字段。

  • 仅适用于条形图:要按值对不同数据类别进行排序,在:guilabel:`排序`下选择:guilabel:`升序`(从最低值到最高值) (from lowest to highest value) or :guilabel:`降序`从最高值到最低值)。

  • 仅适用于条形图和饼图:要查看在图表数据类别下聚合数据的所有记录,勾选:guilabel:Access records from graph

  • 仅适用于条形图:如果使用两个数据维度(类别),勾选:guilabel:Stacked graph,默认将两列显示在彼此顶部。

Example

图表视图中销售分析报告模型的条形图