Skip to content

Commit 5191640

Browse files
committed
[IMP] accounting: full documentation of the new report engine
1 parent 4de66e2 commit 5191640

File tree

9 files changed

+170
-51
lines changed

9 files changed

+170
-51
lines changed
Lines changed: 166 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,208 @@
11
==================================================
2-
Create a customized reports with your own formulas
2+
Create a customized report with your own formulas
33
==================================================
44

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

8-
Odoo 13 comes with a powerful and easy-to-use reporting framework.
8+
Odoo comes with a powerful and easy-to-use reporting framework.
99
Creating new reports (such as a tax report or a balance sheet or
1010
income statement with specific groupings and layout ) to suit your
1111
needs is now easier than ever.
1212

1313
Activate the developer mode
1414
===========================
1515

16-
In order to have access to the financial report creation interface, the
16+
In order to have access to the accounting report creation interface, the
1717
:ref:`developer mode <developer-mode>` needs to be activated.
1818

19-
Create your financial report
19+
Create your report
2020
============================
2121

22-
First, you need to create your financial report. To do that, go to
23-
:menuselection:`Accounting --> Configuration --> Financial Reports`
22+
You can define your own reports by going to
23+
:menuselection:`Accounting --> Configuration --> Accounting Reports`
2424

2525
.. image:: customize/customize02.png
2626
:align: center
2727

28-
Once the name is entered, there are two other parameters that need to be
29-
configured:
28+
Report Variants
29+
================
3030

31-
- **Show Credit and Debit Columns**
31+
A report can either be a root report or a variant.
3232

33-
- **Analysis Period** :
33+
A variant always refers to a root report. When a report is open, all
34+
the variants available for its root are displayed in the variant selector,
35+
in the top right corner of the view.
3436

35-
- Based on date ranges (e.g. Profit and Loss)
36-
37-
- Based on a single date (e.g. Balance Sheet)
37+
.. image:: customize/report_variants.png
38+
:align: center
3839

39-
- Based on date ranges with 'older' and 'total' columns and last 3
40-
months (e.g. Aged Partner Balances)
40+
If a report has no root report, it is considered to be a root report itself.
41+
When creating a new root report, you need to add a menu item for it. To do this
42+
automatically, you can go to :menuselection:`Action --> Create Menu Item` after
43+
saving the report. Refresh the page, and the report will be available directly
44+
under
45+
:menuselection:`Accounting --> Reporting`
4146

42-
- Bases on date ranges and cash basis method (e.g. Cash Flow
43-
Statement)
47+
.. seealso::
48+
List of built-in root reports:
49+
:doc:`main_reports`
4450

45-
Add lines in your custom reports
46-
=================================
51+
Lines
52+
======
4753

4854
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).
55+
all need a **name**. You can also give them a **code** if you wish to use their
56+
value in some formula. Multiple options are also available to change the way the line is displayed.
57+
58+
.. image:: customize/account_report_line_form.png
59+
:align: center
5160

52-
.. image:: customize/customize04.png
61+
Expressions
62+
============
63+
64+
Each report line can declare multiple expressions. An expression can basically be seen as a
65+
subvariable needed by a report line.
66+
67+
.. image:: customize/account_report_expression_form.png
5368
:align: center
5469

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 ;)
70+
When creating an expression, you need to give it a **label**. This label must be unique amongst the
71+
expressions of each line, and is used to refer to it. You also must provide an **engine** and **formula**
72+
(as well, depending on the engine, as a **subformula**).
5873

59-
You have several objects available in the formula :
74+
The **engine** defines how your **formula** and **subformula** will be intepreted. Of course, you are free to mix
75+
expressions using different engines under the same line if you need to.
6076

61-
- ``Ndays`` : The number of days in the selected period (for reports with a
62-
date range).
77+
'Odoo Domain' engine
78+
---------------------
6379

64-
- Another report, referenced by its code. Use ``.balance`` to get its
65-
balance value (also available are ``.credit``, ``.debit`` and
66-
``.amount_residual``)
80+
With this engine, a formula will be interpreted as an :ref:`Odoo domain <reference/orm/domains>` targeting account.move.line objects.
6781

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.
82+
The subformula allows you defining how the move lines matching the domain will be used to compute the value of the expression:
83+
- **sum** : The result is the sum of all the balances of the matched move lines
7484

75-
Other useful fields :
85+
- **sum_if_pos** : The result is the sum of all the balances of the matched move lines if this amount is positive. Else, it's 0.
7686

77-
- **Type** : Type of the result of the formula.
87+
- **sum_if_neg** : The result is the sum of all the balances of the matched move lines if this amount is negative. Else, it's 0.
7888

79-
- **Is growth good when positive** : Used when computing the comparison
80-
column. Check if growth is good (displayed in green) or not.
89+
- **count_rows** : The result is the number of sublines of this expression. If the parent line has a groupby value, this will coresponds
90+
to the number of distinct grouping keys in the matched move lines. Else, it will be the number of matched move lines.
8191

82-
- **Special date changer** : If a specific line in a report should not use
83-
the same dates as the rest of the report.
92+
You can also put a '-' sign at the beginning of the subformula to invert the sign of the result.
8493

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).
94+
'Tax Tags' engine
95+
------------------
8896

