自定义报告¶
Odoo comes with a powerful and easy-to-use reporting framework. The engine allows you to create new reports, such as tax reports, balance sheets, and income statements with specific groupings and layouts.
重要
Activate the developer mode to access the accounting report configuration.
To create a new report, go to root report or a variant.
. From here, create either a小技巧
Consider saving modified reports as report variants to keep their root reports intact.
To access an existing report’s management interface from the report itself, click on the (gears) icon.
根报告¶
根报告可被视为通用的、中立的会计报告。它们是建立本地会计版本的模型。如果一个报告没有根报告,那么它本身就被视为根报告。
Example
比利时和美国的税务报告都将以相同的通用版本为基础,并根据其本地法规进行调整。
Creating a menu item is required to access a new root report. To do so, open the report’s configuration, click Action, Create Menu Item, and refresh the page. The report is now available under .
注解
需要创建新的根报告的情况很少见,例如当一个国家/地区的税务机构要求一种新的特定类型的报告时。
变体¶
变体是根报告的特定国家/地区版本,因此总是引用根报告。要创建变体,请在创建新报告时在 根报告 字段中选择通用(根)报告。
When a root report is opened from the Accounting app’s Reporting menu, all of its variants are displayed in the report variant selector in the top right corner of the view.
Example
VAT Report (BE) is a variant of the root Generic Tax report.

行¶
After creating a report (either root or variant), the next step is to fill it with lines. To create a new line, click on Add a line. To modify an existing line, click on the line itself and edit the popup. All lines require a Name and can have an optional Code which allows using the line’s value in formulas.

表达式¶
Each line can contain one or multiple expressions. Expressions can be seen as sub-variables needed by a report line. To create an expression, click on Add a line within a line’s popup.
When creating an expression, you must enter a Label used to refer to that expression. The label must be unique among the expressions of each report line. Both the Computation Engine and the Formula fields must also be completed. The computation engine defines how the formula(s) and subformula(s) are interpreted. It is possible to mix expressions using different computation engines under the same line if needed.
注解
根据引擎的不同,可能还需要 子公式。
Odoo Domain computation engine¶
When using the Odoo Domain computation engine, a formula is interpreted as an Odoo
domain targeting account.move.line
objects.
子公式允许您定义如何使用与域匹配的移动行来计算表达式的值:
总额
结果是匹配移动线路的所有余额之和。
sum_if_pos
如果结果为正数,则为匹配移动行的所有余额之和。否则,结果为`0`。
sum_if_neg
如果结果为负数,传回所有相符分录资料行的余额之和。否则,传回
0
。count_rows
The result is the number of sub-lines of this expression. If the parent line has a group-by value, this will correspond to the number of distinct grouping keys in the matched move lines. Otherwise, it will be the number of matched move lines.
小技巧
To reverse the sign of the result, put a -
sign at the beginning of the subformula.

