自訂報告

Odoo 配備強大又易用的報告框架。報告引擎讓你可以建立新的報告,例如**稅務報表**,或設有**特定分組方式**及**排版方式**的**資產負債表**及**損益表**。

重要

記得啟動 開發者模式,以進入會計報表建立介面。

To create a new report, open the Accounting app and navigate to Configuration ‣ Accounting Reports. From here, you can either create a root report or a variant.

根級報告

「根級報告」可視為通用、中立的會計報告格式。它們可當作模型使用,以建構本地會計版本。如果某個報表沒有根級報表,它本身便會視為根級報表。

Example

比利時及美國的稅務報告,會使用相同的通用版本作基礎,再根據個別國內法規調整。

When creating a new root report, you need to create a menu item for it. To do so, open the report and, on that same report, click the (Actions) icon, then select Create Menu Item. Refresh the page; the report is now available under Accounting ‣ Reporting.

備註

需要特別建立新根級報告的情況比較少見,例如當國家稅務機關要求呈交新的指定類型報告時。

款式

款式變體是根級報告為特定國家/地區設定的不同版本,所以必定有引用某個根級報告。要建立變體,請在建立新報告時,在 根級報告 欄位中,選擇一個通用(根級)報告。

當你從會計應用程式的任何主選單開啟根級報告時,其所有變體都會顯示在畫面右上角的變體選擇器中。

Example

下圖中,:guilabel:`VAT Report (BE)`(比利時增值稅報告)便是根級報告 :guilabel:`Generic Tax report`(通用稅務報告)的變體。

Report lines

After having created a report (either root or variant), you need to fill it with report lines. You can either create a new one by clicking on Add a line, or modify an existing report line by clicking on it. All report lines require a Name, and can have an optional additional Code (of your choice) if you wish to use their value in formulas.

設定資料行選項。

表達式

Each report 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 report line.

When creating an expression, you must attribute a Label used to refer to that expression. Therefore, it has to be unique among the expressions of each line. Both a Computation Engine and a Formula must also be indicated. The engine defines how your formula(s) and subformula(s) are interpreted. It is possible to mix expressions using different computation engines under the same line if you need to.

備註

視乎不同引擎,可能也需要有 子算式

「Odoo 搜尋範圍」引擎

使用此引擎時,算式會被解釋為 Odoo 搜尋範圍,針對 account.move.line 物件。

子算式讓你對符合搜尋範圍的分錄資料行,定義應如何用作計算表達式的值:

sum

傳回所有相符分錄資料行的數額的總和。

sum_if_pos

傳回所有相符分錄資料行的數額的總和(如果數額為正數)。否則傳回 0

sum_if_neg

傳回所有相符分錄資料行的數額的總和(如果數額為負數)。否則傳回 0

count_rows

The result is the number of sub-lines of this expression. If the report 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.

你可在子算式開首加入 - 符號,以**反轉**傳回值的正負號。

資料行報告中的表達式資料行

「稅項標籤」引擎

為此引擎建立的算式,會包括一個用於配對稅項標籤的名稱。如果建立表達式時未有此類標籤,會自動建立它們。

計算表達式的值時,表達式的計算方法大致是:(附有 + 標籤的分錄資料行數目) - (附有 - 標籤的分錄資料行數目)

Example

假設算式是 tag_name,引擎會嘗試配對 +tag_name-tag_name 稅項標籤,並在必要時建立它們。進一步舉例:兩個標籤透過算式進行配對時,如果算式是 A,它將需要有(或視乎需要而建立)標籤 +A-A

「綜合計算其他算式」引擎

Use this engine when you need to perform arithmetic operations on the amounts obtained for 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 report 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 子算式,以配對另一報表中的表達式。

「賬戶代碼字首」引擎

此引擎使用賬戶代碼的字首,作為算術表達式中的變數,以配對賬戶金額。

Example

21
純算術表達式也可用作單一字首,正如此例。

Example

21 + 10 - 5
此算式將代碼為 2110 開首的賬戶內的分錄資料行數額相加,然後減去代碼字首為 5 的賬戶內的分錄資料行數額。

你亦可選擇忽略指定的子字首:

Example

21 + 10\(101, 102) - 5\(57)
此算式的運作方式與之前的例子相同,但不會考慮字首 10110257

