Skip to content

Commit f8bf397

Browse files
oco-odootoaa-odoo
authored andcommitted
[IMP] accounting: full documentation of the new report engine
Engine report for accounting. taskid: 4720
1 parent 4de66e2 commit f8bf397

File tree

10 files changed

+228
-62
lines changed

10 files changed

+228
-62
lines changed
Lines changed: 216 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,248 @@
1-
==================================================
2-
Create a customized reports with your own formulas
3-
==================================================
1+
========================================
2+
Customized report with your own formulas
3+
========================================
44

55
Overview
66
========
77

8-
Odoo 13 comes with a powerful and easy-to-use reporting framework.
9-
Creating new reports (such as a tax report or a balance sheet or
10-
income statement with specific groupings and layout ) to suit your
11-
needs is now easier than ever.
8+
Odoo comes with a powerful and easy-to-use reporting framework. The engine allows you to create new
9+
reports, such as **tax reports**, or **balance sheets** and **income statements** with **specific
10+
groupings** and **layouts**.
1211

13-
Activate the developer mode
14-
===========================
12+
Create your report
13+
==================
1514

16-
In order to have access to the financial report creation interface, the
17-
:ref:`developer mode <developer-mode>` needs to be activated.
15+
In order to create a new report, go to :menuselection:`Accounting app --> Configuration -->
16+
Accounting Reports`. From here, you can either create a **root report** or a **variant**.
1817

19-
Create your financial report
20-
============================
18+
.. image:: customize/engine-accounting-reports.png
19+
:align: center
20+
:alt: Accounting reports engine.
21+
22+
.. important::
23+
To access the accounting report creation interface, the :ref:`developer mode <developer-mode>`
24+
has to be activated.
25+
26+
Root reports
27+
------------
2128

22-
First, you need to create your financial report. To do that, go to
23-
:menuselection:`Accounting --> Configuration --> Financial Reports`
29+
Root reports can be regarded as generic, neutral accounting reports. They serve as models on which
30+
local accounting versions are built. A tax report for Belgium and the US would both use the same
31+
generic version as a base and adapt it for their domestic regulations.
2432

25-
.. image:: customize/customize02.png
33+
When creating a new root report, you need to create a **menu item** for it. To do so, **save** your
34+
report and then on that same report, click on :menuselection:`Action --> Create Menu Item`. Refresh
35+
the page and the report is now available under :menuselection:`Accounting --> Reporting`. If a
36+
report has no root report, it is considered to be a root report itself.
37+
38+
.. note::
39+
Cases that require the creation of a new root report are very rare. Only in specific situations
40+
where a country's regulations would require the creation of new, specific report, would a new
41+
root report be necessary.
42+
43+
.. image:: customize/engine-create-menu-item.png
2644
:align: center
45+
:alt: Create Menu Item button.
46+
47+
.. seealso::
48+
List of built-in main :doc:`root reports <../overview/main_reports>`.
49+
50+
Variants
51+
--------
52+
53+
Variants are country's specific versions of root reports and, therefore, always refer to a root
54+
report. To create a variant, simply select a generic (root) report in the :guilabel:`Root Report`
55+
field when creating a new root report.
2756

28-
Once the name is entered, there are two other parameters that need to be
29-
configured:
57+
When an accounting (or root) report is opened from one of the accounting app's main menus, all
58+
variants available for that root are displayed in the variant selector in the top right corner of
59+
the view. In the following image, :guilabel:`VAT Report (BE)` is the variant of the root
60+
:guilabel:`Generic Tax report`.
3061

31-
- **Show Credit and Debit Columns**
62+
.. image:: customize/engine-variant.png
63+
:align: center
64+
:alt: Report variant selection.
3265

33-
- **Analysis Period** :
66+
Lines
67+
-----
3468

35-
- Based on date ranges (e.g. Profit and Loss)
69+
After having created a report (either root or variant), you need to fill it with lines. You can
70+
either create a new one by clicking on :guilabel:`Add a line`, or modify an existing line by
71+
clicking on it. All lines *require* a **name**, and can have an optional additional **code** (of
72+
your choice) if you wish to use their value in formulas.
3673

37-
- Based on a single date (e.g. Balance Sheet)
74+
Further options can be accessed by clicking on an existing line.
75+
76+
.. image:: customize/engine-lines-options.png
77+
:align: center
78+
:alt: Engine lines options.
3879

39-
- Based on date ranges with 'older' and 'total' columns and last 3
40-
months (e.g. Aged Partner Balances)
80+
Expressions
81+
-----------
4182

42-
- Bases on date ranges and cash basis method (e.g. Cash Flow
43-
Statement)
83+
Each line can contain one or multiple **expressions**. Expressions can be seen as **sub-variables**
84+
needed by a report line. To access an expression, click on a line.
4485

45-
Add lines in your custom reports
46-
=================================
86+
When creating an expression, you must attribute a **label** used to refer to that expression.
87+
Therefore, it has to be **unique** among the expressions of each line. Both a
88+
:guilabel:`Computation engine` and a :guilabel:`formula` must also be indicated. The **engine**
89+
defines how your **formula(s)** and **subformula(s)** are interpreted. It is possible to mix
90+
expressions using different computation engines under the same line if you need to.
4791

