搜索、筛选和分组记录

Odoo 允许在视图中搜索、筛选和分组记录,以便只显示最相关的记录。搜索栏位于视图顶部,开始键入 搜索值,或点击 🔽(向下箭头) 图标访问 筛选分组方式收藏 下拉菜单。

搜索值

使用搜索字段可快速查找特定值,并将其添加为筛选器。键入要搜索的值,然后从下拉菜单中选择所需的选项来应用搜索筛选器。

Example

不添加 自定义筛选器 来选择 Mitchell Admin销售分析 报告(销售应用程序 ‣ 报告 ‣ 销售)中销售人员的记录,而是搜索`Mitch`,然后点击 搜索销售人员为:Mitch,然后选择 Mitchell Admin

在销售分析报告中搜索特定值

注解

使用搜索字段相当于在添加 自定义筛选器 时使用 包含 操作符。如果输入了部分值,并直接选择了所需字段(未选择 ⏵ [右箭头]),则会包含*所有*包含所选字段输入字符的记录。

筛选

筛选器用于选择符合特定条件的记录。默认的记录选择针对每个视图,但可以通过选择一个(或多个) 预配置筛选器,或通过添加 :ref:`自定义筛选器 <search/custom-filters>`来修改。

预配置筛选器

点击搜索栏中的 🔽(向下箭头) 图标,并从 筛选器 下拉菜单中选择一个(或多个)*预配置筛选器*,即可修改默认的记录选择。

Example

在*销售分析*报告(销售应用程序 ‣ 报告 ‣ 销售)中,默认只选择处于*销售订单*阶段、*订单日期*在过去 365 天内的记录。

要同时包含*报价*阶段的记录,请从 筛选器 中选择 报价

此外,要*只*包括特定年份(例如 2024 年)的销售订单和报价记录,首先要删除现有的 订单日期:最后 365 筛选器,方法是点击 ❌(删除)`图标,然后选择 :menuselection:`订单日期 –> 2024

在销售分析报告中使用预设筛选器

注解

预配置的 筛选器 被分组,每组之间用横线隔开。从同一组中选择预配置的筛选器,可使记录符合*任意*应用条件。但是,从不同组中选择筛选器则要求记录匹配*所有*应用条件。

自定义筛选器

如果 预配置筛选器 <search/preconfigured-filters>`不够具体,可添加自定义筛选器。要执行此操作,请点击搜索栏中的 :guilabel:`🔽(向下箭头) 图标,然后选择 筛选器 ‣ 添加自定义筛选器

在弹出的 添加自定义筛选器 窗口中,会显示匹配选项、筛选规则和 包括存档 记录的切换。

弹出添加自定义筛选器窗口。

默认匹配配置为 匹配以下任意规则,表示每条筛选规则独立应用。要将匹配配置更改为 匹配以下所有规则,必须在自定义筛选器中添加至少两条过滤规则。

  • 匹配以下所有规则**必须满足所有***过滤规则。逻辑上,这是一个 AND (&) 操作。

  • 匹配以下🔽 任一规则**可以满足任何**条筛选规则。逻辑上,这是一个 OR (|) 操作。

默认情况下,自定义筛选器只添加一条筛选规则。下文介绍了筛选规则的结构:

  1. 第一个内联字段是要筛选的*字段名称*。有些字段的细化参数嵌套在另一个字段中。这些字段旁边有一个 :guilabel:`> (箭头)`图标,选择该图标可显示嵌套字段。

  2. 第二个内联字段是用于比较字段名和字段值的条件*操作符*。可用的条件运算符 是针对字段的数据类型的。

  3. 第三个内联字段是字段名的变量 。值输入可以是下拉菜单、文本输入、数字输入、日期/时间输入、布尔选择器,也可以是空白,具体取决于所使用的运算符和字段的数据类型。

规则筛选条件右侧还有三个内嵌按钮:

  1. ➕(加号):在现有规则下方添加新规则。

  2. (添加分支):在现有规则下添加新的规则组,并提供 任意全部 匹配选项,以定义如何将该分支中的每条规则应用于筛选器。如果匹配选项设置为与母组相同,则字段会被移动以加入母组。

    Example

    如果匹配选项设置为 匹配以下所有规则,而新添加的分支的匹配选项从 任意 变为 :guilabel:`全部 `,则新添加的分支将消失,其规则组将移至母组。

  3. 🗑️(垃圾桶):删除节点。如果删除了一个分支节点,该节点的所有子节点也会被删除。

点击 新规则 按钮,可将新的筛选规则添加到自定义筛选器中。

定义筛选条件后,点击 添加 将自定义筛选器添加到视图中。

Example