你更可在**貸記及借記**記項上套用「子篩選」,方法是使用 `C`(貸)及 `D`(借)為字尾。使用時,只會在賬戶字首相符*並且*賬戶內分錄資料行的總數額為**貸記/借記**記項,才會考慮該賬戶。

Example

假設賬戶 210001 的結餘為 -42,而賬戶 210002 結餘為 25。算式 21D 只能配對到賬戶 210002,然後傳回 25。運算此算式時,賬戶 210001 並不相符,因為其結餘屬於*貸記*金額。

排除字首功能可以與 CD 字尾混合使用:

Example

21D + 10\(101, 102)C - 5\(57)
此算式會將代碼字首為 21 的分錄資料行金額(*如果*金額屬借方,即 D)以及字首為 10 的分錄資料行金額(*如果*金額屬貸方,即 C)相加,但不會考慮字首 101102 的賬戶,然後減去字首為 5 的賬戶的金額,但不會考慮字首 57 的賬戶。

若賬戶字首中有字母 CD 要配對,不想用作貸記/借記字尾,可使用空白排除 ()

Example

21D\()
此算式會配對代碼以 21D 開首的賬戶,不論其金額符號屬借記或貸記。

除使用代碼字首指定賬戶,還可使用**賬戶標籤**去配對所需賬戶。這可以很有用,尤其是公司所在國家/地區缺乏標準化的會計賬目總表時,因為相同的賬戶代碼字首,在不同公司可能有不同用途或含義。

Example

tag(25)
此算式會配對賬戶關聯標籤中,具有識別碼(id)為 25 的標籤的賬戶。

如果引用的標籤是在數據檔案中定義的,可使用 xmlid 取代 id。

Example

tag(my_module.my_tag)
此算式會配對賬戶關聯標籤中,包含以 my_module.my_tag 表示的標籤的賬戶。

你亦可使用帶有標籤的算術表達式,更可將它們與字首選擇結合運用。

Example

tag(my_module.my_tag) + tag(42) + 10
此算式會將以下賬戶的金額相加:以 my_module.my_tag 標籤的賬戶、與識別碼 42 的標籤關聯的賬戶,以及代碼字首為 10 的賬戶。

CD 字尾可透過與標籤相同的方式使用。

Example

tag(my_module.my_tag)C
此算式會配對帶有標籤 my_module.my_tag 以及貸方餘額(C)的賬戶。

字首排除也適用於標籤。

Example

tag(my_module.my_tag)\(10)
此算式會配對帶有標籤 my_module.my_tag 以及代碼字首並非 10 的賬戶。

「外部值」引擎

「外部值」引擎用於引用**手動**以及**結轉**的數值。這些值不是在 account.move.line 儲存的,而是使用 account.report.external.value 儲存。這些物件全部都直接指向它所影響的表達式,因此選用它們時,幾乎不需要做任何事情。

**算式**可以是以下其中一項:

sum

若傳回值必須是該時段內所有外部值的總和。

most_recent

若傳回值必須是該時段內最新外部值的值。

此外,**子算式**可透過兩種方式使用:

rounding=X

X 填入數字,會指示將數額四捨五入至 X 個小數位。

editable

表示可手動編輯此表達式,並在報表內觸發顯示一個圖示,讓使用者執行此操作。

備註

手動值是在報表目前選擇的 date_to 那處建立的。

這兩個子算式可用分號 ; 分隔,以混合使用。

Example

editable;rounding=2
以上是混合使用兩種行為的正確子算式。

「自訂 Python 函數」引擎

此引擎是供開發人員按照個別情況需要,自行為表達式引入自訂運算方法的途徑。算式會是要召用的 **Python 函數**名稱,子算式就是在該函數傳回的**字典**(dictionary)中,需要讀取的**鍵**(key)。請只在需要自行編寫自訂模組時,才使用此引擎。

報表可以擁有**無限數量**的直欄,以作顯示。每欄會從**資料行**上宣告的**表達式**獲取數值。直欄的欄位 expression_label 表示所顯示數值來自的表達式的標籤。如果資料行在某欄位中沒有**表達式**,該行在此直欄的位置便不會顯示任何內容。如果需要多個直欄,必須使用不同的**表達式**標籤。

報表的不同直欄。

