|
1 | | -================================================== |
2 | | -Create a customized reports with your own formulas |
3 | | -================================================== |
| 1 | +======================================== |
| 2 | +Customized report with your own formulas |
| 3 | +======================================== |
4 | 4 |
|
5 | 5 | Overview |
6 | 6 | ======== |
7 | 7 |
|
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**. |
12 | 11 |
|
13 | | -Activate the developer mode |
14 | | -=========================== |
| 12 | +.. important:: |
| 13 | + To access the accounting report creation interface, the :ref:`developer mode <developer-mode>` |
| 14 | + has to be activated. |
15 | 15 |
|
16 | | -In order to have access to the financial report creation interface, the |
17 | | -:ref:`developer mode <developer-mode>` needs to be activated. |
| 16 | +Create your report |
| 17 | +================== |
18 | 18 |
|
19 | | -Create your financial report |
20 | | -============================ |
| 19 | +In order to create a new report, go to :menuselection:`Accounting app --> Configuration --> |
| 20 | +Accounting Reports`. From here, you can either create a **root report** or a **variant**. |
21 | 21 |
|
22 | | -First, you need to create your financial report. To do that, go to |
23 | | -:menuselection:`Accounting --> Configuration --> Financial Reports` |
| 22 | +.. image:: customize/engine-create-report.png |
| 23 | + :align: center |
| 24 | + :alt: Accounting reports engine. |
| 25 | + |
| 26 | +Variants |
| 27 | +-------- |
| 28 | + |
| 29 | +A variant always refers to a root report. When a report is open, all the variants available for its |
| 30 | +root are displayed in the variant selector in the top right corner of the view. In the following |
| 31 | +image, :guilabel:`Generic Tax report` is the only variant. |
24 | 32 |
|
25 | | -.. image:: customize/customize02.png |
| 33 | +.. image:: customize/engine-variant.png |
26 | 34 | :align: center |
| 35 | + :alt: Report variant selection. |
27 | 36 |
|
28 | | -Once the name is entered, there are two other parameters that need to be |
29 | | -configured: |
| 37 | +Root reports |
| 38 | +------------ |
| 39 | + |
| 40 | +If a report has no root report, it is considered to be a root report itself. When creating a new |
| 41 | +root report, you need to create a **menu item** for it. To do so, **save** your report and then on |
| 42 | +that same report, click on :menuselection:`Action --> Create Menu Item`. When done, refresh the page |
| 43 | +and the report is now available under :menuselection:`Accounting --> Reporting`. |
| 44 | + |
| 45 | +.. image:: customize/engine-create-menu-item.png |
| 46 | + :align: center |
| 47 | + :alt: Create Menu Item button. |
30 | 48 |
|
31 | | -- **Show Credit and Debit Columns** |
| 49 | +.. seealso:: |
| 50 | + List of built-in main :doc:`root reports <../overview/main_reports>`. |
32 | 51 |
|
33 | | -- **Analysis Period** : |
| 52 | +Lines |
| 53 | +----- |
34 | 54 |
|
35 | | - - Based on date ranges (e.g. Profit and Loss) |
| 55 | +After having created a report, you need to fill it with lines. You can either create a new one by |
| 56 | +clicking on :guilabel:`Add a line`, or modify an existing line by clicking on it. All lines |
| 57 | +*require* a **name**, and can have an optional additional **code** (of your choice) if you wish to |
| 58 | +use their value in formulas. |
36 | 59 |
|
37 | | - - Based on a single date (e.g. Balance Sheet) |
| 60 | +Further options can be accessed by clicking on an existing line. |
| 61 | + |
| 62 | +.. image:: customize/engine-lines-options.png |
| 63 | + :align: center |
| 64 | + :alt: Engine lines options. |
38 | 65 |
|
39 | | - - Based on date ranges with 'older' and 'total' columns and last 3 |
40 | | - months (e.g. Aged Partner Balances) |
| 66 | +Expressions |
| 67 | +----------- |
41 | 68 |
|
42 | | - - Bases on date ranges and cash basis method (e.g. Cash Flow |
43 | | - Statement) |
| 69 | +Each line can contain one or multiple **expressions**. Expressions can be seen as **sub-variables** |
| 70 | +needed by a report line. To access an expression, click on a line. |
44 | 71 |
|
45 | | -Add lines in your custom reports |
46 | | -================================= |
| 72 | +When creating an expression, you must attribute a **label** used to refer to that expression. |
| 73 | +Therefore, it has to be **unique** among the expressions of each line. Both a |
| 74 | +:guilabel:`Computation engine` and a :guilabel:`formula` must also be indicated. The **engine** |
| 75 | +defines how your **formula(s)** and **subformula(s)** are interpreted. It is possible to mix |
| 76 | +expressions using different computation engines under the same line if you need to. |
47 | 77 |
|
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). |
| 78 | +.. note:: |
| 79 | + Depending on the engine, :guilabel:`subformulas` may also be required. |
51 | 80 |
|
52 | | -.. image:: customize/customize04.png |
| 81 | +.. image:: customize/engine-expressions.png |
53 | 82 | :align: center |
| 83 | + :alt: Engine expressions. |
54 | 84 |
|
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 ;) |
| 85 | +'Odoo Domain' engine |
| 86 | +~~~~~~~~~~~~~~~~~~~~ |
58 | 87 |
|
59 | | -You have several objects available in the formula : |
| 88 | +With this engine, a formula is interpreted as an :ref:`Odoo domain <reference/orm/domains>` |
| 89 | +targeting `account.move.line` objects. |
60 | 90 |
|
61 | | -- ``Ndays`` : The number of days in the selected period (for reports with a |
62 | | - date range). |
| 91 | +The subformula allows to define how the move lines matching the domain are used to compute the |
| 92 | +value of the expression: |
63 | 93 |
|
64 | | -- Another report, referenced by its code. Use ``.balance`` to get its |
65 | | - balance value (also available are ``.credit``, ``.debit`` and |
66 | | - ``.amount_residual``) |
| 94 | +- **sum** : The result is the sum of all the balances of the matched move lines; |
67 | 95 |
|
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. |
| 96 | +- **sum_if_pos** : The result is the sum of all the balances of the matched move lines if this |
| 97 | + amount is positive. Else, it's `0`; |
74 | 98 |
|
75 | | -Other useful fields : |
| 99 | +- **sum_if_neg** : The result is the sum of all the balances of the matched move lines if this |
| 100 | + amount is negative. Else, it's `0`; |
76 | 101 |
|
77 | | -- **Type** : Type of the result of the formula. |
| 102 | +- **count_rows** : The result is the number of sub-lines of this expression. If the parent line has |
| 103 | + a group-by value, this will correspond to the number of distinct grouping keys in the matched move |
| 104 | + lines. Else, it will be the number of matched move lines. |
78 | 105 |
|
79 | | -- **Is growth good when positive** : Used when computing the comparison |
80 | | - column. Check if growth is good (displayed in green) or not. |
| 106 | +You can also put a `-` sign at the beginning of the subformula to **invert** the sign of the |
| 107 | +result. |
81 | 108 |
|
82 | | -- **Special date changer** : If a specific line in a report should not use |
83 | | - the same dates as the rest of the report. |
| 109 | +'Tax Tags' engine |
| 110 | +~~~~~~~~~~~~~~~~~ |
84 | 111 |
|
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). |
| 112 | +A formula made for this engine consists of a name used to match tax tags. If such tags do not exist |
| 113 | +when creating the expression, they will be created. |
88 | 114 |
|
89 | | -.. seealso:: |
90 | | - * :doc:`main_reports` |
| 115 | +.. example:: |
| 116 | + If the formula is **tag_name**, the engine matches tax tags **+tag_name** and **-tag_name**, |
| 117 | + creating them if necessary. |
| 118 | + |
| 119 | +When evaluating the expression, the expression computation can roughly be expressed as: **(amount of |
| 120 | +the move lines with** `+` **tag)** `-` **(amount of the move lines with** `-` **tag)**. |
| 121 | + |
| 122 | +'Aggregate Other Formulas' engine |
| 123 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 124 | + |
| 125 | +Use this engine when you need to perform arithmetic operations on the amounts obtained for other |
| 126 | +expressions. Formula can be any expression with `+`, `-`, `/` and `*` operator. To refer to an |
| 127 | +expression, use the code of its **parent line** and its **label** (ex. **CODE.label**). |
| 128 | + |
| 129 | +**Subformulas** can be one of the following: |
| 130 | + |
| 131 | +- **if_above(CUR(amount))**: The value of the arithmetic expression will be returned only if it's |
| 132 | + greater than the provided bound. Else, the result will be `0`; |
| 133 | + |
| 134 | +- **if_below(CUR(amount))**: The value of the arithmetic expression will be returned only if it's |
| 135 | + lower than the provided bound. Else, the result will be `0`; |
| 136 | + |
| 137 | +- **if_between(CUR1(amount1), CUR2(amount2))**: The value of the arithmetic expression will be |
| 138 | + returned only if it's strictly between the provided bounds. Else, it will be brought back to the |
| 139 | + closest bound. |
| 140 | + |
| 141 | +`CUR` is the currency code in capital letters, and `amount` is the amount of the bound expressed in |
| 142 | +that currency. |
| 143 | + |
| 144 | +You can also use the `cross_report` subformula to match, if your expression refers to an expression |
| 145 | +defined in another report. |
| 146 | + |
| 147 | +'Prefix of Account Codes' engine |
| 148 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 149 | + |
| 150 | +This engine is used to match amounts made on accounts using the prefixes of these accounts' codes as |
| 151 | +variables in an arithmetic expression. |
| 152 | + |
| 153 | +.. example:: |
| 154 | + **21 + 10 - 5** |
| 155 | + adds the balances of the move lines made on accounts whose codes start with `21` and `10`, and |
| 156 | + subtract the balance of the ones on the accounts with the prefix `5`. |
| 157 | + |
| 158 | +It is also possible to ignore a selection of sub-prefixes. |
| 159 | + |
| 160 | +.. example:: |
| 161 | + **21 + 10\\(101, 102) - 5\\(57)** |
| 162 | + does the same as the previous example, but ignoring the prefixes `101`, `102` and `57`. |
| 163 | + |
| 164 | +You can apply 'sub-filtering' on **credits and debits** using `C` and `D` suffixes. In this case, an |
| 165 | +account will only be considered if its prefix matches, *and* if the total balance of the move lines |
| 166 | +made on this account is **credit/debit**. |
| 167 | + |
| 168 | +.. example:: |
| 169 | + Account `210001` has a balance of -42 and account `210002` has a balance of 25. The formula |
| 170 | + **21D** only matches the account `210002`, and hence return 25. `210001` is not matched, as its |
| 171 | + balance is *credit*. |
| 172 | + |
| 173 | +Prefix exclusions can be mixed with `C` and `D` suffixes. |
| 174 | + |
| 175 | +.. example:: |
| 176 | + **21D + 10\\(101, 102)C - 5\\(57)** |
| 177 | + |
| 178 | +To match the letter `C` or `D` in a prefix and not use it as suffix, use an *empty* exclusion. |
| 179 | + |
| 180 | +.. example:: |
| 181 | + **21D\\()** |
| 182 | + matches accounts whose code starts with `21D`, regardless of their balance sign. |
| 183 | + |
| 184 | +'External Value' engine |
| 185 | +~~~~~~~~~~~~~~~~~~~~~~~ |
| 186 | + |
| 187 | +The 'external value' engine is used to refer to **manual** and **carryover values**. Those values |
| 188 | +are not stored using `account.move.line`, but with `account.report.external.value`. Each of these |
| 189 | +objects directly points to the expression it impacts, so very little needs to be done about their |
| 190 | +selection here. |
| 191 | + |
| 192 | +**Formulas** can be one of the following: |
| 193 | + |
| 194 | +- **sum** : If the result must be the sum of all the external values in the period; |
| 195 | + |
| 196 | +- **most_recent**: If the result must be the value of the latest external value in the period. |
| 197 | + |
| 198 | +In addition, **subformulas** can be used in two ways: |
| 199 | + |
| 200 | +- **rounding=X** : Replacing **'X'** by a number, instructs to round the amount to X decimals; |
| 201 | + |
| 202 | +- **editable** : indicates this expression can be edited manually, triggering the display of an icon |
| 203 | + in the report, allowing the user to perform this action. |
| 204 | + |
| 205 | +Both subformulas can be mixed, by separating them with a `;`. |
| 206 | + |
| 207 | +.. example:: |
| 208 | + **editable;rounding=2** |
| 209 | + is a correct subformula mixing both behaviors. |
| 210 | + |
| 211 | +'Custom Python Function' engine |
| 212 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 213 | + |
| 214 | +This engine is a means for developers to introduce custom computation of expressions on a |
| 215 | +case-by-case basis. The formula is the name of a **python function** to call, and the subformula is |
| 216 | +a **key** to fetch in the **dictionary** returned by this function. Use it only if you are making a |
| 217 | +custom module of your own. |
| 218 | + |
| 219 | +Columns |
| 220 | +------- |
| 221 | + |
| 222 | +Reports can have an **indefinite number** of columns to display. Each column gets its values from |
| 223 | +the **expressions** declared on the **lines**. The field :guilabel:`expression_label` of the column |
| 224 | +gives the label of the expressions whose value is displayed. If a line has no **expression** in that |
| 225 | +field, then nothing is displayed for it in this column. If multiple columns are required, you must |
| 226 | +use different **expression** labels. |
| 227 | + |
| 228 | +.. image:: customize/engine-columns.png |
| 229 | + :align: center |
| 230 | + :alt: Columns of report. |
| 231 | + |
| 232 | +When using the **period comparison** feature found under :menuselection:`Configuration --> |
| 233 | +Accounting Reports --> (Report you wish to use) --> Options`, all columns are repeated in and for |
| 234 | +each period. |
0 commit comments