要定位 CRM 应用程序中处于 赢得 阶段且预期收入大于 $1,000 的所有潜在客户和商机,应输入以下内容:

匹配以下所有规则🔽(向下箭头):

  1. Stage is in Won

  2. Expected Revenue > 1,000

  3. any 🔽 (down arrow) of:

    • Type = Lead

    • Type = Opportunity

Adding a custom filter to filter specific records in CRM.

小技巧

激活 开发者模式 可显示每个字段的技术名称和数据类型,以及筛选规则下方的 #代码编辑器 文本区域,以便手动查看和编辑域。

组记录

The display of records in a view can be clustered together, according to one of the preconfigured groups. To do so, click the 🔽 (down arrow) icon in the search bar, then select one of the Group By options from the drop-down menu.

Example

To group the records by salesperson on the Sales Analysis report (Sales app ‣ Reporting ‣ Sales), click the Salesperson option from the Group By drop-down menu. The view changes to group the records by salesperson, without filtering out any records.

销售分析报告中的分组记录

It is possible to customize groups by using a field present on the model. To do so, click Add Custom Group, and select a field from the drop-down menu.

注解

Several groups can be used at the same time. The first group that is selected is the main cluster, the next one that is added further divides the main group’s categories, and so on. Furthermore, filters and groups can be used together to refine the view even more.

比较

Certain reporting dashboards include a Comparison section in the drop-down menus of their Search… bars. This includes the Overall Equipment Effectiveness report for the Manufacturing app, and the Purchase report for the Purchase app, among others.

The options in the Comparison section are used to compare data from two different time periods. There are two comparison options to choose from: (Time Filter): Previous Period and (Time Filter): Previous Year.

重要

For some reports, the Comparison section only appears in the Search… bar drop-down menu if one (or more) time periods have been selected in the Filters column. This is because, if no time period is specified, there is nothing to compare.

Additionally, some reports only allow use of the Comparison feature when the (pie chart) graph type, or the (pivot) view, is selected. A Comparison option can be selected even if another view is enabled, but doing so does not change the way data is displayed on the report.

The Search... bar for the production analysis report.

To view data using one of the two comparisons, begin by selecting a time period in the Filters column of the Search… bar drop-down menu. Then, select either (Time Filter): Previous Period or (Time Filter): Previous Year in the Comparison section.

With one of the Comparison options enabled, the report compares the data for the selected period, with the data for the same unit of time (month, quarter, year), one period or year prior. The way the data is displayed depends on the selected view:

  • The (bar chart) shows two bars, side-by-side, for each unit of time for the selected time period. The left bar represents the selected time period, while the right bar represents the previous time period.

  • The (line chart) is displayed with two lines, one representing the selected time period, and the other representing the previous time period.

  • The (pie chart) appears as a large circle with a smaller circle inside. The larger circle represents the selected time period, while the smaller circle represents the previous time period.

  • The (pivot table) is displayed with each column split into two smaller columns. The right column represents the selected time period, while the left column represents the previous time period.

Example

In the Production Analysis report of the Manufacturing app, data for the second quarter of 2024 is compared to data for the second quarter of 2023. Q2 is selected in the End Date filter section of the Search… bar drop-down menu. In the Comparison section, End Date: Previous Year is selected.

The current year is 2024, so the larger circle shows data for the second quarter (Q2) of 2024. The smaller circle shows data for the second quarter (Q2) of 2023, which is the same time period, but one year prior.

If End Date: Previous Period is selected instead, the smaller circle shows data for the first quarter (Q1) of 2024, which is the same time period, but one period prior.

The comparison view of the Production Analysis report.

收藏夹

Favorites are a way to save a specific search for future use, or as the new default filter for the view.

To save the current view as a favorite, click the 🔽 (down arrow) icon in the search bar, then select the Save current search drop-down menu to display the following options:

  • Filter name: name of the favorited search.

  • Default filter: sets the favorited search as the default filter for the view.

  • Shared: makes the favorited search available to all users. By default, the favorited search is only available to the user who created it.

Once the options are set, click Save to save the favorited search.

Saving a favorite search on the Sales Analysis report

点击搜索栏中的 🔽(向下箭头) 图标,然后在 收藏 下拉菜单中选择已保存的筛选器,即可访问已保存的收藏夹。要删除已保存的收藏夹,请点击收藏搜索旁边的 🗑️(垃圾桶) 图标。

小技巧

要查看*所有*收藏的搜索,首先激活 开发者模式,然后导航至 设置应用程序 ‣ 技术 ‣ 用户界面:用户自定义筛选器。在这里,可以查看、编辑、存档或删除所有收藏的搜索。