自訂報告¶
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
傳回所有相符分錄資料行的數額的總和。
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
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\()
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
10
的賬戶。C
及 D
字尾可透過與標籤相同的方式使用。
Example
tag(my_module.my_tag)C
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.
**算式**可以是以下其中一項:
sum
若傳回值必須是該時段內所有外部值的總和。
most_recent
若傳回值必須是該時段內最新外部值的值。
此外,**子算式**可透過兩種方式使用:
rounding=X
將
X
填入數字,會指示將數額四捨五入至 X 個小數位。editable
表示可手動編輯此表達式,並在報表內觸發顯示一個圖示,讓使用者執行此操作。
備註
手動值是在報表目前選擇的 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