Aggregate Other Formulas computation engine¶
The Aggregate Other Formulas computation engine performs arithmetic operations on the
amounts obtained from other expressions. Formulas here are composed of references to expressions
separated by one of the four basic arithmetic operators (addition +
, subtraction -
, division
/
, and multiplication *
). To refer to an expression, type in its parent line’s code followed
by a period .
and the expression’s label (ex. code.label).
**子公式**可以是以下其中之一:
if_above(CUR(amount))
只有当算术表达式的值大于所提供的界限时,才会返回该值。否则,结果将是
0
。if_below(CUR(amount))
只有当算术表达式的值小于所提供的界限时,才会返回该值。否则,结果将为
0
。if_between(CUR1(amount1), CUR2(amount2))
只有当算术表达式的值严格位于所提供的界限之间时,才会返回该值。否则,将返回最接近的界限。
if_other_expr_above(LINE_CODE.EXPRESSION_LABEL, CUR(amount))
只有当所提供的行代码和表达式标签所表示的表达式值大于所提供的界限时,才会返回算术表达式的值。否则,结果将为
0
。if_other_expr_below(LINE_CODE.EXPRESSION_LABEL, CUR(amount))
只有当所提供的行代码和表达式标签所表示的表达式值小于所提供的界限时,才会返回算术表达式的值。否则,结果将为
0
。
CUR
是大写的货币代码,amount
是以该货币表示的绑定金额。
您还可以使用 cross_report
子公式来匹配另一份报告中的表达式。
Prefix of Account Codes computation engine¶
The Prefix of Account Codes computation engine is used to match amounts made on accounts using the prefixes of these accounts’ codes as variables in an arithmetic expression.
Example
21
Example
21 + 10 - 5
也可以忽略选定的子前缀。
Example
21 + 10\(101, 102) - 5\(57)
101
、102
和 57
。您可以使用后缀 `C`(贷) 和 `D`(借) 对**贷记和借记**进行“子筛选”。在这种情况下,只有账户的前缀匹配,且该账户内的分录资料行的总余额为**贷记/借记**时,才会考虑该账户。
Example
账户 210001
余额为 -42,账户 210002
余额为 25。公式 21D
只与账户 210002
匹配,因此返回 25。210001
不匹配,因为其余额为*贷方*。
前缀排除可与`C`和`D`后缀混合使用。
Example
要匹配前缀中的字母 C
或 D
,但不将其用作后缀,请使用空排除项 ()
。
Example
21D\()
除了使用代码前缀来包含账户外,还可以用**账户标记**来匹配它们。举例来说,如果你所在的国家没有标准化的会计科目表,那么相同的前缀在不同的公司可能会有不同的用途,这个方法就特别有用。
Example
tag(25)
If the tag you reference is defined in a data file, an XMLID can be used instead of the ID.
Example
tag(my_module.my_tag)
您还可以将算术表达式与标记一起使用,也可以将其与前缀选择相结合。
Example
tag(my_module.my_tag) + tag(42) + 10
后缀 C
和 D
的使用方法与标签相同。
Example
tag(my_module.my_tag)C
前缀排除也适用于标签。
Example
tag(my_module.my_tag)\(10)
10
开头的账户。External Value computation engine¶
The External Value computation engine is used to refer to manual and carryover
values. Those values are not stored using account.move.line
, but with
account.report.external.value
. Each of these objects directly points to the expression it impacts,
so very little needs to be done about their selection here.
**公式**可以是以下之一:
总额
如果结果必须是该周期内所有外部值的总和。
most_recent
如果结果必须是该周期内最新外部值的值。
此外,**子公式**有两种使用方法:
舍入=X
将
X
替换为数字,表示将金额四舍五入到小数点后 X 位。可编辑
表示可以手动编辑该表达式,从而在报告中显示一个图标,允许用户执行该操作。
注解
手动值在报告中当前选择的 date_to
处创建。
这两个子公式可以混合使用,方法是用 ;
分隔。
Example
editable;rounding=2
Custom Python Function computation engine¶
The Custom Python Function computation engine is a means for developers to introduce custom computation of expressions on a case-by-case basis. The Formula is the name of a python function to call, and the Subformula is a key to fetch in the dictionary returned by this function. Use this computation engine only if making a custom module.
列¶
报表可显示的列数**无限**。每列会从**资料行**上宣告的**表达式**获取数值。该列的 expression_label 字段给出了显示其值的表达式的标签。如果资料行在某字段中没有**表达式**,该行在此列的位置便不会显示任何内容。如果需要多个列,必须使用不同的**表达式**标签。

在会计报告的 选项 分页选用**期间比较**功能时,所有列都会在每个期间内,为每个期间重复显示。
Line grouping¶
Non-standard grouping is possible by adding or using existing fields on the Journal Item model, provided that the fields are related and non-stored.
注解
Grouping lines requires the report to have explicit report lines that can be edited. The deferred reports, for example, do not support grouping lines as they use dynamic lines that are generated.
Create a new field on journal item¶
To create a non-stored, related field in the Journal Item model, first go to (bug) icon, then click Fields. Click New to create a new field, and complete the following fields:
, and click theField Name: a technical name for the field
Field Label: the label to be displayed for the field
Field Type: the type of field that this related field should point to
Stored: Leave this field unchecked as only non-stored fields can be used to group lines.
Related Model: If the field type is one2many, many2many, or many2one, select the model of the original field to group by.
Related Field Definition: the technical path to the field you want to group by
Example
To group by the sales team of the commercial partner, set the related field definition to
move_id.team_id
.
Group lines¶
To group lines, go to the Lines tab of the desired report, click on the line you want to group, and edit the Group by field. Enter the technical name (Field Name) of the field to use as the grouping key.
小技巧
To find a list of all the model’s fields and their technical names, go to (bug) icon, then click Fields. The technical name of each field is listed in the Field Name column.
, and click the