[IMP] accounting: full documentation of the new report engine
Engine report for accounting.
closes odoo/documentation#3226
Taskid: 3042880
X-original-commit: bf2d3d9ed2
Signed-off-by: Castillo Jonathan (jcs) <jcs@odoo.com>
@ -1,90 +1,269 @@
|
|||||||
==================================================
|
========================================
|
||||||
Create a customized reports with your own formulas
|
Create a report with customized formulas
|
||||||
==================================================
|
========================================
|
||||||
|
|
||||||
Overview
|
Odoo comes with a powerful and easy-to-use reporting framework. The engine allows you to create new
|
||||||
|
reports, such as **tax reports**, or **balance sheets** and **income statements** with **specific
|
||||||
|
groupings** and **layouts**.
|
||||||
|
|
||||||
|
.. important::
|
||||||
|
Activate the :ref:`developer mode <developer-mode>` to access the accounting report creation
|
||||||
|
interface.
|
||||||
|
|
||||||
|
To create a new report, go to :menuselection:`Accounting --> Configuration --> Management:
|
||||||
|
Accounting Reports`. From here, you can either create a :ref:`root report <customize-reports/root>`
|
||||||
|
or a :ref:`variant <customize-reports/variants>`.
|
||||||
|
|
||||||
|
.. image:: customize/engine-accounting-reports.png
|
||||||
|
:align: center
|
||||||
|
:alt: Accounting reports engine.
|
||||||
|
|
||||||
|
.. _customize-reports/root:
|
||||||
|
|
||||||
|
Root reports
|
||||||
|
============
|
||||||
|
|
||||||
|
Root reports can be regarded as generic, neutral accounting reports. They serve as models on which
|
||||||
|
local accounting versions are built. If a report has no root report, it is considered to be a root
|
||||||
|
report itself.
|
||||||
|
|
||||||
|
.. example::
|
||||||
|
A tax report for Belgium and the US would both use the same generic version as a base and adapt
|
||||||
|
it for their domestic regulations.
|
||||||
|
|
||||||
|
When creating a new root report, you need to create a **menu item** for it. To do so, open the
|
||||||
|
report and then, on that same report, click on :menuselection:`Action --> Create Menu Item`. Refresh
|
||||||
|
the page; the report is now available under :menuselection:`Accounting --> Reporting`.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
Cases that require creating a new root report are rare, such as when a country's tax authorities
|
||||||
|
require a new and specific type of report.
|
||||||
|
|
||||||
|
.. image:: customize/engine-create-menu-item.png
|
||||||
|
:align: center
|
||||||
|
:alt: Create Menu Item button.
|
||||||
|
|
||||||
|
.. _customize-reports/variants:
|
||||||
|
|
||||||
|
Variants
|
||||||
========
|
========
|
||||||
|
|
||||||
Odoo 13 comes with a powerful and easy-to-use reporting framework.
|
Variants are country-specific versions of root reports and, therefore, always refer to a root
|
||||||
Creating new reports (such as a tax report or a balance sheet or
|
report. To create a variant, select a generic (root) report in the :guilabel:`Root Report` field
|
||||||
income statement with specific groupings and layout ) to suit your
|
when creating a new report.
|
||||||
needs is now easier than ever.
|
|
||||||
|
|
||||||
Activate the developer mode
|
When a root report is opened from one of the accounting app's main menus, all its variants are
|
||||||
===========================
|
displayed in the variant selector in the top right corner of the view.
|
||||||
|
|
||||||
In order to have access to the financial report creation interface, the
|
.. example::
|
||||||
:ref:`developer mode <developer-mode>` needs to be activated.
|
In the following image, :guilabel:`VAT Report (BE)` is the variant of the root :guilabel:`Generic
|
||||||
|
Tax report`.
|
||||||
|
|
||||||
Create your financial report
|
.. image:: customize/engine-variant.png
|
||||||
============================
|
|
||||||
|
|
||||||
First, you need to create your financial report. To do that, go to
|
|
||||||
:menuselection:`Accounting --> Configuration --> Financial Reports`
|
|
||||||
|
|
||||||
.. image:: customize/customize02.png
|
|
||||||
:align: center
|
:align: center
|
||||||
|
:alt: Report variant selection.
|
||||||
|
|
||||||
Once the name is entered, there are two other parameters that need to be
|
Lines
|
||||||
configured:
|
=====
|
||||||
|
|
||||||
- **Show Credit and Debit Columns**
|
After having created a report (either root or variant), you need to fill it with lines. You can
|
||||||
|
either create a new one by clicking on :guilabel:`Add a line`, or modify an existing line by
|
||||||
|
clicking on it. All lines *require* a :guilabel:`Name`, and can have an optional additional
|
||||||
|
:guilabel:`Code` (of your choice) if you wish to use their value in formulas.
|
||||||
|
|
||||||
- **Analysis Period** :
|
.. image:: customize/engine-lines-options.png
|
||||||
|
|
||||||
- Based on date ranges (e.g. Profit and Loss)
|
|
||||||
|
|
||||||
- Based on a single date (e.g. Balance Sheet)
|
|
||||||
|
|
||||||
- Based on date ranges with 'older' and 'total' columns and last 3
|
|
||||||
months (e.g. Aged Partner Balances)
|
|
||||||
|
|
||||||
- Bases on date ranges and cash basis method (e.g. Cash Flow
|
|
||||||
Statement)
|
|
||||||
|
|
||||||
Add lines in your custom reports
|
|
||||||
=================================
|
|
||||||
|
|
||||||
After you've created the report, you need to fill it with lines. They
|
|
||||||
all need a **name**, a **code** (that is used to refer to the line), a
|
|
||||||
**sequence number** and a **level** (Used for the line rendering).
|
|
||||||
|
|
||||||
.. image:: customize/customize04.png
|
|
||||||
:align: center
|
:align: center
|
||||||
|
:alt: Engine lines options.
|
||||||
|
|
||||||
In the **formulas** field you can add one or more formulas to assign a
|
Expressions
|
||||||
value to the balance column (and debit and credit column if applicable –
|
===========
|
||||||
separated by ;)
|
|
||||||
|
|
||||||
You have several objects available in the formula :
|
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 :guilabel:`Add a line` *within* a line
|
||||||
|
report.
|
||||||
|
|
||||||
- ``Ndays`` : The number of days in the selected period (for reports with a
|
When creating an expression, you must attribute a :guilabel:`label` used to refer to that
|
||||||
date range).
|
expression. Therefore, it has to be **unique** among the expressions of each line. Both a
|
||||||
|
:guilabel:`Computation Engine` and a :guilabel:`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.
|
||||||
|
|
||||||
- Another report, referenced by its code. Use ``.balance`` to get its
|
.. note::
|
||||||
balance value (also available are ``.credit``, ``.debit`` and
|
Depending on the engine, :guilabel:`subformulas` may also be required.
|
||||||
``.amount_residual``)
|
|
||||||
|
|
||||||
A line can also be based on the sum of account move lines on a selected
|
'Odoo Domain' engine
|
||||||
domain. In which case you need to fill the domain field with an Odoo
|
--------------------
|
||||||
domain on the account move line object. Then an extra object is
|
|
||||||
available in the formulas field, namely ``sum``, the sum of the account
|
|
||||||
move lines in the domain. You can also use the group by field to group
|
|
||||||
the account move lines by one of their columns.
|
|
||||||
|
|
||||||
Other useful fields :
|
With this engine, a formula is interpreted as an :ref:`Odoo domain <reference/orm/domains>`
|
||||||
|
targeting `account.move.line` objects.
|
||||||
|
|
||||||
- **Type** : Type of the result of the formula.
|
The subformula allows you to define how the move lines matching the domain are used to compute the
|
||||||
|
value of the expression:
|
||||||
|
|
||||||
- **Is growth good when positive** : Used when computing the comparison
|
`sum`
|
||||||
column. Check if growth is good (displayed in green) or not.
|
The result is the sum of all the balances of the matched move lines.
|
||||||
|
|
||||||
- **Special date changer** : If a specific line in a report should not use
|
`sum_if_pos`
|
||||||
the same dates as the rest of the report.
|
The result is the sum of all the balances of the matched move lines if this amount is positive.
|
||||||
|
Otherwise, it is `0`.
|
||||||
|
|
||||||
- **Show domain** : How the domain of a line is displayed. Can be foldable
|
`sum_if_neg`
|
||||||
(``default``, hidden at the start but can be unfolded), ``always``
|
The result is the sum of all the balances of the matched move lines if this amount is negative.
|
||||||
(always displayed) or ``never`` (never shown).
|
Otherwise, it is `0`.
|
||||||
|
|
||||||
.. seealso::
|
`count_rows`
|
||||||
* :doc:`main_reports`
|
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.
|
||||||
|
|
||||||
|
You can also put a `-` sign at the beginning of the subformula to **reverse** the sign of the
|
||||||
|
result.
|
||||||
|
|
||||||
|
.. image:: customize/engine-expressions.png
|
||||||
|
:align: center
|
||||||
|
:alt: Expression line within a line report
|
||||||
|
|
||||||
|
'Tax Tags' engine
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
A formula made for this engine consists of a name used to match tax tags. If such tags do not exist
|
||||||
|
when creating the expression, they will be created.
|
||||||
|
|
||||||
|
When evaluating the expression, the expression computation can roughly be expressed as: **(amount of
|
||||||
|
the move lines with** `+` **tag)** `-` **(amount of the move lines with** `-` **tag)**.
|
||||||
|
|
||||||
|
.. example::
|
||||||
|
If the formula is `tag_name`, the engine matches tax tags `+tag_name` and `-tag_name`, creating
|
||||||
|
them if necessary. To exemplify further: two tags are matched by the formula. If the formula
|
||||||
|
is `A`, it will require (and create, if needed) tags `+A` and `-A`.
|
||||||
|
|
||||||
|
'Aggregate Other Formulas' engine
|
||||||
|
---------------------------------
|
||||||
|
|
||||||
|
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 parent line's **code** followed by a period `.` and the
|
||||||
|
expression's **label** (ex. **code.label**).
|
||||||
|
|
||||||
|
**Subformulas** can be one of the following:
|
||||||
|
|
||||||
|
`if_above(CUR(amount))`
|
||||||
|
The value of the arithmetic expression will be returned only if it is greater than the provided
|
||||||
|
bound. Otherwise, the result will be `0`.
|
||||||
|
|
||||||
|
`if_below(CUR(amount))`
|
||||||
|
The value of the arithmetic expression will be returned only if it is lower than the provided
|
||||||
|
bound. Otherwise, the result will be `0`.
|
||||||
|
|
||||||
|
`if_between(CUR1(amount1), CUR2(amount2))`
|
||||||
|
The value of the arithmetic expression will be returned only if it is strictly between the
|
||||||
|
provided bounds. Otherwise, it will be brought back to the closest bound.
|
||||||
|
|
||||||
|
`CUR` is the currency code in capital letters, and `amount` is the amount of the bound expressed in
|
||||||
|
that currency.
|
||||||
|
|
||||||
|
You can also use the `cross_report` subformula to match an expression found in another report.
|
||||||
|
|
||||||
|
'Prefix of Account Codes' engine
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
This engine is used to match amounts made on accounts using the prefixes of these accounts' codes as
|
||||||
|
variables in an arithmetic expression.
|
||||||
|
|
||||||
|
.. example::
|
||||||
|
| `21`
|
||||||
|
| Arithmetic expressions can also be a single prefix, such as here.
|
||||||
|
|
||||||
|
.. example::
|
||||||
|
| `21 + 10 - 5`
|
||||||
|
| This formula adds the balances of the move lines made on accounts whose codes start with `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)`
|
||||||
|
| This formula works the same way as the previous example but ignores the prefixes `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::
|
||||||
|
Account `210001` has a balance of -42 and account `210002` has a balance of 25. The formula
|
||||||
|
`21D` only matches the account `210002`, and hence returns 25. `210001` is not matched, as its
|
||||||
|
balance is *credit*.
|
||||||
|
|
||||||
|
Prefix exclusions can be mixed with the `C` and `D` suffixes.
|
||||||
|
|
||||||
|
.. example::
|
||||||
|
| `21D + 10\\(101, 102)C - 5\\(57)`
|
||||||
|
| This formula adds the balances of the move lines made on accounts whose code starts with `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`.
|
||||||
|
|
||||||
|
To match the letter `C` or `D` in a prefix and not use it as a suffix, use an empty exclusion `()`.
|
||||||
|
|
||||||
|
.. example::
|
||||||
|
| `21D\\()`
|
||||||
|
| This formula matches accounts whose code starts with `21D`, regardless of their balance sign.
|
||||||
|
|
||||||
|
'External Value' engine
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
The 'external value' 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.
|
||||||
|
|
||||||
|
**Formulas** can be one of the following:
|
||||||
|
|
||||||
|
`sum`
|
||||||
|
If the result must be the sum of all the external values in the period.
|
||||||
|
|
||||||
|
`most_recent`
|
||||||
|
If the result must be the value of the latest external value in the period.
|
||||||
|
|
||||||
|
In addition, **subformulas** can be used in two ways:
|
||||||
|
|
||||||
|
`rounding=X`
|
||||||
|
Replacing `X` with a number instructs to round the amount to X decimals.
|
||||||
|
|
||||||
|
`editable`
|
||||||
|
Indicates this expression can be edited manually, triggering the display of an icon in the
|
||||||
|
report, allowing the user to perform this action.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
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`
|
||||||
|
| is a correct subformula mixing both behaviors.
|
||||||
|
|
||||||
|
'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.
|
||||||
|
|
||||||
|
Columns
|
||||||
|
=======
|
||||||
|
|
||||||
|
Reports can have an **indefinite number** of columns to display. Each column gets its values from
|
||||||
|
the **expressions** declared on the **lines**. The field :guilabel:`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.
|
||||||
|
|
||||||
|
.. image:: customize/engine-columns.png
|
||||||
|
:align: center
|
||||||
|
:alt: Columns of report.
|
||||||
|
|
||||||
|
When using the **period comparison** feature found under the :guilabel:`Options` tab of an
|
||||||
|
accounting report, all columns are repeated in and for each period.
|
||||||
|
Before Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 79 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 9.6 KiB |
@ -375,7 +375,15 @@ You can check the meaning of the fields here:
|
|||||||
* :doc:`/developer/reference/standard_modules/account/account_report`
|
* :doc:`/developer/reference/standard_modules/account/account_report`
|
||||||
* :doc:`/developer/reference/standard_modules/account/account_report_line`
|
* :doc:`/developer/reference/standard_modules/account/account_report_line`
|
||||||
|
|
||||||
If you gave a `root_report_id` to your report, it is now available in its variant selector. If not, you still need to add a menu item for it. A default menu item can be created from the form view of the report, by clicking on 'Actions', then 'Create Menu Item'. You'll then need to refresh the page to see it. Alternatively, to create a dedicated section for a totally new report in the :guilabel:`Reporting` menu, you need to create a new `ir.ui.menu` record (usually in the main `l10n_XX` module) and a new `ir.actions.client` (usually in the new report xml file) that calls the `account.report` with the new report id. Then, set the new menu as `parent_id` field in the action model. Example for the Belgian localization:
|
If you gave a `root_report_id` to your report, it is now available in its variant selector. If not,
|
||||||
|
you still need to add a menu item for it. A default menu item can be created from the form view of
|
||||||
|
the report by clicking on :menuselection:`Actions --> Create Menu Item`. You will then need to
|
||||||
|
refresh the page to see it. Alternatively, to create a dedicated section for a totally new report in
|
||||||
|
the :guilabel:`Reporting` menu, you need to create a new `ir.ui.menu` record (usually in the main
|
||||||
|
`l10n_XX` module) and a new `ir.actions.client` (usually in the new report XML file) that calls the
|
||||||
|
`account.report` with the new **report id**. Then, set the new menu as `parent_id` field in the
|
||||||
|
action model.
|
||||||
|
|
||||||
* `ir.ui.menu record in l10n_be <{GITHUB_PATH}/addons/l10n_be/data/menuitem_data.xml>`_
|
.. example::
|
||||||
* `parent_id field in l10n_be_reports (v16) <https://github.com/odoo/enterprise/blob/a1614d0b1460dc453cbe395efba41573d29e7b7e/l10n_be_reports/data/partner_vat_listing.xml#L55-L65>`_
|
* `ir.ui.menu creation <{GITHUB_PATH}/addons/l10n_be/data/menuitem_data.xml>`_
|
||||||
|
* `ir.actions.client and menu item creation <{GITHUB_ENT_PATH}/l10n_be_reports/data/partner_vat_listing.xml>`_
|
||||||
|