[IMP] account, account_report, l10n_*: Introduce unified reporting engine

This commit adapts account's model to the new report engine introduced for v16, and updates the data files accordingly.

account.report model is now declared in community, together with the other models used by the reporting. This is done so that the tax tags can properly be created by the tax report and used on tax templates. All the actual computation logic stays in enterprise.

See enterprise commit for full details.

Task 2524389

closes odoo/documentation#2557

Related: odoo/odoo#94125
Related: odoo/enterprise#28648
Related: odoo/upgrade#3695
Signed-off-by: Julien Alardot (jual) <jual@odoo.com>
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
This commit is contained in:
Julien Alardot (jual) 2022-07-25 11:09:48 +00:00 committed by oco-odoo
parent 6ec20abc53
commit 642968bfd8
7 changed files with 83 additions and 53 deletions

View File

@ -248,7 +248,7 @@ Tax Report
The tax report is declared in the :guilabel:`Invoicing` (`account`) app, but the report is only accessible when :guilabel:`Accounting` (`account_accountant`) is installed.
.. seealso::
- :ref:`Tax Report Line References <reference/account_tax_report_line>`
- :doc:`/developer/reference/standard_modules/account/account_report_line`
- :doc:`/applications/finance/accounting/reporting/declarations/tax_returns`
In the previous section, you noticed the fields `invoice_repartition_line_ids` or `refund_repartition_line_ids` and probably understood nothing about them. Good news: you are not alone on this incomprehension. Bad news: you have to figure it out a bit. The topic is complicated. Indeed:
@ -258,27 +258,22 @@ In the previous section, you noticed the fields `invoice_repartition_line_ids` o
The simple version is that, in the tax template, you indicate in the invoice/refund repartition lines whether the base or a percentage of the tax needs to be reported in which report line (through the *minus/plus_report_line_ids* fields).
It becomes clear also when you check the tax configuration in the Odoo interface (or check the docs :ref:`Tax References <reference/account_tax>`, :ref:`Tax Repartition References <reference/account_tax_repartition>`).
And fortunately we have a presentation explaining the tax reports (as in version 13.0) in details:
.. youtube:: PuXE_NyFRTM
:align: right
:width: 700
:height: 394
So, once you have properly configured taxes, you just need to add the :file:`data/account_tax_report_data.xml` file with a record for your `account.tax.report` at the beginning:
So, once you have properly configured taxes, you just need to add the :file:`data/account_tax_report_data.xml` file with a record for your `account.report`. For it to be considered as a tax report, you need to provide it with the right `root_report_id`.
.. code-block:: xml
<odoo>
<record id="tax_report" model="account.tax.report">
<record id="tax_report" model="account.report">
<field name="name">Tax Report</field>
<field name="root_report_id" ref="account.generic_tax_report"/>
<field name="country_id" ref="base.XX"/>
</record>
...
</odoo>
... followed by the declaration of its lines, as `account.tax.report.line` records.
... followed by the declaration of its lines, as `account.report.line` records.
.. example::
`addons/l10n_au/data/account_tax_report_data.xml <{GITHUB_PATH}/addons/l10n_au/data/account_tax_report_data.xml>`_
@ -361,7 +356,8 @@ Basic :file:`__manifest__.py` file for such a module looks as following:
"l10n_XX", "account_reports"
],
"data": [
"data/account_financial_html_report_data.xml",
"data/balance_sheet.xml",
"data/profit_and_loss.xml",
],
"auto_install": True,
}
@ -374,13 +370,12 @@ Some good examples:
* `l10n_ch_reports/data/account_financial_html_report_data.xml <{GITHUB_ENT_PATH}/l10n_ch_reports/data/account_financial_html_report_data.xml>`_
* `l10n_be_reports/data/account_financial_html_report_data.xml <{GITHUB_ENT_PATH}/l10n_be_reports/data/account_financial_html_report_data.xml>`_
For the fields' meaning, dive directly to the source:
You can check the meaning of the fields here:
* `account.financial.html.report (v15) <https://github.com/odoo/enterprise/blob/d4eff9d39469cf3fe18589a1547cb0cdb93f4ae9/account_reports/models/account_financial_report.py#L59-L75>`_
* `account.financial.html.report.line (v15) <https://github.com/odoo/enterprise/blob/d4eff9d39469cf3fe18589a1547cb0cdb93f4ae9/account_reports/models/account_financial_report.py#L931-L964>`_
* :doc:`/developer/reference/standard_modules/account/account_report`
* :doc:`/developer/reference/standard_modules/account/account_report_line`
The menu for the new report is created automatically. By default, it is located under :menuselection:`Accounting -> Reporting`.
To create a dedicated section in the :guilabel:`Reporting` menu, you need to create a new `ir.ui.menu` record (usually in the main `l10n_XX` module) and set it as `parent_id` field in the `account.financial.html.report` model. Example for the Belgian localization:
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:
* `ir.ui.menu record in l10n_be <{GITHUB_PATH}/addons/l10n_be/data/menuitem_data.xml>`_
* `parent_id field in l10n_be_reports (v15) <https://github.com/odoo/enterprise/blob/d4eff9d39469cf3fe18589a1547cb0cdb93f4ae9/l10n_be_reports/data/account_financial_html_report_data.xml#L11>`_
* `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>`_