48-
After you've created the report, you need to fill it with lines. They
49-
all need a **name**, a **code** (that is used to refer to the line), a
50-
**sequence number** and a **level** (Used for the line rendering).
92+
.. note::
93+
Depending on the engine, :guilabel:`subformulas` may also be required.
5194

52-
.. image:: customize/customize04.png
95+
.. image:: customize/engine-expressions.png
5396
:align: center
97+
:alt: Engine expressions.
5498

55-
In the **formulas** field you can add one or more formulas to assign a
56-
value to the balance column (and debit and credit column if applicable –
57-
separated by ;)
99+
'Odoo Domain' engine
100+
~~~~~~~~~~~~~~~~~~~~
58101

59-
You have several objects available in the formula :
102+
With this engine, a formula is interpreted as an :ref:`Odoo domain <reference/orm/domains>`
103+
targeting `account.move.line` objects.
60104

61-
- ``Ndays`` : The number of days in the selected period (for reports with a
62-
date range).
105+
The subformula allows you to define how the move lines matching the domain are used to compute the
106+
value of the expression:
63107

64-
- Another report, referenced by its code. Use ``.balance`` to get its
65-
balance value (also available are ``.credit``, ``.debit`` and
66-
``.amount_residual``)
108+
- **sum** : The result is the sum of all the balances of the matched move lines;
67109

68-
A line can also be based on the sum of account move lines on a selected
69-
domain. In which case you need to fill the domain field with an Odoo
70-
domain on the account move line object. Then an extra object is
71-
available in the formulas field, namely ``sum``, the sum of the account
72-
move lines in the domain. You can also use the group by field to group
73-
the account move lines by one of their columns.
110+
- **sum_if_pos** : The result is the sum of all the balances of the matched move lines if this
111+
amount is positive. Else, it's `0`;
74112

75-
Other useful fields :
113+
- **sum_if_neg** : The result is the sum of all the balances of the matched move lines if this
114+
amount is negative. Else, it's `0`;
76115

77-
- **Type** : Type of the result of the formula.
116+
- **count_rows** : The result is the number of sub-lines of this expression. If the parent line has
117+
a group-by value, this will correspond to the number of distinct grouping keys in the matched move
118+
lines. Else, it will be the number of matched move lines.
78119

79-
- **Is growth good when positive** : Used when computing the comparison
80-
column. Check if growth is good (displayed in green) or not.
120+
You can also put a `-` sign at the beginning of the subformula to **invert** the sign of the
121+
result.
81122

82-
- **Special date changer** : If a specific line in a report should not use
83-
the same dates as the rest of the report.
123+
'Tax Tags' engine
124+
~~~~~~~~~~~~~~~~~
84125

85-
- **Show domain** : How the domain of a line is displayed. Can be foldable
86-
(``default``, hidden at the start but can be unfolded), ``always``
87-
(always displayed) or ``never`` (never shown).
126+
A formula made for this engine consists of a name used to match tax tags. If such tags do not exist
127+
when creating the expression, they will be created.
88128

