Informes personalizados¶
Odoo comes with a powerful and easy-to-use reporting framework. The engine allows you to create new reports, such as tax reports, or balance sheets and income statements with specific groupings and layouts.
Importante
Activate the developer mode to access the accounting report creation interface.
To create a new report, open the Accounting app and navigate to . From here, you can either create a root report or a variant.
Informe raíz¶
Los informes raíz se pueden considerar como informes contables generales; sirven como modelos sobre los que se construyen las versiones de contabilidad locales. Si se crea un informe y no se le asigna un informe raíz, se considera que dicho informe es un informe raíz.
Example
Un informe fiscal para Bélgica y Estados Unidos usará la misma versión general como base y se adaptará según sus normativas nacionales.
When creating a new root report, you need to create a menu item for it. To do so, open the report and, on that same report, click the (Actions) icon, then select Create Menu Item. Refresh the page; the report is now available under .
Nota
No es normal encontrarse casos que requieran crear un nuevo informe raíz, un ejemplo de casos que lo necesitan son los informes específicos que exigen algunas autoridades fiscales.
Variantes¶
Las variantes son versiones específicas de los informes raíz, por lo que siempre van a referirse a un informe raíz. Para crear una variante, selecciona un informe raíz general en informe raíz al crear un nuevo informe.
When a root report is opened from one of the accounting app’s main menus, all its variants are displayed in the variant selector in the top right corner of the view.
Example
In the following image, VAT Report (BE) is the variant of the root Generic Tax report.
Report lines¶
After having created a report (either root or variant), you need to fill it with report lines. You can either create a new one by clicking on Add a line, or modify an existing report line by clicking on it. All report lines require a Name, and can have an optional additional Code (of your choice) if you wish to use their value in formulas.
Expresiones¶
Each report line can contain one or multiple expressions. Expressions can be seen as sub-variables needed by a report line. To create an expression, click on Add a line within a report line.
When creating an expression, you must attribute a Label used to refer to that expression. Therefore, it has to be unique among the expressions of each line. Both a Computation Engine and a Formula must also be indicated. The engine defines how your formula(s) and subformula(s) are interpreted. It is possible to mix expressions using different computation engines under the same line if you need to.
Nota
En algunos casos también va a ser necesario definir subfórmulas.
“Odoo Domain” engine¶
With this engine, a formula is interpreted as an Odoo domain
targeting account.move.line objects.
La subformula le permite definir el uso de las líneas de movimiento que coinciden con el dominio para calcular el valor de la expresión:
sumEl resultado es la suma de todos los balances de las líneas de movimiento coincidentes.
sum_if_posEl resultado es la suma de todos los balances de las líneas de movimiento coincidentes si el importe es positivo; de lo contrario, es
0.sum_if_negEl resultado es la suma de todos los balances de las líneas de movimiento coincidentes si el importe es negativo; de lo contrario, es
0.count_rowsThe result is the number of sub-lines of this expression. If the report line has a group-by value, this will correspond to the number of distinct grouping keys in the matched move lines. Otherwise, it will be the number of matched move lines.
You can also put a - sign at the beginning of the subformula to reverse the sign of the
result.
“Aggregate Other Formulas” engine¶
Use this engine when you need to perform arithmetic operations on the amounts obtained for other
expressions. Formulas here are composed of references to expressions separated by one of the four
basic arithmetic operators (addition +, subtraction -, division /, and multiplication *). To
refer to an expression, type in its report line’s code followed by a period . and the
expression’s label (ex. code.label).
Las subfórmulas pueden ser las siguientes:
if_above(CUR(amount))Se devolverá el valor de la expresión aritmética solo si es mayor que el límite proporcionado. De lo contrario, el resultado será
0.if_below(CUR(amount))Se devolverá el valor de la expresión aritmética solo si es menor que el límite proporcionado. De lo contrario, el resultado será
0.if_between(CUR1(amount1), CUR2(amount2))Se devolverá el valor de la expresión aritmética solo si se encuentra entre los límites proporcionados. De lo contrario, se devolverá al límite más cercano.
if_other_expr_above(LINE_CODE.EXPRESSION_LABEL, CUR(amount))Se devolverá el valor de la expresión aritmética solo si el valor indicado por el código de línea y la etiqueta de expresión es mayor que el límite establecido. De lo contrario, el resultado será
0.if_other_expr_below(LINE_CODE.EXPRESSION_LABEL, CUR(amount))Se devolverá el valor de la expresión aritmética solo si el valor indicado por el código de línea y la etiqueta de expresión es inferior al límite establecido. De lo contrario, el resultado será
0.
CUR es el código de la divisa en mayúsculas, e importe es el importe del límite expresado en esa divisa.
También puede utilizar la subfórmula cross_report para que coincida con una expresión encontrada en otro informe.
“Prefix of Account Codes” engine¶
This engine is used to match amounts made on accounts using the prefixes of these accounts” codes as variables in an arithmetic expression.
Example
21Example
21 + 10 - 521 y 10, y resta el balance de las realizadas en cuentas con el prefijo 5.También es posible ignorar una selección de subprefijos.
Example
21 + 10\(101, 102) - 5\(57)101, 102 y 57.También puede aplicar un «subfiltrado» en los créditos y débitos utilizando los sufijos C y D. En este caso, solo se tendrá en cuenta una cuenta si su prefijo coincide, y si el balance total de las líneas de movimiento realizadas en esta cuenta es de crédito/débito.
Example
La cuenta 210001 tiene un balance de -42 y la cuenta 210002 tiene un balance de 25. La fórmula 21D solo coincide con la cuenta 210002, por lo que devuelve 25. La cuenta 210001 no coincide, ya que su saldo es de crédito.
Se pueden mezclar las exclusiones de los prefijos con los sufijos C y D.
Example
21D + 10\(101, 102)C - 5\(57)21 si es débito (D) y 10 si es crédito (C) pero ignora los prefijos 101 y 102, y resta el balance de las realizadas en cuentas con el prefijo 5, sin tomar en cuenta el prefijo 57.Si desea que la letra C o D coincida con un prefijo y no se utilice como sufijo, utilice una exclusión vacía ().
Example
21D\()21D, sin importar el signo de su balance.Además de utilizar prefijos de código para incluir cuentas, también puede hacer que coincidan con las etiquetas de cuentas. Esto es muy útil, por ejemplo, si su país no tiene un plan de cuentas estandarizado, donde es posible que se use el mismo prefijo para diferentes propósitos de una empresa a otra.
Example
etiqueta(25)If the tag you reference is defined in a data file, an xmlid can be used instead of the id.
Example
etiqueta(mi_módulo.mi_etiqueta)También puede usar expresiones aritméticas con etiquetas y tiene la posibilidad de combinarlas con selecciones de prefijo.
Example
etiqueta(mi_módulo.mi_etiqueta) + etiqueta(42) + 1010.Los sufijos C y D se pueden utilizar de la misma forma con las etiquetas.
Example
etiqueta(mi_módulo.mi_etiqueta)CLa exclusión de prefijos también funciona con las etiquetas.
Example
etiqueta(mi_módulo.mi_etiqueta)\(10)10.“External Value” engine¶
The “external value” engine is used to refer to manual and carryover values. Those values
are not stored using account.move.line, but with account.report.external.value. Each of these
objects directly points to the expression it impacts, so very little needs to be done about their
selection here.
Las fórmulas pueden ser las siguientes:
sumSi el resultado debe ser la suma de todos los valores externos del periodo.
most_recentSi el resultado debe ser el valor del último valor externo del periodo.
Además, puede usar las subfórmulas de dos formas:
rounding=XSe sustituye
Xpor un número para redondear la cantidad a X decimales.editableIndica que esta expresión se puede editar de forma manual, lo que provoca la aparición de un icono en el informe que permite que el usuario realice esta acción.
Nota
Los valores manuales se crean en la date_to seleccionada en el informe.
Ambas fórmulas se pueden usar al mismo tiempo, solo se deben separar por ;.
Example
editable;rounding=2“Custom Python Function” engine¶
This engine is a means for developers to introduce custom computation of expressions on a case-by-case basis. The formula is the name of a python function to call, and the subformula is a key to fetch in the dictionary returned by this function. Use it only if you are making a custom module of your own.
Columnas¶
Los informes pueden tener un número indefinido de columnas. Cada columna obtiene sus valores de las expresiones indicadas en las líneas. El campo expression_label de la columna proporciona la etiqueta de las expresiones cuyo valor se muestra. Si una línea no tiene ninguna expresión en ese campo, no se mostrará nada para ella en esta columna. Si se necesitan varias columnas, debe utilizar diferentes etiquetas de expresión
Si utiliza la función comparación de periodos en la pestaña Opciones de un informe contable, todas las columnas se repiten en y para cada periodo.
Line grouping¶
Non-standard grouping is possible by adding or using existing fields on the Journal Item model, provided that the fields are related and non-stored.
Nota
Grouping lines requires the report to have explicit report lines that can be edited. The deferred reports, for example, do not support grouping lines as they use dynamic lines that are generated.
Create a new field on journal item¶
To create a non-stored, related field in the Journal Item model, first go to , and click the (bug) icon, then click Fields. Click New to create a new field, and complete the following fields:
Field Name: a technical name for the field
Field Label: the label to be displayed for the field
Field Type: the type of field that this related field should point to
Stored: Leave this field unchecked as only non-stored fields can be used to group lines.
Related Model: If the field type is one2many, many2many, or many2one, select the model of the original field to group by.
Related Field Definition: the technical path to the field you want to group by
Example
To group by the sales team of the commercial partner, set the related field definition to
move_id.team_id.
Group lines¶
To group lines, go to the Lines tab of the desired report, click on the line you want to group, and edit the Group by field. Enter the technical name (Field Name) of the field to use as the grouping key.
Truco
To find a list of all the model’s fields and their technical names, go to , and click the (bug) icon, then click Fields. The technical name of each field is listed in the Field Name column.
Ver también
Custom tax report setup¶
Report configuration¶
Truco
All technical terms and functions of Odoo’s reports engine are explained in the previous sections of this page. We strongly recommend reading these sections before setting up a custom tax report.
To create a custom tax report, open the Accounting app, navigate to , then click New:
Enter a name for your report.
Select a Root Report.
Under the Availability field, select Country Matches, then select the Country matching your company.
Next, create a report line by clicking the Add a line. Once created, click that report line to configure it:
Click Add a line again to create an Expression and name it.
In the Definition tab, select a Computation Engine for that expression depending on the following scenarios:
In this scenario, your company uses tax grids:
Select Tax Tags as the computation engine. Odoo uses this field to link the report line to your taxes.
In the Formula field, type your short grid identifier (e.g.,
vat_sales_base). Odoo automatically generates the+and-variants of this tag for you to map inside .In the Subformula field, enter either
baseto report the untaxed amount, ortaxto report the actual tax amount collected/paid.
Repeat this process as necessary. Then, Save & Close.
Alternatively, you can:
Select Aggregate Other Formulas as the computation engine. Odoo uses this field to perform math on lines already present in the report rather than scanning raw transactions.
In the Formula field, use basic algebra referencing your line codes (e.g.,
LINE_10 - LINE_20).
Repeat this process as necessary. Then, Save & Close.
In this scenario, your company does not use tax grids. Instead, it tracks everything strictly via General Ledger accounts:
Select Prefix of Account Codes as the computation engine: Odoo uses this for lines that need to pull financial totals. Instead of looking for transaction tags, Odoo pulls live balances directly from your chart of accounts.
In the Formula field, type the starting digits of the accounts you want to track, (e.g.,
40will pull the combined total of all revenue accounts starting with400000,401000, etc.).
Repeat this process as necessary. Then, Save & Close.
Alternatively, you can:
Select Aggregate Other Formulas as the computation engine. Odoo uses this to calculate subtotals, net tax, or grand totals by adding or subtracting your other report lines.
In the Formula field, use basic algebra referencing your line codes (e.g.,
LINE_10 - LINE_20).
Repeat this process as necessary. Then, Save & Close.
In this scenario, your company requires advanced filtering, manual user overrides, or complex algorithmic logic that standard tags and account prefixes cannot handle:
Select Odoo Domain as the computation engine: Odoo uses this to bypass tax tags entirely and filter raw journal items (
account.move.line) using standard Odoo search syntax.In the Formula field, enter a valid domain starting with brackets to isolate tax-exempt transactions for specific partner categories.
Alternatively, you can:
Select External Value as the computation engine. Odoo uses this to log manual overrides or historical carryover values.
In the Formula field, type either
sum(to add all manual values together over multi-period reports) ormost_recent(to display only the latest value).In the Subformula field, type
editableto display an edit icon on the live report, allowing users to modify the value manually. Additionally, you can round numbers by typingrounding=x.
Alternatively, you can:
Select Custom Python Function as the computation engine. Odoo uses this as an execution engine to run specific calculations through backend coding when rules involve progressive brackets, loops, or multi-tier thresholds.
In the Formula field, enter the exact technical name of the Python method defined in your custom localization module.
Repeat this process as necessary. Then, Save & Close.
In the Options tab of an Expression, populate the Carry Over To field with a formula to always carry over balances or only carry them over when the amount is negative. Leave this field blank if you do not want to use this feature.
Example
if_below(EUR(0))Tax configuration¶
Next, go to and click New to create and configure new taxes for your custom tax report. Create your Sales and Purchases taxes, and populate the Tax Grids for all taxes using the matching tax grids you created earlier. Finally, make sure to specify both a tax payable and tax receivable account for each tax.
Example
Closing entry¶
To close taxes, a tax group must be specified on each tax used in your custom tax report. To do this, open the Accounting app, navigate to , open a tax that requires a tax group, click the Advanced Options tab, and select a group in the Tax Group field. Once assigned, click the (right arrow) icon and set both a Tax Payable Account and a Tax Receivable Account.
Truco
When everything has been set up, make sure to test your report by creating invoices, bills, and credit notes using the taxes specific to that report. Finally, test the closing entry itself.
If you want to hide a specific account from displaying in the tax closing entry, go to , select the tax, and click the (settings adjust) icon. From there, check the Tax Closing Entry box to adjust its visibility.
Ver también