View File

@ -20,6 +20,7 @@ digraph foo {
label = "Invoices";
color = lightyellow;
node [style=filled, color=white];
edge [fontsize=8,];
account_move_line[label="account.move.line"]
account_tax[label="account.tax"]
account_tax_repartition_line[label="account.tax.repartition.line"];
@ -35,10 +36,10 @@ digraph foo {
label = "Reporting";
color = mistyrose;
node [style=filled, color=white];
account_tax_report_line[label="account.tax.report.line"];
account_generic_tax_report[label="account.generic.tax.report"];
account_tax_report[label="account.tax.report"];
account_tax_report -> account_generic_tax_report [label="Calls and displays", dir=back];
edge [fontsize=8,];
account_tax_report [label="account.report"];
account_tax_report_line [label="account.report.line"];
account_report_expression [label="account.report.expression"];
account_tax_report -> account_tax_report_line [label="0..*"]
}
subgraph cluster_templates {
@ -46,10 +47,16 @@ digraph foo {
label = "Templates";
color = lightblue;
node [style=filled, color=white];
edge [fontsize=8,];
account_tax_template[label="account.tax.template"];
account_tax_repartition_line_template[label="account.tax.repartition.line.template"];
account_tax_template -> account_tax_repartition_line_template [label="1 for base, 1..* for tax amount"];
}
{
rank=same;
account_move_line;
account_tax_report;
}
{
rank=same;
account_tax;
@ -59,15 +66,16 @@ digraph foo {
}
{
rank=same;
account_tax_report;
account_tax_report_line;
account_report_expression;
account_tax_template;
account_tax_repartition_line_template;
}
account_tax -> account_tax_template [label="Creates when installing CoA", dir=back];
account_tax_repartition_line -> account_tax_repartition_line_template [label="Creates when installing CoA", dir=back];
account_tax -> account_tax_template [label=" Creates when\n installing CoA", dir=back];
account_tax_repartition_line -> account_tax_repartition_line_template[label=" Creates when\n installing CoA", dir=back];
account_tax_repartition_line_template -> account_account_tag [label="tag_ids"];
account_tax_report_line -> account_account_tag [label="Creates (+ and -)"];
account_tax_report_line -> account_report_expression [label="0..*"];
account_tax_report_line -> account_tax_report_line [label="children_ids"];
account_report_expression -> account_account_tag [label="Engine tax_tags 1..*"];
account_tax_report -> res_country [label="0..1"];
account_account_tag -> res_country [label="0..1"];
}
}

View File

@ -12,6 +12,7 @@ Accounting
account/account_chart_template
account/account_fiscal_position
account/account_group
account/account_tax_report_line
account/account_report
account/account_report_line
account/account_tax
account/account_tax_repartition

View File

@ -11,6 +11,5 @@ Account Tag
.. autofield:: applicability
.. autofield:: color
.. autofield:: active
.. autofield:: tax_report_line_ids
.. autofield:: tax_negate
.. autofield:: country_id

View File

@ -0,0 +1,33 @@
===============
Report
===============
.. automodel:: odoo.addons.account.models.account_report.AccountReport
:main:
.. autofield:: name
.. autofield:: line_ids
.. autofield:: column_ids
.. autofield:: root_report_id
.. autofield:: chart_template_id
.. autofield:: country_id
.. autofield:: only_tax_exigible
.. autofield:: caret_options_initializer
.. autofield:: availability_condition
.. autofield:: load_more_limit
.. autofield:: search_bar
.. autofield:: default_opening_date_filter
.. autofield:: filter_multi_company
.. autofield:: filter_date_range
.. autofield:: filter_show_draft
.. autofield:: filter_unreconciled
.. autofield:: filter_unfold_all
.. autofield:: filter_period_comparison
.. autofield:: filter_growth_comparison
.. autofield:: filter_journals
.. autofield:: filter_analytic
.. autofield:: filter_hierarchy
.. autofield:: filter_account_type
.. autofield:: filter_partner
.. autofield:: filter_fiscal_position

View File

@ -0,0 +1,18 @@
===============
Report Line
===============
.. automodel:: odoo.addons.account.models.account_report.AccountReportLine
:main:
.. autofield:: name
.. autofield:: expression_ids
.. autofield:: report_id
.. autofield:: hierarchy_level
.. autofield:: parent_id
.. autofield:: children_ids
.. autofield:: foldable
.. autofield:: print_on_new_page
.. autofield:: action_id
.. autofield:: hide_if_zero

View File

@ -1,24 +0,0 @@
.. _reference/account_tax_report_line:
===============
Tax Report Line
===============
.. automodel:: odoo.addons.account.models.account_tax_report.AccountTaxReportLine
:main:
.. autofield:: name
.. autofield:: tag_ids
.. autofield:: report_action_id
.. autofield:: children_line_ids
.. autofield:: parent_id
.. autofield:: sequence
.. autofield:: report_id
.. autofield:: tag_name
.. autofield:: code
.. autofield:: formula
.. autofield:: carry_over_condition_method
.. autofield:: carry_over_destination_line_id
.. autofield:: carryover_line_ids
.. autofield:: is_carryover_persistent
.. autofield:: is_carryover_used_in_balance