|
1 | 1 | ================================================== |
2 | | -Create a customized reports with your own formulas |
| 2 | +Create a customized report with your own formulas |
3 | 3 | ================================================== |
4 | 4 |
|
5 | 5 | Overview |
6 | 6 | ======== |
7 | 7 |
|
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. |
9 | 9 | Creating new reports (such as a tax report or a balance sheet or |
10 | 10 | income statement with specific groupings and layout ) to suit your |
11 | 11 | needs is now easier than ever. |
12 | 12 |
|
13 | 13 | Activate the developer mode |
14 | 14 | =========================== |
15 | 15 |
|
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 |
17 | 17 | :ref:`developer mode <developer-mode>` needs to be activated. |
18 | 18 |
|
19 | | -Create your financial report |
| 19 | +Create your report |
20 | 20 | ============================ |
21 | 21 |
|
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` |
24 | 24 |
|
25 | 25 | .. image:: customize/customize02.png |
26 | 26 | :align: center |
27 | 27 |
|
28 | | -Once the name is entered, there are two other parameters that need to be |
29 | | -configured: |
| 28 | +Report Variants |
| 29 | +================ |
30 | 30 |
|
31 | | -- **Show Credit and Debit Columns** |
| 31 | +A report can either be a root report or a variant. |
32 | 32 |
|
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. |
34 | 36 |
|
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 |
38 | 39 |
|
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` |
41 | 46 |
|
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` |
44 | 50 |
|
45 | | -Add lines in your custom reports |
46 | | -================================= |
| 51 | +Lines |
| 52 | +====== |
47 | 53 |
|
48 | 54 | 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 |
51 | 60 |
|
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 |
53 | 68 | :align: center |
54 | 69 |
|
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**). |
58 | 73 |
|
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. |
60 | 76 |
|
61 | | -- ``Ndays`` : The number of days in the selected period (for reports with a |
62 | | - date range). |
| 77 | +'Odoo Domain' engine |
| 78 | +--------------------- |
63 | 79 |
|
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. |
67 | 81 |
|
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 |
74 | 84 |
|
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. |
76 | 86 |
|
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. |
78 | 88 |
|
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. |
81 | 91 |
|
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. |
84 | 93 |
|
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 | +------------------ |
88 | 96 |
|
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 |
0 commit comments