Accounting localization

Warning

This tutorial requires knowledge about how to build a module in Flectra (see Getting started).

Installation procedure

On installing the account module, the localization module corresponding to the country code of the company is installed automatically. In case of no country code set or no localization module found, the l10n_generic_coa (US) localization module is installed by default. Check post init hook for details.

For example, l10n_ch will be installed if the company has Switzerland as country.

Building a localization module

The structure of a basic l10n_XX module may be described with the following __manifest__.py file:

{
    "name": "COUNTRY - Accounting",
    "version": "1.0.0",
    "category": "Accounting/Localizations/Account Charts",
    "license": "LGPL-3",
    "depends": [
        "account",
        # "l10n_multilang",
    ],
    "data": [
        # Chart of Accounts
        "data/account_chart_template_data.xml",
        "data/account_account_tag_data.xml",
        "data/account.account.template.csv",
        "data/account.group.template.csv",

        # Taxes
        "data/account_tax_group_data.xml",
        "data/account_tax_report_data.xml",
        "data/account_tax_template_data.xml",
        "data/account_fiscal_position_template_data.xml",
        "data/account_account_template_post_data.xml",

        "data/account_chart_post_data.xml",
        "data/account_chart_template_try_loading.xml",

        # Views and others
        "views/xxxmodel_views.xml"
    ],
    "demo": [
        "demo/demo_company.xml",
    ]
}

In the first file data/account_chart_template_data.xml, we set the name for the chart of accounts along with some basic fields.

Note

Recommended xmlid for the record is chart_template. If you need many chart of accounts, you can add some suffixes, i.e. chart_template_XXX.

Chart of Accounts

Account tags

Tags are a way to sort accounts. For example, imagine you want to create a financial report having multiple lines but you have no way to find a rule to dispatch the accounts according to their code. The solution is the usage of tags, one for each report line, to filter accounts like you want.

Put the tags in the data/account_account_tag_data.xml file.

Accounts

Obviously, Chart of Accounts cannot exist without Accounts. You need to specify them in data/account.account.template.csv.

CSV is prefered but you may use XML format instead.

Warning

  • Avoid the usage of liquidity account.account.type! Indeed, the bank & cash accounts are created directly at the installation of the localization module and then, are linked to an account.journal.

  • Only one account of type payable/receivable is enough for the generic case. We need to define a PoS receivable account as well however. (linked in the CoA)

  • Don’t create too many accounts: 200-300 is enough. But mostly, we try to find a good balance where the CoA needs minimal adapting for most companies afterwards.

Next settings for the chart of accounts are set in a separate file, because we need to provide a list of accounts first. In data/account_chart_post_data.xml, we set some default accounts:

Account groups

Account groups allow describing the hierarchical structure of the chart of accounts. The filter needs to be activated in the report and then when you decollapse into journal entries it will show the parents of the account.

It works with the prefix start/end, so every account where the code starts with something between start and end will have this account.group as the parent group. Furthermore, the account groups can have a parent account group as well to form the hierarchy.

Taxes

To add taxes you first need to specify tax groups. You normally need just one tax group for every tax rate, except for the 0% as you need to often distinguish between exempt, 0%, not subject, … taxes. This model only has two required fields: name and country. Create the file data/account_tax_group_data.xml and list the groups:

<flectra>
    <data noupdate="1">
        <record id="tax_group_tva_0" model="account.tax.group">
            <field name="name">TVA 0%</field>
            <field name="country_id" ref="base.ch"/>
        </record>

        ...
    </data>
</flectra>

Now you can add the taxes via data/account_tax_template_data.xml file. The first tax you define that is purchase/sale also becomes the default purchase/sale tax for your products.

If some accounts should use default taxes, you can set them up in data/account_account_template_post_data.xml

Tax Report

Professional feature

The tax report is declared in the Invoicing (account) app, but the report is only accessible when Accounting (account_accountant) is installed.

See also

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:

accounting_localization/tax_report.dot
> Graph not rendered because `dot` is not installed

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 Flectra interface (or check the docs Tax References, Tax Repartition References).

So, once you have properly configured taxes, you just need to add the 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.

<flectra>
    <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>

    ...
</flectra>

… followed by the declaration of its lines, as account.report.line records.

Example

