@@ -3,20 +3,21 @@ Custom reports
3
3
==============
4
4
5
5
Odoo comes with a powerful and easy-to-use reporting framework. The engine allows you to create new
6
- reports, such as ** tax reports **, or ** balance sheets ** and ** income statements ** with ** specific
7
- groupings ** and ** layouts ** .
6
+ reports, such as tax reports, balance sheets, and income statements with specific groupings and
7
+ layouts.
8
8
9
9
.. important ::
10
- Activate the :ref: `developer mode <developer-mode >` to access the accounting report creation
11
- interface .
10
+ Activate the :ref: `developer mode <developer-mode >` to access the accounting report
11
+ configuration .
12
12
13
- To create a new report, go to :menuselection: `Accounting --> Configuration --> Management:
14
- Accounting Reports `. From here, you can either create a :ref: `root report <customize-reports/root >`
15
- or a :ref: ` variant <customize-reports/variants >`.
13
+ To create a new report, go to :menuselection: `Accounting --> Configuration --> Accounting Reports `.
14
+ From here, create either a :ref: `root report <customize-reports/root >` or a :ref: ` variant
15
+ <customize-reports/variants>`.
16
16
17
- .. image :: customize/engine-accounting-reports.png
18
- :align: center
19
- :alt: Accounting reports engine.
17
+ .. tip ::
18
+ - Consider saving modified reports as report variants to keep their root reports intact.
19
+ - To access an existing report's management interface from the report itself, click on the
20
+ :icon: `fa-cogs ` :guilabel: `(gears) ` icon.
20
21
21
22
.. _customize-reports/root :
22
23
@@ -31,18 +32,14 @@ report itself.
31
32
A tax report for Belgium and the US would both use the same generic version as a base and adapt
32
33
it for their domestic regulations.
33
34
34
- When creating a new root report, you need to create a ** menu item ** for it . To do so, open the
35
- report and then, on that same report, click on :menuselection : `Action --> Create Menu Item `. Refresh
36
- the page; the report is now available under :menuselection: `Accounting --> Reporting `.
35
+ Creating a menu item is required to access a new root report . To do so, open the report's
36
+ configuration, click :guilabel : `Action `, :guilabel: ` Create Menu Item `, and refresh the page. The
37
+ report is now available under :menuselection: `Accounting --> Reporting `.
37
38
38
39
.. note ::
39
40
Cases that require creating a new root report are rare, such as when a country's tax authorities
40
41
require a new and specific type of report.
41
42
42
- .. image :: customize/engine-create-menu-item.png
43
- :align: center
44
- :alt: Create Menu Item button.
45
-
46
43
.. _customize-reports/variants :
47
44
48
45
Variants
@@ -52,50 +49,47 @@ Variants are country-specific versions of root reports and, therefore, always re
52
49
report. To create a variant, select a generic (root) report in the :guilabel: `Root Report ` field
53
50
when creating a new report.
54
51
55
- When a root report is opened from one of the accounting app's main menus , all its variants are
56
- displayed in the variant selector in the top right corner of the view.
52
+ When a root report is opened from the Accounting app's :guilabel: ` Reporting ` menu , all of its
53
+ variants are displayed in the report variant selector in the top right corner of the view.
57
54
58
55
.. example ::
59
- In the following image, :guilabel: `VAT Report (BE) ` is the variant of the root :guilabel: `Generic
60
- Tax report `.
56
+ :guilabel: `VAT Report (BE) ` is a variant of the root :guilabel: `Generic Tax report `.
61
57
62
58
.. image :: customize/engine-variant.png
63
- :align: center
64
59
:alt: Report variant selection.
65
60
66
61
Lines
67
62
=====
68
63
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 :guilabel: `Name `, and can have an optional additional
72
- :guilabel: ` Code ` (of your choice) if you wish to use their value in formulas.
64
+ After creating a report (either root or variant), the next step is to fill it with lines. To create
65
+ a new line, click on :guilabel: `Add a line `. To modify an existing line, click on the line itself
66
+ and edit the popup . All lines require a :guilabel: `Name ` and can have an optional :guilabel: ` Code `
67
+ which allows using the line's value in formulas.
73
68
74
69
.. image :: customize/engine-lines-options.png
75
- :align: center
76
70
:alt: Engine lines options.
77
71
78
72
Expressions
79
73
===========
80
74
81
75
Each line can contain one or multiple **expressions **. Expressions can be seen as **sub-variables **
82
- needed by a report line. To create an expression, click on :guilabel: `Add a line ` *within * a line
83
- report .
76
+ needed by a report line. To create an expression, click on :guilabel: `Add a line ` *within * a line's
77
+ popup .
84
78
85
- When creating an expression, you must attribute a :guilabel: `label ` used to refer to that
86
- expression. Therefore, it has to be ** unique ** among the expressions of each line. Both a
87
- :guilabel: ` Computation Engine ` and a :guilabel: `Formula ` must also be indicated . The **engine **
88
- defines how your **formula(s) ** and **subformula(s) ** are interpreted. It is possible to mix
89
- expressions using different computation engines under the same line if you need to .
79
+ When creating an expression, you must enter a :guilabel: `label ` used to refer to that expression.
80
+ The label must be unique among the expressions of each report line. Both the :guilabel: ` Computation
81
+ Engine ` and the :guilabel: `Formula ` fields must also be completed . The **computation engine **
82
+ defines how the **formula(s) ** and **subformula(s) ** are interpreted. It is possible to mix
83
+ expressions using different computation engines under the same line if needed .
90
84
91
85
.. note ::
92
86
Depending on the engine, :guilabel: `subformulas ` may also be required.
93
87
94
- ' Odoo Domain' engine
95
- --------------------
88
+ Odoo Domain computation engine
89
+ ------------------------------
96
90
97
- With this engine, a formula is interpreted as an :ref: `Odoo domain < reference/orm/domains >`
98
- targeting `account.move.line ` objects.
91
+ When using the :guilabel: ` Odoo Domain ` computation engine, a formula is interpreted as an :ref: `Odoo
92
+ domain <reference/orm/domains>` targeting `account.move.line ` objects.
99
93
100
94
The subformula allows you to define how the move lines matching the domain are used to compute the
101
95
value of the expression:
@@ -112,39 +106,39 @@ value of the expression:
112
106
Otherwise, it is `0 `.
113
107
114
108
`count_rows `
115
- The result is the number of sub-lines of this expression. If the parent line has a group-by
116
- value, this will correspond to the number of distinct grouping keys in the matched move lines.
117
- Otherwise, it will be the number of matched move lines.
109
+ The result is the number of sub-lines of this expression. If the parent line has a :ref` group-by
110
+ <customize-reports/lines-group-by>` value, this will correspond to the number of distinct
111
+ grouping keys in the matched move lines. Otherwise, it will be the number of matched move lines.
118
112
119
- You can also put a ` - ` sign at the beginning of the subformula to ** reverse ** the sign of the
120
- result.
113
+ .. tip ::
114
+ To ** reverse ** the sign of the result, put a ` - ` sign at the beginning of the subformula .
121
115
122
116
.. image :: customize/engine-expressions.png
123
- :align: center
124
117
:alt: Expression line within a line report
125
118
126
- ' Tax Tags' engine
127
- -----------------
119
+ Tax Tags computation engine
120
+ ---------------------------
128
121
129
- A formula made for this engine consists of a name used to match tax tags. If such tags do not exist
130
- when creating the expression, they will be created.
122
+ When using the :guilabel: `Tax Tags ` computation engine, the contents of the :guilabel: `Formula `
123
+ field are matched to tax tags. If such tags do not exist when creating the expression, they will be
124
+ created.
131
125
132
126
When evaluating the expression, the expression computation can roughly be expressed as: **(amount of
133
127
the move lines with ** `+ ` **tag) ** `- ` **(amount of the move lines with ** `- ` **tag) **.
134
128
135
129
.. example ::
136
- If the formula is `tag_name `, the engine matches tax tags `+tag_name ` and ` -tag_name `, creating
137
- them if necessary. To exemplify further: two tags are matched by the formula. If the formula
138
- is `A `, it will require (and create, if needed) tags `+A ` and `-A `.
130
+ If the :guilabel: ` Formula ` is set to `tag_name `, the engine matches tax tags `+tag_name ` and
131
+ ` -tag_name `, creating them if necessary. To exemplify further: two tags are matched by the
132
+ formula. If the formula is `A `, it will require (and create, if needed) tags `+A ` and `-A `.
139
133
140
- ' Aggregate Other Formulas' engine
141
- ---------------------------------
134
+ Aggregate Other Formulas computation engine
135
+ -------------------------------------------
142
136
143
- Use this engine when you need to perform arithmetic operations on the amounts obtained for other
144
- expressions. Formulas here are composed of references to expressions separated by one of the four
145
- basic arithmetic operators (addition `+ `, subtraction `- `, division ` / `, and multiplication ` * `). To
146
- refer to an expression, type in its parent line's **code ** followed by a period ` . ` and the
147
- expression's **label ** (ex. **code.label **).
137
+ The :guilabel: ` Aggregate Other Formulas ` computation engine performs arithmetic operations on the
138
+ amounts obtained from other expressions. Formulas here are composed of references to expressions
139
+ separated by one of the four basic arithmetic operators (addition `+ `, subtraction `- `, division
140
+ ` / `, and multiplication ` * `). To refer to an expression, type in its parent line's **code ** followed
141
+ by a period ` . ` and the expression's **label ** (ex. **code.label **).
148
142
149
143
**Subformulas ** can be one of the following:
150
144
@@ -175,11 +169,11 @@ that currency.
175
169
176
170
You can also use the `cross_report ` subformula to match an expression found in another report.
177
171
178
- ' Prefix of Account Codes' engine
179
- --------------------------------
172
+ Prefix of Account Codes computation engine
173
+ ------------------------------------------
180
174
181
- This engine is used to match amounts made on accounts using the prefixes of these accounts' codes as
182
- variables in an arithmetic expression.
175
+ The :guilabel: ` Prefix of Account Codes ` computation engine is used to match amounts made on accounts
176
+ using the prefixes of these accounts' codes as variables in an arithmetic expression.
183
177
184
178
.. example ::
185
179
| `21`
@@ -226,9 +220,9 @@ accounts, where the same prefix might be used for different purposes across comp
226
220
227
221
.. example ::
228
222
| `tag(25)`
229
- | This formula matches accounts whose associated tags contain the one with id *25*.
223
+ | This formula matches accounts whose associated tags contain the one with ID *25*.
230
224
231
- If the tag you reference is defined in a data file, an xmlid can be used instead of the id .
225
+ If the tag you reference is defined in a data file, an XMLID can be used instead of the ID .
232
226
233
227
.. example ::
234
228
| `tag(my_module.my_tag)`
@@ -255,14 +249,13 @@ Prefix exclusion also works with tags.
255
249
| This formula matches accounts with the tag *my_module.my_tag* and a code not starting with
256
250
`10`.
257
251
252
+ External Value computation engine
253
+ ---------------------------------
258
254
259
- 'External Value' engine
260
- -----------------------
261
-
262
- The 'external value' engine is used to refer to **manual ** and **carryover values **. Those values
263
- are not stored using `account.move.line `, but with `account.report.external.value `. Each of these
264
- objects directly points to the expression it impacts, so very little needs to be done about their
265
- selection here.
255
+ The :guilabel: `External Value ` computation engine is used to refer to **manual ** and **carryover
256
+ values **. Those values are not stored using `account.move.line `, but with
257
+ `account.report.external.value `. Each of these objects directly points to the expression it impacts,
258
+ so very little needs to be done about their selection here.
266
259
267
260
**Formulas ** can be one of the following:
268
261
@@ -288,15 +281,16 @@ Both subformulas can be mixed by separating them with a `;`.
288
281
289
282
.. example ::
290
283
| `editable;rounding=2`
291
- | is a correct subformula mixing both behaviors.
284
+ | This subformula shows the correct way to mix both behaviors.
292
285
293
- ' Custom Python Function' engine
294
- -------------------------------
286
+ Custom Python Function computation engine
287
+ -----------------------------------------
295
288
296
- This engine is a means for developers to introduce custom computation of expressions on a
297
- case-by-case basis. The formula is the name of a **python function ** to call, and the subformula is
298
- a **key ** to fetch in the **dictionary ** returned by this function. Use it only if you are making a
299
- custom module of your own.
289
+ The :guilabel: `Custom Python Function ` computation engine is a means for developers to introduce
290
+ custom computation of expressions on a case-by-case basis. The :guilabel: `Formula ` is the name of a
291
+ **python function ** to call, and the :guilabel: `Subformula ` is a **key ** to fetch in the
292
+ **dictionary ** returned by this function. Use this computation engine only if making a custom
293
+ module.
300
294
301
295
Columns
302
296
=======
@@ -308,8 +302,60 @@ field, then nothing is displayed for it in this column. If multiple columns are
308
302
use different **expression ** labels.
309
303
310
304
.. image :: customize/engine-columns.png
311
- :align: center
312
305
:alt: Columns of report.
313
306
314
307
When using the **period comparison ** feature found under the :guilabel: `Options ` tab of an
315
308
accounting report, all columns are repeated in and for each period.
309
+
310
+ .. _customize-reports/lines-group-by :
311
+
312
+ Line grouping
313
+ =============
314
+
315
+ Once the report is filled with lines, the lines can be grouped. To do so, choose which field to
316
+ group by. Any field can be used, even if it does not exist in the journal item model yet.
317
+
318
+ .. important ::
319
+ The field must be on the journal item model, be non-stored, and be related to the model and field
320
+ you want to group by (i.e., related to the res.country model and the
321
+ partner_id.commercial_partner_id.country_id field) in order to group by the country of the
322
+ commercial partner.
323
+
324
+ .. note ::
325
+ Grouping lines requires the report to have explicit report lines that can be edited. The deferred
326
+ reports, for example, do not support grouping lines as they use dynamic lines that are generated.
327
+
328
+ Create a new field on journal item
329
+ ----------------------------------
330
+
331
+ To create a non-stored related field in the journal item model, first go to
332
+ :menuselection: `Accounting --> Journal Items `, and click the :icon: `fa-bug ` :guilabel: `(bug) ` icon,
333
+ then click :guilabel: `Fields `. Click :guilabel: `New ` to create a new field, and complete the
334
+ following fields:
335
+
336
+ - :guilabel: `Field Name `: the technical name of the field
337
+ - :guilabel: `Field Label `: the displayed label of the field
338
+ - :guilabel: `Field Type `: :guilabel: `one2many `, :guilabel: `many2many `, or :guilabel: `many2one `
339
+ - :guilabel: `Readonly `: while not strictly necessary, it is recommended to use readonly fields for
340
+ grouping lines
341
+ - :guilabel: `Stored `: leave this field unchecked as only non-stored fields can be used to group
342
+ lines
343
+ - :guilabel: `Related Model `: the model of the original field to group by
344
+ - :guilabel: `Related Field Definition `: the technical path to the field you want to group by
345
+
346
+ .. example ::
347
+ To group by the country of the commercial partner, set the related field definition to
348
+ `partner_id.commercial_partner_id.country_id `.
349
+
350
+ Group lines
351
+ -----------
352
+
353
+ To group lines, go to the :guilabel: `Lines ` tab of the desired report, click on the line you want to
354
+ group, and edit the :guilabel: `Group by ` field. Enter the technical name (:guilabel: `Field Name `) of
355
+ the field to use as the grouping key.
356
+
357
+ .. tip ::
358
+ To find a list of all the model's fields and their technical names, go to
359
+ :menuselection: `Accounting --> Journal Items `, and click the :icon: `fa-bug ` :guilabel: `(bug) `
360
+ icon, then click :guilabel: `Fields `. The technical name of each field is listed in the
361
+ :guilabel: `Field Name ` column.
0 commit comments