89-
.. seealso::
90-
* :doc:`main_reports`
129+
.. example::
130+
If the formula is **tag_name**, the engine matches tax tags **+tag_name** and **-tag_name**,
131+
creating them if necessary.
132+
133+
When evaluating the expression, the expression computation can roughly be expressed as: **(amount of
134+
the move lines with** `+` **tag)** `-` **(amount of the move lines with** `-` **tag)**.
135+
136+
'Aggregate Other Formulas' engine
137+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
138+
139+
Use this engine when you need to perform arithmetic operations on the amounts obtained for other
140+
expressions. Formula can be any expression with `+`, `-`, `/` and `*` operator. To refer to an
141+
expression, use the code of its **parent line** and its **label** (ex. **CODE.label**).
142+
143+
**Subformulas** can be one of the following:
144+
145+
- **if_above(CUR(amount))**: The value of the arithmetic expression will be returned only if it's
146+
greater than the provided bound. Else, the result will be `0`;
147+
148+
- **if_below(CUR(amount))**: The value of the arithmetic expression will be returned only if it's
149+
lower than the provided bound. Else, the result will be `0`;
150+
151+
- **if_between(CUR1(amount1), CUR2(amount2))**: The value of the arithmetic expression will be
152+
returned only if it's strictly between the provided bounds. Else, it will be brought back to the
153+
closest bound.
154+
155+
`CUR` is the currency code in capital letters, and `amount` is the amount of the bound expressed in
156+
that currency.
157+
158+
You can also use the `cross_report` subformula to match, if your expression refers to an expression
159+
defined in another report.
160+
161+
'Prefix of Account Codes' engine
162+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
163+
164+
This engine is used to match amounts made on accounts using the prefixes of these accounts' codes as
165+
variables in an arithmetic expression.
166+
167+
.. example::
168+
| **21 + 10 - 5**
169+
| Adds the balances of the move lines made on accounts whose codes start with `21` and `10`, and
170+
subtract the balance of the ones on the accounts with the prefix `5`.
171+
172+
It is also possible to ignore a selection of sub-prefixes.
173+
174+
.. example::
175+
| **21 + 10\\(101, 102) - 5\\(57)**
176+
| Does the same as the previous example, but ignoring the prefixes `101`, `102` and `57`.
177+
178+
You can apply 'sub-filtering' on **credits and debits** using `C` and `D` suffixes. In this case, an
179+
account will only be considered if its prefix matches, *and* if the total balance of the move lines
180+
made on this account is **credit/debit**.
181+
182+
.. example::
183+
Account `210001` has a balance of -42 and account `210002` has a balance of 25. The formula
184+
**21D** only matches the account `210002`, and hence return 25. `210001` is not matched, as its
185+
balance is *credit*.
186+
187+
Prefix exclusions can be mixed with `C` and `D` suffixes.
188+
189+
.. example::
190+
**21D + 10\\(101, 102)C - 5\\(57)**
191+
192+
To match the letter `C` or `D` in a prefix and not use it as suffix, use an *empty* exclusion.
193+
194+
.. example::
195+
| **21D\\()**
196+
| Matches accounts whose code starts with `21D`, regardless of their balance sign.
197+
198+
'External Value' engine
199+
~~~~~~~~~~~~~~~~~~~~~~~
200+
201+
The 'external value' engine is used to refer to **manual** and **carryover values**. Those values
202+
are not stored using `account.move.line`, but with `account.report.external.value`. Each of these
203+
objects directly points to the expression it impacts, so very little needs to be done about their
204+
selection here.
205+
206+
**Formulas** can be one of the following:
207+
208+
- **sum** : If the result must be the sum of all the external values in the period;
209+
210+
- **most_recent**: If the result must be the value of the latest external value in the period.
211+
212+
In addition, **subformulas** can be used in two ways:
213+
214+
- **rounding=X** : Replacing **'X'** by a number, instructs to round the amount to X decimals;
215+
216+
- **editable** : indicates this expression can be edited manually, triggering the display of an icon
217+
in the report, allowing the user to perform this action.
218+
219+
Both subformulas can be mixed, by separating them with a `;`.
220+
221+
.. example::
222+
**editable;rounding=2**
223+
| Is a correct subformula mixing both behaviors.
224+
225+
'Custom Python Function' engine
226+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
227+
228+
This engine is a means for developers to introduce custom computation of expressions on a
229+
case-by-case basis. The formula is the name of a **python function** to call, and the subformula is
230+
a **key** to fetch in the **dictionary** returned by this function. Use it only if you are making a
231+
custom module of your own.
232+
233+
Columns
234+
-------
235+
236+
Reports can have an **indefinite number** of columns to display. Each column gets its values from
237+
the **expressions** declared on the **lines**. The field :guilabel:`expression_label` of the column
238+
gives the label of the expressions whose value is displayed. If a line has no **expression** in that
239+
field, then nothing is displayed for it in this column. If multiple columns are required, you must
240+
use different **expression** labels.
241+
242+
.. image:: customize/engine-columns.png
243+
:align: center
244+
:alt: Columns of report.
245+
246+
When using the **period comparison** feature found under :menuselection:`Configuration -->
247+
Accounting Reports --> (Report you wish to use) --> Options`, all columns are repeated in and for
248+
each period.
Binary file not shown.
Binary file not shown.
79 KB
Loading
15.3 KB
Loading
5.24 KB
Loading
9.06 KB
Loading
41.6 KB
Loading
9.65 KB
Loading

content/developer/howtos/accounting_localization.rst

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,15 @@ You can check the meaning of the fields here:
375375
* :doc:`/developer/reference/standard_modules/account/account_report`
376376
* :doc:`/developer/reference/standard_modules/account/account_report_line`
377377

378-
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:
379-
380-
* `ir.ui.menu record in l10n_be <{GITHUB_PATH}/addons/l10n_be/data/menuitem_data.xml>`_
381-
* `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>`_
378+
If you gave a `root_report_id` to your report, it is now available in its variant selector. If not,
379+
you still need to add a menu item for it. A default menu item can be created from the form view of
380+
the report, by clicking on :menuselection:`Actions --> Create Menu Item'. You will then need to
381+
refresh the page to see it. Alternatively, to create a dedicated section for a totally new report in
382+
the :guilabel:`Reporting` menu, you need to create a new `ir.ui.menu` record (usually in the main
383+
`l10n_XX` module) and a new `ir.actions.client` (usually in the new report .XML file) that calls the
384+
`account.report` with the new **report id**. Then, set the new menu as `parent_id` field in the
385+
action model.
386+
387+
.. example ::
388+
* `ir.ui.menu creation <{GITHUB_PATH}/addons/l10n_be/data/menuitem_data.xml>`_
389+
* `ir.actions.client and menu item creation <{GITHUB_ENT_PATH}/l10n_be_reports/data/partner_vat_listing.xml>`_

0 commit comments

Comments
 (0)