自訂報告¶
Odoo 附带一个功能强大且易于使用的报告框架。该引擎允许您创建新的报告,如**税务报告**或**资产负债表**和**收入报表**,并可进行**特定分组**和**布局**。
重要
激活 开发者模式 访问会计报告创建界面。
根报告¶
根报告可被视为通用的、中立的会计报告。它们是建立本地会计版本的模型。如果一个报告没有根报告,那么它本身就被视为根报告。
Example
比利时和美国的税务报告都将以相同的通用版本为基础,并根据其本地法规进行调整。
创建新的根报告时,需要为其创建**菜单项**。为此,请打开报告,然后在同一报告上单击
。刷新页面;现在该报告在 下可用。備註
需要创建新的根报告的情况很少见,例如当一个国家/地区的税务机构要求一种新的特定类型的报告时。
變體¶
变体是根报告的特定国家/地区版本,因此总是引用根报告。要创建变体,请在创建新报告时在 根报告 字段中选择通用(根)报告。
从会计应用程序的主菜单之一打开根报告时,其所有变体都会显示在视图右上角的变体选择器中。
明細列表¶
创建报告(根报告或变量报告)后,需要在报告中添加行。您可以点击 添加行 创建新行,也可以点击现有行进行修改。所有行都*需要*一个 名称,如果您希望在公式中使用它们的值,还可以选择附加 :guilabel:`代码`(由您选择)。
表達式¶
每一行可以包含一个或多个**表达式**。表达式可视为报告行所需的**子变量**。要创建表达式,请单击行报告*内*的 添加行。
创建表达式时,您必须为该表达式指定一个 标签 属性。因此,在每一行的表达式中,它必须是**唯一**的。还必须指定 计算引擎 和 公式 。引擎**定义了如何解释您的**公式**和**子公式。如果需要,可以在同一行中混合使用不同计算引擎的表达式。
備註
根据引擎的不同,可能还需要 子公式。
『Odoo 域名』 引擎¶
使用此引擎时,公式被解释为针对`account.move.line`对象的:ref:Odoo 域名<reference/orm/domains>
。
子公式允许您定义如何使用与域匹配的移动行来计算表达式的值:
总额
结果是匹配移动线路的所有余额之和。
sum_if_pos
如果结果为正数,则为匹配移动行的所有余额之和。否则,结果为`0`。
sum_if_neg
The result is the sum of all the balances of the matched move lines if this amount is negative. Otherwise, it is
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.
您也可以在子公式的开头加上 -
号,来**取反**结果的符号。
『Aggregate Other Formulas』 engine¶
当您需要对其他表达式得到的金额进行算术运算时,请使用此引擎。这里的公式由引用表达式组成,表达式由四个基本算术运算符(加法运算符 +
、减法运算符 -
、除法运算符 /
和乘法运算符 *
)之一分隔。要引用一个表达式,请输入其上级行的**代码**,后跟一个句点`.`和表达式的**标签**(例如**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』 engine¶
该引擎用于匹配账户金额,使用这些账户代码的前缀作为算术表达式中的变量。
Example
21
Example
21 + 10 - 5
21
and 10
, and subtracts the balance of the ones on accounts with the prefix 5
.It is also possible to ignore a selection of sub-prefixes.
Example
21 + 10\(101, 102) - 5\(57)
101
, 102
,
and 57
.You can apply 『sub-filtering』 on credits and debits using the C
and D
suffixes. In this
case, an account will only be considered if its prefix matches, and if the total balance of the
move lines made on this account is credit/debit.
Example
账户 210001
余额为 -42,账户 210002
余额为 25。公式 21D
只与账户 210002
匹配,因此返回 25。210001
不匹配,因为其余额为*贷方*。
前缀排除可与`C`和`D`后缀混合使用。
Example
21D + 10\(101, 102)C - 5\(57)
21
if it is debit (D
) and 10
if it is credit (C
), but ignores prefixes 101
, 102
, and
subtracts the balance of the ones on accounts with the prefix 5
, ignoring the prefix 57
.要匹配前缀中的字母 C
或 D
,但不将其用作后缀,请使用空排除项 ()
。
Example
21D\()
除了使用代码前缀来包含账户外,还可以用**账户标记**来匹配它们。举例来说,如果你所在的国家没有标准化的会计科目表,那么相同的前缀在不同的公司可能会有不同的用途,这个方法就特别有用。
Example
tag(25)
如果您引用的标记是在数据文件中定义的,则可以使用 xmlid 代替 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
开头的账户。『外部价值』 引擎¶
『外部值’引擎用于参考**手动值**和**结转值**。这些值不是使用`account.move.line`存储的,而是使用`account.report.external.value`。这些对象中的每一个都直接指向它所影响的表达式,因此在这里几乎不需要进行选择。
**公式**可以是以下之一:
总额
如果结果必须是该周期内所有外部值的总和。
most_recent
如果结果必须是该周期内最新外部值的值。
此外,**子公式**有两种使用方法:
舍入=X
将
X
替换为数字,表示将金额四舍五入到小数点后 X 位。可编辑
表示可以手动编辑该表达式,从而在报告中显示一个图标,允许用户执行该操作。
備註
Manual values are created at the date_to
currently selected in the report.
Both subformulas can be mixed by separating them with a ;
.
Example
editable;rounding=2
『Custom Python Function』 engine¶
This 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 it only if you are making a custom module of your own.
欄位¶
Reports can have an indefinite number of columns to display. Each column gets its values from the expressions declared on the lines. The field expression_label of the column gives the label of the expressions whose value is displayed. If a line has no expression in that field, then nothing is displayed for it in this column. If multiple columns are required, you must use different expression labels.
When using the period comparison feature found under the Options tab of an accounting report, all columns are repeated in and for each period.