addons/l10n_au/data/account_tax_report_data.xml

    <record id="tax_report" model="account.report">
        <field name="name">BAS Report</field>
        <field name="root_report_id" ref="account.generic_tax_report"/>
        <field name="country_id" ref="base.au"/>
        <field name="filter_fiscal_position" eval="True"/>
        <field name="availability_condition">country</field>
        <field name="column_ids">
            <record id="tax_report_balance" model="account.report.column">
                <field name="name">Balance</field>
                <field name="expression_label">balance</field>
            </record>
        </field>
        <field name="line_ids">
            <record id="account_tax_report_gstrpt_sale_total" model="account.report.line">
                <field name="name">GST amounts you owe the Tax Office from sales</field>
                <field name="hierarchy_level">0</field>
                <field name="children_ids">
                    <record id="account_tax_report_gstrpt_g1" model="account.report.line">
                        <field name="name">G1: Total Sales (including any GST)</field>
                        <field name="code">G1</field>
                        <field name="expression_ids">
                            <record id="account_tax_report_gstrpt_g1_tag" model="account.report.expression">
                                <field name="label">balance</field>
                                <field name="engine">tax_tags</field>
                                <field name="formula">G1</field>
                            </record>
                        </field>
                        <field name="children_ids">
                            <record id="account_tax_report_gstrpt_g2" model="account.report.line">
                                <field name="name">G2: Export sales</field>
                                <field name="code">G2</field>
                                <field name="expression_ids">
                                    <record id="account_tax_report_gstrpt_g2_tag" model="account.report.expression">
                                        <field name="label">balance</field>
                                        <field name="engine">tax_tags</field>
                                        <field name="formula">G2</field>
                                    </record>
                                </field>
                            </record>

Fiscal positions

Specify fiscal positions in the data/account_fiscal_position_template_data.xml file.

Final steps

The last step when installing a localization module is to try to apply its chart of accounts to the current company (if it does not already have one). The file data/account_chart_template_try_loading.xml is responsible for that.

Finally, you may add a demo company, so the localization can easily be tested in demo mode.

Example

addons/l10n_ch/demo/demo_company.xml

    <record id="partner_demo_company_ch" model="res.partner">
        <field name="name">CH Company</field>
        <field name="vat">CHE-530781296TVA</field>
        <field name="street">14 Meierskappelerstrasse</field>
        <field name="city">Risch-Rotkreuz</field>
        <field name="country_id" ref="base.ch"/>
        
        <field name="zip">6343</field>
        <field name="phone">+41 78 123 45 67</field>
        <field name="email">info@company.chexample.com</field>
        <field name="website">www.chexample.com</field>
    </record>

    <record id="partner_demo_company_bank_account" model="res.partner.bank">
        <field name="acc_type">iban</field>
        <field name="acc_number">CH4431999123000889012</field>
        <field name="bank_id" ref="base.bank_ing" />
        <field name="partner_id" ref="l10n_ch.partner_demo_company_ch"/>
    </record>

    <record id="demo_company_ch" model="res.company">
        <field name="name">CH Company</field>
        <field name="partner_id" ref="partner_demo_company_ch"/>
    </record>

    <function model="res.company" name="_onchange_country_id">
        <value eval="[ref('demo_company_ch')]"/>
    </function>

    <function model="res.users" name="write">
        <value eval="[ref('base.user_root'), ref('base.user_admin'), ref('base.user_demo')]"/>
        <value eval="{'company_ids': [(4, ref('l10n_ch.demo_company_ch'))]}"/>
    </function>

    <function model="account.chart.template" name="try_loading">
        <value eval="[]"/>
        <value>ch</value>
        <value model="res.company" eval="obj().env.ref('l10n_ch.demo_company_ch')"/>
    </function>

Accounting reports

Professional feature

See also

Overview

Basic __manifest__.py file for such a module looks as following:

{
    "name": "COUNTRY - Accounting Reports",
    "category": "Accounting/Localizations/Reporting",
    "version": "1.0.0",
    "license": "OEEL-1",
    "depends": [
        "l10n_XX", "account_reports"
    ],
    "data": [
        "data/balance_sheet.xml",
        "data/profit_and_loss.xml",
    ],
    "auto_install": True,
}

Functional overview of financial reports is here: Main reports available.

Some good examples:

You can check the meaning of the fields here:

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 ‣ Create Menu Item. You will then need to refresh the page to see it. Alternatively, to create a dedicated section for a totally new report in the 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.