在會計報告的 選項 分頁選用**期間比較**功能時,所有直欄都會在每個期間內,為每個期間重複顯示。

資料行分組

可以透過在日記帳項目模型上新增或使用現有欄位來進行非標準分組,前提是這些欄位是相關的且未儲存的。

備註

分組資料行需要報表具有可編輯的明確報表資料行。例如,遞延報表不支援分組資料行,因為它們使用動態產生的資料行。

在日記帳項目上建立新欄位

若要在日記帳項目模型中建立未儲存的相關欄位,請先前往會計 ‣ 日記帳項目,並按一下(除錯)圖示,然後按一下欄位。按一下新增以建立新欄位,並完成以下欄位:

  • 欄位名稱:欄位的技術名稱

  • 欄位標籤:欄位要顯示的標籤

  • 欄位類型:此相關欄位應指向的欄位類型

  • 已儲存:請不要勾選此欄位,因為只有未儲存的欄位才能用於分組資料行。

  • 相關模型:如果欄位類型為one2manymany2manymany2one,請選擇原始欄位的模型以進行分組。

  • 相關欄位定義:您要分組的欄位的技術路徑

    Example

    若要按商業合作夥伴的銷售團隊分組,請將相關欄位定義設為 move_id.team_id

分組資料行

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.

小訣竅

若要尋找所有模型欄位及其技術名稱的清單,請前往會計 ‣ 日記帳記項,然後按一下錯誤)圖示,接著按一下欄位。每個欄位的技術名稱列於欄位名稱欄中。

Custom tax report setup

Report configuration

小訣竅

All technical terms and functions of Odoo’s reports engine are explained in the previous sections of this page. We strongly recommend reading these sections before setting up a custom tax report.

To create a custom tax report, open the Accounting app, navigate to Configuration ‣ Accounting Reports, then click New:

  • Enter a name for your report.

  • Select a Root Report.

  • Under the Availability field, select Country Matches, then select the Country matching your company.

Next, create a report line by clicking the Add a line. Once created, click that report line to configure it:

  • Click Add a line again to create an Expression and name it.

  • In the Definition tab, select a Computation Engine for that expression depending on the following scenarios:

In this scenario, your company uses tax grids:

  • Select Tax Tags as the computation engine. Odoo uses this field to link the report line to your taxes.

  • In the Formula field, type your short grid identifier (e.g., vat_sales_base). Odoo automatically generates the + and - variants of this tag for you to map inside Configuration ‣ Taxes.

  • In the Subformula field, enter either base to report the untaxed amount, or tax to report the actual tax amount collected/paid.

Repeat this process as necessary. Then, Save & Close.

Alternatively, you can:

  • Select Aggregate Other Formulas as the computation engine. Odoo uses this field to perform math on lines already present in the report rather than scanning raw transactions.

  • In the Formula field, use basic algebra referencing your line codes (e.g., LINE_10 - LINE_20).

Repeat this process as necessary. Then, Save & Close.

In the Options tab of an Expression, populate the Carry Over To field with a formula to always carry over balances or only carry them over when the amount is negative. Leave this field blank if you do not want to use this feature.

Example

if_below(EUR(0))
This formula will only carry over amounts below 0.00 EUR.

Tax configuration

Next, go to Configuration ‣ Taxes and click New to create and configure new taxes for your custom tax report. Create your Sales and Purchases taxes, and populate the Tax Grids for all taxes using the matching tax grids you created earlier. Finally, make sure to specify both a tax payable and tax receivable account for each tax.

Example

Tax grids configuration.

Closing entry

To close taxes, a tax group must be specified on each tax used in your custom tax report. To do this, open the Accounting app, navigate to Configuration ‣ Taxes, open a tax that requires a tax group, click the Advanced Options tab, and select a group in the Tax Group field. Once assigned, click the (right arrow) icon and set both a Tax Payable Account and a Tax Receivable Account.

小訣竅

  • When everything has been set up, make sure to test your report by creating invoices, bills, and credit notes using the taxes specific to that report. Finally, test the closing entry itself.

  • If you want to hide a specific account from displaying in the tax closing entry, go to Configuration ‣ Taxes, select the tax, and click the (settings adjust) icon. From there, check the Tax Closing Entry box to adjust its visibility.

其他資料

Tax closing