89-
.. seealso::
90-
* :doc:`main_reports`
97+
A formula made for this engine consists of a name used to match tax tags. If such tags don't exist when creating the expression, they will be created.
98+
99+
.. example::
100+
If formula is **tag_name**, the engine will match tax tags **+tag_name** and **-tag_name**, creating them if necessary.
101+
102+
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).
103+
104+
'Aggregate Other Formulas' engine
105+
----------------------------------
106+
107+
Use this engine when you need to perform some arithmetic operation on the amounts obtained for other expressions.
108+
Formula can be any expression with +, -, / and * operator. To refer to an expression, use the code of its parent line and its label, like this: **CODE.label**.
109+
110+
**subformula** can be one of the following:
111+
112+
- **if_above(CUR(amount))**: The value of the arithmetic expression will be returned only if it's greater than the provided bound. Else, the result will be 0.
113+
114+
- **if_below(CUR(amount))**: The value of the arithmetic expression will be returned only if it's lower than the provided bound. Else, the result will be 0.
115+
116+
- **if_between(CUR1(amount1), CUR2(amount2))**: The value of the arithmetic expression will be returned only if it's strictly between the provided bounds.
117+
Else, it will be brought back to the closest bound.
118+
119+
Where **CUR** is a currency code in capital letters, and **amount** is the amount of the bound, expressed in this currency.
120+
121+
You can also use the **cross_report** subformula to match if your expression refers to an expression defined in another report.
122+
123+
'Prefix of Account Codes' engine
124+
---------------------------------
125+
126+
This engine is used to match amounts put on accounts using the prefixes of these accounts' codes as variables in an arithmetic expression.
127+
128+
.. example::
129+
**21 + 10 - 5**
130+
will add the balances of the move lines made on accounts whose codes start with '21' and '10', and substract the balance of the ones on
131+
the accounts prefixed '5'.
132+
133+
It is also possible to ignore some subprefixes.
134+
135+
.. example::
136+
**21 + 10\\(101, 102) - 5\\(57)**
137+
will do the same as the previous example, but ignoring the prefixes '101', '102' and '57'.
138+
139+
You can apply finer treatment on debits/credits using C and D suffixes. In this case, an account will only be considered if its prefix
140+
matches and the total balance of the move lines made on this account is credit/debit.
141+
142+
.. example::
143+
Account 210001 has a balance of -42 and account 210002 has a balance of 25.
144+
The formula **21D** will only match account 210002, and hence return 25. 210001 will not be matched, as its balance is credit.
145+
146+
It is of course possible to mix prefix exclusion with D/C suffixes.
147+
148+
.. example::
149+
**21D + 10\\(101, 102)C - 5\\(57)**
150+
151+
To match letter C or D in a prefix and not use it as suffix, use an empty exclusion.
152+
153+
.. example::
154+
**21D\\()**
155+
will match accounts whose code starts with '21D', regardless of their balance sign.
156+
157+
'External Value' engine
158+
------------------------
159+
160+
The 'external value' engine is used to refer to manual and carryover values. Those values are note stored using account.move.line, but
161+
with another object (account.report.external.value). Each of these objects directly points to the expression it impacts, so very few
162+
needs to be done about their selection here.
163+
164+
**formula** can be one of the following:
165+
166+
- **sum** : If the result must be the sum of all the external values in the period.
167+
168+
- **most_recent**: If the result must be the value of the latest external value in the period.
169+
170+
In addition, **subformula** can be used in two ways:
171+
172+
- **rounding=X** : Replacing X by a number, will tell to round the amount to X decimals
173+
174+
- **editable** : Will tell this expression can be edited manually, triggering the display of an icon in the report allowing the user to
175+
perform this action.
176+
177+
Both those subformulas can be mixed, by separating them with a ';'.
178+
179+
.. example::
180+
**editable;rounding=2**
181+
is a correct subformula, mixing both behaviors.
182+
183+
'Custom Python Function' engine
184+
--------------------------------
185+
186+
This engine is a means for developers to introduce custom computation of expressions on a case-by-case basis. The formula is then the name of
187+
a python function to call, and subformula is a key to fetch in the dictionary returned by this function. Use it only if you are making a custom
188+
module of your own.
189+
190+
Columns
191+
=======
192+
193+
Each report can define any number of columns to display.
194+
195+
.. image:: customize/account_report_form_columns.png
196+
:align: center
197+
198+
Each column gets its values from the expressions declared on the lines. The field **expression_label** of the column gives the label of the
199+
expressions whose value will be displayed. If a line has no expression with this label, then nothing will be displayed for it in this column. If you need
200+
multiple columns, you just have to use different expression labels; it's that simple !
201+
202+
.. image:: customize/multicolumn_example.png
203+
:align: center
204+
205+
When using the period comparison feature, the whole block of columns will be repeated in each period.
206+
207+
.. image:: customize/multicolumn_comparison.png
208+
:align: center
18.6 KB
Loading
21.5 KB
Loading
25.6 KB
Loading
45 KB
Loading
12.1 KB
Loading
21.2 KB
Loading
27 KB
Loading

content/developer/howtos/accounting_localization.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,8 @@ 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:
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.
379379

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>`_
380+
.. example ::
381+
* `ir.ui.menu creation <{GITHUB_PATH}/addons/l10n_be/data/menuitem_data.xml>`_
382+
* `ir.actions.client and menu item creation <{GITHUB_ENT_PATH}/l10n_be_reports/data/partner_vat_listing.xml>`_

0 commit comments

Comments
 (0)