From e5562a2418e2f7d538dd7b44e9da55f563692931 Mon Sep 17 00:00:00 2001 From: Mathis Jacoby Date: Fri, 12 May 2023 15:08:43 +0200 Subject: [PATCH] [ADD] l10n_be_annual_account_xbrl --- l10n_be_annual_account_xbrl/__init__.py | 1 + l10n_be_annual_account_xbrl/__manifest__.py | 28 + .../data/partner_id_numbers_data.xml | 13 + .../models/__init__.py | 4 + .../models/l10n_be_annual_account_xbrl.py | 1180 +++++++++++++++++ .../models/mis_report.py | 11 + .../models/res_company.py | 71 + .../models/res_partner.py | 190 +++ .../readme/CONFIGURE.rst | 9 + .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 10 + .../readme/INSTALL.rst | 8 + .../readme/ROADMAP.rst | 1 + l10n_be_annual_account_xbrl/readme/USAGE.rst | 29 + .../acl_l10n_be_annual_account_xbrl.xml | 23 + .../acl_rule_l10n_be_annual_account_xbrl.xml | 26 + .../static/description/icon.png | Bin 0 -> 9455 bytes .../views/l10n_be_annual_account_xbrl.xml | 229 ++++ .../views/mis_report.xml | 16 + .../views/res_partner.xml | 17 + l10n_be_mis_reports/__manifest__.py | 23 +- .../odoo/addons/l10n_be_annual_account_xbrl | 1 + setup/l10n_be_annual_account_xbrl/setup.py | 7 + 23 files changed, 1894 insertions(+), 4 deletions(-) create mode 100644 l10n_be_annual_account_xbrl/__init__.py create mode 100644 l10n_be_annual_account_xbrl/__manifest__.py create mode 100644 l10n_be_annual_account_xbrl/data/partner_id_numbers_data.xml create mode 100644 l10n_be_annual_account_xbrl/models/__init__.py create mode 100644 l10n_be_annual_account_xbrl/models/l10n_be_annual_account_xbrl.py create mode 100644 l10n_be_annual_account_xbrl/models/mis_report.py create mode 100644 l10n_be_annual_account_xbrl/models/res_company.py create mode 100644 l10n_be_annual_account_xbrl/models/res_partner.py create mode 100644 l10n_be_annual_account_xbrl/readme/CONFIGURE.rst create mode 100644 l10n_be_annual_account_xbrl/readme/CONTRIBUTORS.rst create mode 100644 l10n_be_annual_account_xbrl/readme/DESCRIPTION.rst create mode 100644 l10n_be_annual_account_xbrl/readme/INSTALL.rst create mode 100644 l10n_be_annual_account_xbrl/readme/ROADMAP.rst create mode 100644 l10n_be_annual_account_xbrl/readme/USAGE.rst create mode 100644 l10n_be_annual_account_xbrl/security/acl_l10n_be_annual_account_xbrl.xml create mode 100644 l10n_be_annual_account_xbrl/security/acl_rule_l10n_be_annual_account_xbrl.xml create mode 100644 l10n_be_annual_account_xbrl/static/description/icon.png create mode 100644 l10n_be_annual_account_xbrl/views/l10n_be_annual_account_xbrl.xml create mode 100644 l10n_be_annual_account_xbrl/views/mis_report.xml create mode 100644 l10n_be_annual_account_xbrl/views/res_partner.xml create mode 120000 setup/l10n_be_annual_account_xbrl/odoo/addons/l10n_be_annual_account_xbrl create mode 100644 setup/l10n_be_annual_account_xbrl/setup.py diff --git a/l10n_be_annual_account_xbrl/__init__.py b/l10n_be_annual_account_xbrl/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/l10n_be_annual_account_xbrl/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/l10n_be_annual_account_xbrl/__manifest__.py b/l10n_be_annual_account_xbrl/__manifest__.py new file mode 100644 index 000000000..e83d4535f --- /dev/null +++ b/l10n_be_annual_account_xbrl/__manifest__.py @@ -0,0 +1,28 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "L10n Be Annual Account Xbrl", + "summary": """ + generates the xbrl report of belgium annual account""", + "version": "14.0.1.0.0", + "development_status": "Alpha", + "license": "AGPL-3", + "author": "ACSONE SA/NV,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/l10n-belgium", + "depends": [ + "l10n_be_mis_reports", + "contacts", + "partner_firstname", + "partner_identification", + ], + "data": [ + "data/partner_id_numbers_data.xml", + "security/acl_l10n_be_annual_account_xbrl.xml", + "security/acl_rule_l10n_be_annual_account_xbrl.xml", + "views/l10n_be_annual_account_xbrl.xml", + "views/mis_report.xml", + "views/res_partner.xml", + ], + "demo": [], +} diff --git a/l10n_be_annual_account_xbrl/data/partner_id_numbers_data.xml b/l10n_be_annual_account_xbrl/data/partner_id_numbers_data.xml new file mode 100644 index 000000000..9e7cde300 --- /dev/null +++ b/l10n_be_annual_account_xbrl/data/partner_id_numbers_data.xml @@ -0,0 +1,13 @@ + + + + + nmt:m1 + Entity Number + + + member_number + Member Number + + + diff --git a/l10n_be_annual_account_xbrl/models/__init__.py b/l10n_be_annual_account_xbrl/models/__init__.py new file mode 100644 index 000000000..26648ee3a --- /dev/null +++ b/l10n_be_annual_account_xbrl/models/__init__.py @@ -0,0 +1,4 @@ +from . import l10n_be_annual_account_xbrl +from . import mis_report +from . import res_partner +from . import res_company diff --git a/l10n_be_annual_account_xbrl/models/l10n_be_annual_account_xbrl.py b/l10n_be_annual_account_xbrl/models/l10n_be_annual_account_xbrl.py new file mode 100644 index 000000000..d4103ac27 --- /dev/null +++ b/l10n_be_annual_account_xbrl/models/l10n_be_annual_account_xbrl.py @@ -0,0 +1,1180 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +import base64 +import json +import re +import tempfile +from datetime import datetime + +from lxml import etree + +from odoo import _, api, fields, models +from odoo.exceptions import UserError, ValidationError + + +class L10nBeAnnualAccountXbrl(models.Model): + _name = "l10n.be.annual.account.xbrl" + _inherit = ["mail.thread", "mail.activity.mixin"] + _description = "Belgium Annual Account" + _order = "date_from desc" + _rec_name = "report_name" + + @api.model + def _get_default_company_id(self): + return self.env.company + + report_name = fields.Char(string="Report Name", required=True) + bs_mis_report_template_id = fields.Many2one( + comodel_name="mis.report", + string="Balance Sheet", + domain=[("json_data_file", "!=", False), ("json_calc_file", "!=", False)], + ) + pl_mis_report_template_id = fields.Many2one( + comodel_name="mis.report", + string="Profit & Loss", + domain=[("json_data_file", "!=", False), ("json_calc_file", "!=", False)], + ) + company_id = fields.Many2one( + comodel_name="res.company", + string="Company", + required=True, + default=_get_default_company_id, + ) + company_category = fields.Selection( + string="Company Category", + selection=[ + ("m01-f", "companies with capital"), + ("m81-f", "companies without capital"), + ("m04-f", "Non-profit institution"), + ], + ) + company_registry = fields.Char( + string="Company Registry", + related="company_id.company_registry", + required=True, + ) + state = fields.Selection( + [ + ("draft", "Draft"), + ("confirmed", "Confirmed"), + ("published", "Published"), + ], + default="draft", + string="Status", + ) + date_range_id = fields.Many2one(comodel_name="date.range", string="Date Range") + date_from = fields.Date(string="From", required=True) + date_to = fields.Date(string="To", required=True) + administrator_ids = fields.Many2many( + comodel_name="res.partner", + relation="annual_account_xbrl_administrators", + string="Administrators", + ) + accountant_ids = fields.Many2many( + comodel_name="res.partner", + relation="annual_account_xbrl_accountants", + string="Accountants", + readonly=True, + states={"draft": [("readonly", False)]}, + ) + schema_ref = fields.Char(string="Schema") + legal_form = fields.Selection( + string="Legal Status", + selection=[ + ("lgf:m418", "Autonomous municipal company"), + ("lgf:m706", "Cooperative society"), + ("lgf:m716", "Cooperative society governed by public law"), + ( + "lgf:m265", + "Europ. Econ. assoc wo reg.seat but with est. unit in Belgium", + ), + ("lgf:m027", "European company (Societas Europaea)"), + ("lgf:m001", "European cooperative society"), + ("lgf:m065", "European economic assoc with registered seat in Belgium"), + ("lgf:m030", "Foreign company"), + ("lgf:m011", "General partnership"), + ("lgf:m125", "International non-profit organization"), + ("lgf:m612", "Limited partnership"), + ("lgf:m017", "Non-profit organization"), + ("lgf:m026", "Private foundation"), + ("lgf:m610", "Private limited company"), + ("lgf:m616", "Private limited company governed by public law"), + ("lgf:m021", "Private mutual insurance fund"), + ("lgf:m014", "Public limited company"), + ("lgf:m029", "Public utility foundation"), + ], + ) + active = fields.Boolean( + default=True, + ) + commercial_court = fields.Selection( + string="Commercial Court", + selection=[ + ("cct:m03", "Antwerp, division Antwerp"), + ("cct:m10", "Antwerp, division Hasselt"), + ("cct:m17", "Antwerp, division Mechelen"), + ("cct:m25", "Antwerp, division Tongeren"), + ("cct:m27", "Antwerp, division Turnhout"), + ("cct:m32", "Brussels, Dutch speaking"), + ("cct:m31", "Brussels, French speaking"), + ("cct:m30", "Eupen"), + ("cct:m05", "Ghent, division Bruges"), + ("cct:m07", "Ghent, division Dendermonde"), + ("cct:m09", "Ghent, division Ghent"), + ("cct:m12", "Ghent, division Ieper"), + ("cct:m13", "Ghent, division Kortrijk"), + ("cct:m22", "Ghent, division Ostend"), + ("cct:m23", "Ghent, division Oudenaarde"), + ("cct:m29", "Ghent, division Veurne"), + ("cct:m06", "Hainaut, division Charleroi"), + ("cct:m18", "Hainaut, division Mons"), + ("cct:m26", "Hainaut, division Tournai"), + ("cct:m14", "Leuven"), + ("cct:m04", "Liège, division Arlon"), + ("cct:m08", "Liège, division Dinant"), + ("cct:m11", "Liège, division Huy"), + ("cct:m16", "Liège, division Marche-en-Famenne"), + ("cct:m19", "Liège, division Namur"), + ("cct:m20", "Liège, division Neufchâteau"), + ("cct:m28", "Liège, division Verviers"), + ("cct:m21", "Walloon Brabant"), + ], + ) + date_recent_filing = fields.Date( + string="Last filing date", + help="Date of filing the most recent document mentioning the date of " + "publication of the deed of incorporation and of the deed of amendment " + "of the articles of association", + ) + date_general_assembly = fields.Date( + string="General Assembly", + help="Date of the general assembly where the accounts were approved", + ) + date_last_xbrl_generation = fields.Date( + string="Last XBRL Generation Date", tracking=True + ) + + # flake8: noqa: B950 + def get_mapping_dict(self): + """Returns a mapping dictionary where the key is the XBRL fact id + and the value is its corresponding field + """ + return { + "met:str2#dim:bas=bas:m26#dim:part=part:m2#dim:psn=psn:m1#dim:qlt=qlt:m1": "company_registry", + "met:dte1#dim:bas=bas:m27#dim:evt=evt:m1#dim:part=part:m2": "date_general_assembly", + "met:dte1#dim:bas=bas:m27#dim:mmt=mmt:m1#dim:part=part:m2#dim:prd=prd:m1": "date_from", + "met:dte1#dim:bas=bas:m27#dim:mmt=mmt:m2#dim:part=part:m2#dim:prd=prd:m1": "date_to", + "lgf-enum:list2#dim:bas=bas:m30#dim:part=part:m2#dim:psn=psn:m1": "legal_form", + "cct-enum:list1#dim:bas=bas:m32#dim:part=part:m2": "commercial_court", + "met:dte1#dim:bas=bas:m27#dim:evt=evt:m2#dim:part=part:m2": "date_recent_filing", + } + + def action_confirmed(self): + self.state = "confirmed" + + def action_draft(self): + self.state = "draft" + + def action_published(self): + self.state = "published" + self.active = False + + @api.constrains( + "state", + "company_category", + "schema_ref", + "commercial_court", + "date_recent_filing", + "legal_form", + "date_from", + "date_to", + ) + def _check_confirmed(self): + for record in self: + if record.state != "draft": + if not record.company_category: + raise ValidationError(_("Company Category cannot be empty")) + if not record.schema_ref: + raise ValidationError(_("Schema cannot be empty")) + if not record.commercial_court: + raise ValidationError(_("Commercial Court cannot be empty")) + if not record.date_recent_filing: + raise ValidationError(_("Last filing date cannot be empty")) + if not record.legal_form: + raise ValidationError(_("Legal Status cannot be empty")) + if not record.date_from: + raise ValidationError(_("Date From cannot be empty")) + if not record.date_to: + raise ValidationError(_("Date To cannot be empty")) + if not record.bs_mis_report_template_id: + raise ValidationError(_("Balance Sheet cannot be empty")) + if not record.pl_mis_report_template_id: + raise ValidationError(_("Profit & Loss cannot be empty")) + self._check_administrators() + if record.date_general_assembly < record.date_to: + raise UserError( + _( + "The closing date of the financial year must be earlier than" + " or equal to the date of approval by the general meeting" + ) + ) + + @api.constrains("state", "date_recent_filing") + def _check_date_recent_filing(self): + for record in self: + if record.state != "draft": + if record.date_recent_filing > fields.Date.today(): + raise ValidationError(_("Last filing date cannot be in the future")) + + @api.onchange("date_range_id") + def _onchange_date_range(self): + if self.date_range_id: + self.date_from = self.date_range_id.date_start + self.date_to = self.date_range_id.date_end + + @api.onchange("date_from", "date_to") + def _onchange_dates(self): + if self.date_range_id: + if ( + self.date_from != self.date_range_id.date_start + or self.date_to != self.date_range_id.date_end + ): + self.date_range_id = False + + @api.onchange("company_category") + def _onchange_schema(self): + if self.company_category == "m01-f": + self.schema_ref = "http://www.nbb.be/be/fr/cbso/fws/22.19/mod/m01/m01-f.xsd" + elif self.company_category == "m81-f": + self.schema_ref = "http://www.nbb.be/be/fr/cbso/fws/22.19/mod/m81/m81-f.xsd" + elif self.company_category == "m04-f": + self.schema_ref = "http://www.nbb.be/be/fr/cbso/fws/22.19/mod/m04/m04-f.xsd" + + @api.constrains("bs_mis_report_template_id") + def _check_balance_sheet(self): + if self.bs_mis_report_template_id: + if not self.bs_mis_report_template_id.json_data_file: + raise ValidationError( + _( + "JSON Data file cannot be empty, " + "edit the balance sheet to add one" + ) + ) + if not self.bs_mis_report_template_id.json_calc_file: + raise ValidationError( + _( + "JSON Calculation file cannot be empty, " + "edit the balance sheet to add one" + ) + ) + + @api.constrains("pl_mis_report_template_id") + def _check_profit_loss(self): + if self.pl_mis_report_template_id: + if not self.pl_mis_report_template_id.json_data_file: + raise ValidationError( + _( + "JSON Data file cannot be empty, " + "edit the profit & loss to add one" + ) + ) + if not self.pl_mis_report_template_id.json_calc_file: + raise ValidationError( + _( + "JSON Calculation file cannot be empty, " + "edit the profit & loss to add one" + ) + ) + + def _check_administrators(self): + for record in self: + for admin in record.administrator_ids: + self._check_admin_address(admin) + self._check_entity_number(admin) + for accountant in record.accountant_ids: + self._check_admin_address(accountant) + self._check_entity_number(accountant) + self._check_member_number(accountant) + + def _check_admin_address(self, admin): + if not admin.kind_of_address: + raise UserError( + _( + f"Kind of Address field for Administrator {admin.name} cannot be empty" + ) + ) + matched_street = re.match( + r"(?P\d+[a-zA-Z]*)\s*\/*\s*(?P\w*)\s*,\s*(?P.+)", + admin.street, + ) + if not matched_street: + raise UserError( + f"Address of {admin.name} should be like : " + f"STREET_NUMBER/STREET_BOX(optional), STREET_NAME." + " Example : 718A(/14), Pink Road" + ) + + def _check_entity_number(self, admin): + nb_entity_number = 0 + for id_number in admin.id_numbers: + if id_number.category_id.code == "nmt:m1": + nb_entity_number += 1 + if nb_entity_number != 1 and admin.company_type == "company": + raise UserError( + _( + f"Administrator {admin.name} must have " + f"only one Entity Number (in ID Numbers)" + ) + ) + + def _check_member_number(self, admin): + nb_member_number = 0 + for id_number in admin.id_numbers: + if id_number.category_id.code == "member_number": + nb_member_number += 1 + if nb_member_number != 1: + raise UserError( + _( + f"Accountant {admin.name} must have only one Member Number (in ID Numbers)" + ) + ) + + def action_download_xbrl(self): + """Downloads the xbrl balance sheet""" + tmp = tempfile.mkdtemp() + report_name = self.report_name.strip() + report_name = report_name.replace(" ", "_") + result_file_path = f"{tmp}/{report_name}.xbrl" + self._write_xbrl_report(result_file_path) + with open(result_file_path, "rb") as file: + attachment_model = self.env["ir.attachment"].sudo() + attachment = attachment_model.create( + { + "name": f"{report_name}.xbrl", + "datas": base64.b64encode(file.read()), + "type": "binary", + "mimetype": "application/xml", + } + ) + url = f"web/content/{attachment.id}?download=true" + self.date_last_xbrl_generation = datetime.today() + return { + "type": "ir.actions.act_url", + "url": url, + "target": "new", + } + + def _write_xbrl_report(self, result_file_path): + """Writes the information of the balance sheet for the selected + accounting period in the file result_file_path + :param result_file_path: the path of the xbrl file + """ + balance_sheet_kpis_dict = self._evaluate_kpis(self.bs_mis_report_template_id) + profit_loss_kpis_dict = self._evaluate_kpis(self.pl_mis_report_template_id) + json_file = base64.standard_b64decode( + self.bs_mis_report_template_id.json_data_file + ) + json_data_dict = json.loads(json_file) + fact_prototypes = json_data_dict["internalModels"][0]["factPrototypes"] + rubcode_list = self._get_rubcode_list(fact_prototypes) + rubcodes = [] + rubcodes = self._get_rubcodes(balance_sheet_kpis_dict, rubcodes) + rubcodes = self._get_rubcodes(profit_loss_kpis_dict, rubcodes) + ns_list = self._get_xbrl_namespaces(json_data_dict, rubcode_list, rubcodes) + namespaces_dict = json_data_dict["internalModels"][0]["namespacesByPrefix"] + NSMAP = self._set_nsmap(ns_list, namespaces_dict) + root = etree.Element("xbrl", nsmap=NSMAP) + link = etree.SubElement(root, "{http://www.xbrl.org/2003/linkbase}schemaRef") + link.set("{http://www.w3.org/1999/xlink}type", "simple") + link.set("{http://www.w3.org/1999/xlink}href", self.schema_ref) + root = self._write_identifying_data(root, json_data_dict) + administrators_list = json_data_dict["internalModels"][0]["editorModel"][ + "sectionsOrTables" + ][1]["section"]["sectionsOrTables"][0]["section"]["sectionsOrTables"][0][ + "section" + ][ + "sectionsOrTables" + ] + root = self._write_administrators( + root, + json_data_dict, + self.administrator_ids, + administrators_list, + "administrator", + ) + accountants_list = json_data_dict["internalModels"][0]["editorModel"][ + "sectionsOrTables" + ][1]["section"]["sectionsOrTables"][0]["section"]["sectionsOrTables"][1][ + "section" + ][ + "sectionsOrTables" + ] + root = self._write_administrators( + root, json_data_dict, self.accountant_ids, accountants_list, "accountant" + ) + root = self._write_kpis(root, rubcode_list, balance_sheet_kpis_dict) + root = self._write_kpis(root, rubcode_list, profit_loss_kpis_dict) + root = self._write_units(root) + prev_root_length = len(root) + id_data_dict = { + "l10n_be": self.get_mapping_dict(), + "company_id": self.company_id.get_mapping_dict(), + } + root = self._write_identifying_data_values( + root, id_data_dict, NSMAP, len(root) - prev_root_length + 1, json_data_dict + ) + index = len(root) - prev_root_length + 1 + root = self._write_admin_list_values(json_data_dict, root, index, NSMAP) + index = len(root) - prev_root_length + 1 + kpis_dict = dict(balance_sheet_kpis_dict, **profit_loss_kpis_dict) + root = self._write_rubric_values( + json_data_dict, kpis_dict, rubcodes, root, index + ) + self._write_report_in_file(result_file_path, root) + + def _write_units(self, root): + """Writes the needed units in the XBRL document""" + unit_eur = etree.SubElement(root, "unit", id="EUR") + measure_eur = etree.SubElement(unit_eur, "measure") + measure_eur.text = "iso4217:EUR" + unit_pure = etree.SubElement(root, "unit", id="pure") + measure_pure = etree.SubElement(unit_pure, "measure") + measure_pure.text = "pure" + return root + + def _write_rubric_values(self, json_data_dict, kpis_dict, rubcodes, root, index): + """Writes the values regarding the rubric codes in the XBRL document + :param json_data_dict: Data dictionary containing data from the NBB taxonomy + :param kpis_dict: Dictionary containing the evaluation of mis report + templates over a time period + :param rubcodes: The list of all the rubric codes present in the json data dictionary + :param root: Root tag of the XBRL document + :param index: The index of the XBRL context + """ + for rubcode_name, kpi_value in kpis_dict.items(): + split_rubcode = rubcode_name.split("_") + sanitized_rubcode = "" + if len(split_rubcode) == 2: + sanitized_rubcode = split_rubcode[-1] + elif len(split_rubcode) == 3: + sanitized_rubcode = f"{split_rubcode[-2]}/{split_rubcode[-1]}" + if sanitized_rubcode not in rubcodes or not kpi_value: + continue + rubcode_fact_prototype = self._get_rub_fact_prototype( + sanitized_rubcode, json_data_dict + ) + value = etree.SubElement( + root, + "{http://www.nbb.be/be/fr/cbso/dict/met}%s" + % rubcode_fact_prototype.get("qname").split(":")[1], + contextRef=f"c{index}", + decimals="INF", + unitRef="EUR", + ) + kpi_value = self.company_id.currency_id.round(kpi_value) + # In some cases currency_id.round returns more than two decimals + value.text = str(round(kpi_value, 2)) + index += 1 + return root + + def _get_rub_fact_prototype(self, rubcode_name, json_data_dict): + """Returns the fact prototype present in the json data dictionary + which correspond to the rubric code rubcode_name + :param rubcode_name: The rubric code + :param json_data_dict: Data dictionary containing data from the NBB taxonomy + """ + fact_prototypes = json_data_dict["internalModels"][0]["factPrototypes"] + for fact_prototype in fact_prototypes: + if fact_prototype.get("rubCode"): + if fact_prototype["rubCode"] == rubcode_name: + return fact_prototype + + def _write_report_in_file(self, file_path, root): + """Writes pretty printed root in the XBRL file""" + with open(file_path, "wb") as file: + file.write( + etree.tostring( + element_or_tree=root, + xml_declaration=True, + encoding="UTF-8", + pretty_print=True, + ) + ) + + def _get_rubcodes(self, mis_report_template_kpis, rubcodes_list): + """Returns the list of the rubric codes present in mis_report_template_kpis + :param mis_report_template_kpis: Dictionary containing the evaluation of the + mis report template over a time period + :param rubcodes_list: The list of all the rubric codes from the json data file + """ + for key in mis_report_template_kpis.keys(): + if key.startswith("rub"): + split_acc_name = key.split("_") + sanitized_acc_name = "" + if len(split_acc_name) == 2: + sanitized_acc_name = split_acc_name[-1] + elif len(split_acc_name) == 3: + sanitized_acc_name = f"{split_acc_name[-2]}/{split_acc_name[-1]}" + if sanitized_acc_name not in rubcodes_list: + rubcodes_list.append(sanitized_acc_name) + return rubcodes_list + + def _set_nsmap(self, ns_list, namespaces_dict): + """Set the namespaces mapping dictionary used in the XBRL file""" + etree.register_namespace("link", "http://www.xbrl.org/2003/linkbase") + etree.register_namespace("xlink", "http://www.w3.org/1999/xlink") + NSMAP = { + None: "http://www.xbrl.org/2003/instance", + "xbrldi": "http://xbrl.org/2006/xbrldi", + "link": "http://www.xbrl.org/2003/linkbase", + "xlink": "http://www.w3.org/1999/xlink", + "iso4217": "http://www.xbrl.org/2003/iso4217", + } + if self.accountant_ids or self.administrator_ids: + NSMAP["open"] = "http://www.nbb.be/be/fr/cbso/dict/dom/open" + for namespace in ns_list: + if namespace.startswith("dim:"): + namespace = namespace.split(":")[1] + if namespaces_dict.get(namespace): + etree.register_namespace(namespace, namespaces_dict.get(namespace)) + NSMAP[namespace] = namespaces_dict.get(namespace) + return NSMAP + + def _write_identifying_data(self, root, json_data_dict): + """Writes the identifying data contexts in the XBRL file""" + id_data_dict = { + "l10n_be": self.get_mapping_dict(), + "company_id": self.company_id.get_mapping_dict(), + } + added_fact_list = [] + for module_name, mapping_dict in id_data_dict.items(): + for fact_id, field_name in mapping_dict.items(): + matched_dims = re.match(r"[^#]+#(?P.+)", fact_id) + if matched_dims.group("dimensions") in added_fact_list: + continue + fact_prototypes = json_data_dict["internalModels"][0]["factPrototypes"] + for fact_prototype in fact_prototypes: + class_instance = ( + self if module_name == "l10n_be" else self.company_id + ) + if ( + fact_prototype.get("id") == fact_id + and class_instance[field_name] + ): + context = etree.Element("context", id=f"c{len(root)}") + entity = etree.Element("entity") + identifier = etree.Element( + "identifier", scheme="http://fgov.be" + ) + identifier.text = self.company_registry + entity.append(identifier) + context.append(entity) + period = etree.Element("period") + instant = etree.Element("instant") + instant.text = self.date_to.strftime(format="%Y-%m-%d") + period.append(instant) + context.append(period) + scenario = etree.Element("scenario") + for dimension in fact_prototype.get("dims"): + xbrldi = etree.SubElement( + scenario, + "{http://xbrl.org/2006/xbrldi}explicitMember", + dimension=dimension["dimQname"], + ) + xbrldi.text = dimension["memberQname"] + context.append(scenario) + root.append(context) + if matched_dims: + added_fact_list.append(matched_dims.group("dimensions")) + if field_name == "zip": + zip_code = ( + self._parse_zip( + class_instance[field_name], json_data_dict + ) + if field_name == "zip" + else None + ) + if zip_code: + added_fact_list.append( + "dim:bas=bas:m31#dim:ctc=ctc:m5#" + "dim:part=part:m2#dim:psn=psn:m1" + ) + return root + + def _write_identifying_data_values( + self, root, id_data_dict, ns_map, index, json_data_dict + ): + """Writes the identifying data value, for each context in the XBRL file + :param root: Root tag of the XBRL document + :param id_data_dict: A dictionary of dictionaries containing the name of the + field corresponding to an XBRL fact id, for + l10n_be_annual_account_xbrl and res_company models + :param ns_map: The namespaces mapping dictionary + :param index: The index of the XBRL context + :param json_data_dict: Data dictionary containing data from the NBB taxonomy + """ + values_list = [] + for module_name, mapping_dict in id_data_dict.items(): + for fact_id, field_name in mapping_dict.items(): + if field_name in values_list: + continue + class_instance = self if module_name == "l10n_be" else self.company_id + ns = fact_id.split("#")[0] + if field_name == "zip" or field_name == "city": + zip_code = ( + self._parse_zip(class_instance[field_name], json_data_dict) + if field_name == "zip" + else None + ) + if zip_code: + if "pcd-enum:list1" in fact_id: + root = self._write_fact_value( + root, + ns_map[ns.split(":")[0]], + ns.split(":")[1], + index, + zip_code, + ) + values_list.append(field_name) + values_list.append("city") + index += 1 + else: + if "pcd-enum:list1" not in fact_id: + root = self._write_fact_value( + root, + ns_map[ns.split(":")[0]], + ns.split(":")[1], + index, + class_instance[field_name], + ) + values_list.append(field_name) + index += 1 + else: + if class_instance[field_name]: + root = self._write_fact_value( + root, + ns_map[ns.split(":")[0]], + ns.split(":")[1], + index, + class_instance[field_name], + ) + values_list.append(field_name) + index += 1 + return root + + def _write_kpis(self, root, rubcode_list, mis_report_template_kpis): + """Writes the contexts for each rubric code of a mis report template + in the XBRL file + :param root: Root tag of the XBRL document + :param rubcode_list: The list of all the rubric codes from the json data dictionary + :param mis_report_template_kpis: A dictionary containing the evaluation of the + mis report template over a time period + """ + if mis_report_template_kpis: + for rubric, value in mis_report_template_kpis.items(): + # Check if it is an account + if rubric.startswith("rub"): + if value: + context = etree.Element("context", id=f"c{len(root)}") + entity = etree.Element("entity") + identifier = etree.Element( + "identifier", scheme="http://fgov.be" + ) + identifier.text = self.company_registry + entity.append(identifier) + context.append(entity) + period = etree.Element("period") + instant = etree.Element("instant") + instant.text = self.date_to.strftime(format="%Y-%m-%d") + period.append(instant) + context.append(period) + scenario = etree.Element("scenario") + scenario = self._write_rubric_dimensions( + scenario, rubric, rubcode_list + ) + context.append(scenario) + root.append(context) + return root + + def _write_rubric_dimensions(self, scenario, account_name, rubcode_list): + """Writes the dimensions of a rubric in the XBRL file + :param scenario: The scenario tag of a context + :param account_name: The name of the rubric + :param rubcode_list: The list of all the rubric codes from the json data dictionary + :return: + """ + split_acc_name = account_name.split("_") + sanitized_acc_name = "" + if len(split_acc_name) == 2: + sanitized_acc_name = split_acc_name[-1] + elif len(split_acc_name) == 3: + sanitized_acc_name = f"{split_acc_name[-2]}/{split_acc_name[-1]}" + for fact_prototype in rubcode_list: + if fact_prototype.get("rubCode") and fact_prototype.get("period") == "N": + if ( + "rubCode" in fact_prototype + and fact_prototype["rubCode"] == sanitized_acc_name + ): + for dim in fact_prototype["dims"]: + xbrldi = etree.Element( + "{http://xbrl.org/2006/xbrldi}explicitMember", + dimension=dim.get("dimQname"), + ) + xbrldi.text = dim.get("memberQname") + scenario.append(xbrldi) + break + return scenario + + def _get_rubcode_list(self, fact_prototypes): + """Get the list of all the rubric codes of the json data file""" + rubcode_list = [] + rubcodes = [] + for fact_prototype in fact_prototypes: + if fact_prototype.get("rubCode") and fact_prototype.get("period") == "N": + if fact_prototype.get("rubCode") not in rubcodes: + rubcodes.append(fact_prototype.get("rubCode")) + rubcode_list.append(fact_prototype) + return rubcode_list + + def _get_xbrl_namespaces(self, json_data_dict, rubcode_list, rubcodes): + """Returns the list of the namespaces needed for the XBRL facts that + will be written in the XBRL report + """ + fact_ids_list = self._get_fact_ids(json_data_dict, rubcode_list, rubcodes) + ns_list = [] + fact_prototypes = json_data_dict["internalModels"][0]["factPrototypes"] + for fact_id in fact_ids_list: + for fact_prototype in fact_prototypes: + if fact_prototype.get("id") != fact_id: + continue + for dimension in fact_prototype.get("dims"): + dimension_names = dimension.get("dimQname").split(":") + for dimension_name in dimension_names: + if dimension_name not in ns_list: + ns_list.append(dimension_name) + if fact_prototype.get("qname"): + if "-" in fact_prototype["qname"]: + dimension_name = ( + fact_prototype["qname"].split(":")[0].split("-")[0] + ) + if dimension_name not in ns_list: + ns_list.append(dimension_name) + dimension_name = fact_prototype["qname"].split(":")[0] + if dimension_name not in ns_list: + ns_list.append(dimension_name) + break + return ns_list + + def _get_fact_ids(self, json_data_dict, rubcode_list, rubcodes): + """Returns the list of all the ids of the XBRL facts that will be + written in the XBRL report + :param json_data_dict: Data dictionary containing data from the NBB taxonomy + :param rubcode_list: The list of all the rubric codes from the json data dictionary + :param rubcodes: The list of the rubcodes present in the balance sheet and + the profit & loss + """ + + # l10n_be_annual_account_xbrl fact ids + fact_ids_list = [ + fact_id + for fact_id in self.get_mapping_dict().keys() + if self._fact_has_value( + fact_id, self, self.get_mapping_dict(), json_data_dict + ) + ] + # Company fact ids + fact_ids_list += [ + fact_id + for fact_id in self.company_id.get_mapping_dict().keys() + if self._fact_has_value( + fact_id, + self.company_id, + self.company_id.get_mapping_dict(), + json_data_dict, + ) + and fact_id not in fact_ids_list + ] + # Administrators fact ids + for admin in self.administrator_ids: + fact_ids_list += [ + fact_id + for fact_id in admin._get_admin_id_mapping()[admin.company_type].keys() + if self._fact_has_value( + fact_id, + admin, + admin._get_admin_id_mapping()[admin.company_type], + json_data_dict, + ) + and fact_id not in fact_ids_list + ] + # Accountants fact ids + for accountant in self.accountant_ids: + fact_ids_list += [ + fact_id + for fact_id in accountant._get_accountant_id_mapping()[ + accountant.company_type + ].keys() + if self._fact_has_value( + fact_id, + accountant, + accountant._get_accountant_id_mapping()[accountant.company_type], + json_data_dict, + ) + and fact_id not in fact_ids_list + ] + # Rubcodes fact ids + kpi_dict = dict( + self._evaluate_kpis(self.bs_mis_report_template_id), + **self._evaluate_kpis(self.pl_mis_report_template_id), + ) + for fact_prototype in rubcode_list: + rubcode = fact_prototype.get("rubCode") + acc_name = "" + if rubcode in rubcodes: + if "/" in rubcode: + acc_name = rubcode.split("/") + acc_name = f"rub_{acc_name[0]}_{acc_name[1]}" + else: + acc_name = f"rub_{rubcode}" + if kpi_dict.get(acc_name): + fact_ids_list.append(fact_prototype.get("id")) + return fact_ids_list + + def _evaluate_kpis(self, mis_report_template): + """evaluate the mis report template over a time period, + from date_from to date_to + """ + aep = mis_report_template._prepare_aep(companies=self.company_id) + return mis_report_template.evaluate( + aep=aep, + date_from=self.date_from, + date_to=self.date_to, + ) + + def _write_administrators( + self, root, json_data_dict, admin_list, admin_data_list, admin_type + ): + """Writes the information regarding the administrators or the + accountants in the XBRL file + :param root: Root tag of the XBRL document + :param json_data_dict: Data dictionary containing data from the NBB taxonomy + :param admin_list: The list of the administrators or the accountants of the company + :param admin_data_list: A list of res_partner who are the administrators or + the accountants of a company + :param admin_type: The function of the res_partner , administrator or accountant + """ + for admin in admin_list: + facts_list = [] + if admin.company_type == "person": + admin_rows = ( + admin_data_list[1]["section"]["sectionsOrTables"][0] + .get("table") + .get("rows") + ) + else: + admin_rows = ( + admin_data_list[0]["section"]["sectionsOrTables"][0] + .get("table") + .get("rows") + ) + open_dim_q_names = self._find_open_dim_q_names(admin_rows) + for row in admin_rows: + for col in row.get("cols"): + if col.get("fp"): + dimensions = self._find_xbrl_fact_by_id( + json_data_dict["internalModels"][0]["factPrototypes"], + col["fp"].get("id"), + ).get("dims") + if not self._is_fact_written(dimensions, facts_list): + if admin_type == "administrator": + id_mapping_list = admin._get_admin_id_mapping()[ + admin.company_type + ] + else: + id_mapping_list = admin._get_accountant_id_mapping()[ + admin.company_type + ] + if self._fact_has_value( + col["fp"].get("id"), + admin, + id_mapping_list, + json_data_dict, + ): + context = etree.Element("context", id=f"c{len(root)}") + entity = etree.Element("entity") + identifier = etree.Element( + "identifier", scheme="http://fgov.be" + ) + identifier.text = self.company_registry + entity.append(identifier) + context.append(entity) + period = etree.Element("period") + instant = etree.Element("instant") + instant.text = self.date_to.strftime(format="%Y-%m-%d") + period.append(instant) + context.append(period) + scenario = etree.Element("scenario") + open_dim_q_names_dict = dict() + if len(open_dim_q_names) == 1: + open_dim_q_names_dict = { + open_dim_q_names[0]: admin.name + } + elif len(open_dim_q_names) == 2: + open_dim_q_names_dict = { + open_dim_q_names[0]: admin.firstname, + open_dim_q_names[1]: admin.lastname, + } + scenario = self._write_admin_dimensions( + scenario, + col["fp"].get("id"), + open_dim_q_names_dict, + json_data_dict, + ) + context.append(scenario) + root.append(context) + facts_list.append(self._concat_dims(dimensions)) + return root + + def _fact_has_value(self, fact_id, class_instance, id_mapping_list, json_data_dict): + """Returns true if the XBRL fact has a value + :param fact_id: The id of the XBRL fact + :param class_instance: an instance of res_partner (administrator or accountant) + :param id_mapping_list: A dictionary of mapping dictionaries where the key is + the XBRL fact id and the value is its corresponding field, + for each type of administrator (legal and natural person) + :param json_data_dict: Data dictionary containing data from the NBB taxonomy + """ + fact_value = None + if fact_id in id_mapping_list: + field_name = id_mapping_list.get(fact_id) + if "id_numbers" in field_name: + for id_number in class_instance.id_numbers: + if field_name == "id_numbers.category_id": + if id_number.category_id.code == "nmt:m1": + fact_value = id_number.category_id.code + elif field_name == "id_numbers.member_number": + fact_value = class_instance.get_member_number() + else: + fact_value = id_number.name + elif "street" in field_name: + street_dict = self._parse_street(class_instance.street) + fact_value = street_dict[field_name] + if len(fact_value) == 0: + fact_value = None + elif "zip" in field_name or "city" in field_name: + zip_value = self._parse_zip(class_instance["zip"], json_data_dict) + if zip_value: + if "pcd-enum" in fact_id: + fact_value = zip_value + else: + fact_value = class_instance[field_name] + else: + fact_value = class_instance[field_name] + return fact_value is not None and fact_value is not False + + def _find_open_dim_q_names(self, admin_rows): + """Returns a list of the open dimensions of an administrator""" + open_dim_q_names = [] + for row in admin_rows: + if len(open_dim_q_names) <= 0: + for col in row.get("cols"): + if col.get("fp"): + if col["fp"].get("openDimQNames"): + for open_dim_q_name in col["fp"]["openDimQNames"]: + open_dim_q_names.append(open_dim_q_name) + return open_dim_q_names + + def _is_fact_written(self, dimensions, facts_list): + return self._concat_dims(dimensions) in facts_list + + def _concat_dims(self, dimensions): + concat_dim = "" + for dim in dimensions: + if dim.get("memberQname"): + concat_dim += f"{dim.get('dimQname')}={dim.get('memberQname')}#" + return concat_dim + + def _write_admin_dimensions( + self, scenario, xbrl_fact_id, open_dim_q_names_dict, json_data_dict + ): + """Add the dimension to the scenario tag for the administrators + or the accountants in the XBRL file + :param scenario: The scenario tag of a context + :param xbrl_fact_id: The id of the XBRL fact + :param open_dim_q_names_dict: A dictionary containing the open dimensions + :param json_data_dict: Data dictionary containing data from the NBB taxonomy + """ + dimensions = self._find_xbrl_fact_by_id( + json_data_dict["internalModels"][0]["factPrototypes"], xbrl_fact_id + ).get("dims") + for key, value in open_dim_q_names_dict.items(): + xbrldi = etree.SubElement( + scenario, + "{http://xbrl.org/2006/xbrldi}typedMember", + dimension=key, + ) + openstr = etree.SubElement( + xbrldi, "{http://www.nbb.be/be/fr/cbso/dict/dom/open}str" + ) + openstr.text = value + for dim in dimensions: + if dim.get("memberQname"): + xbrldi = etree.SubElement( + scenario, + "{http://xbrl.org/2006/xbrldi}explicitMember", + dimension=dim.get("dimQname"), + ) + xbrldi.text = dim.get("memberQname") + return scenario + + def _find_xbrl_fact_by_id(self, fact_prototypes, xbrl_fact_id): + for fact_prototype in fact_prototypes: + if fact_prototype.get("id") == xbrl_fact_id: + return fact_prototype + return None + + def _write_admin_list_values(self, json_data_dict, root, index, ns_map): + """Write the values of the XBRL facts regarding the administrators + and the accountants + :param json_data_dict: Data dictionary containing data from the NBB taxonomy + :param root: Root tag of the XBRL document + :param index: The index of the XBRL context + :param ns_map: The namespaces mapping dictionary + """ + prev_root_length = len(root) + for administrator_id in self.administrator_ids: + admin_mapping_dict = administrator_id._get_admin_id_mapping()[ + administrator_id.company_type + ] + root = self._write_admin_and_accounting_values( + json_data_dict, + root, + index, + ns_map, + admin_mapping_dict, + administrator_id, + ) + index += len(root) - prev_root_length + prev_root_length = len(root) + for accountant_id in self.accountant_ids: + acc_mapping_dict = accountant_id._get_accountant_id_mapping()[ + accountant_id.company_type + ] + root = self._write_admin_and_accounting_values( + json_data_dict, root, index, ns_map, acc_mapping_dict, accountant_id + ) + index += len(root) - prev_root_length + prev_root_length = len(root) + return root + + def _write_admin_and_accounting_values( + self, json_data_dict, root, index, ns_map, mapping_dict, admin + ): + """Writes the values of the XBRL facts regarding an administrator or an accountant + :param json_data_dict: Data dictionary containing data from the NBB taxonomy + :param root: Root tag of the XBRL document + :param index: The index of the XBRL context + :param ns_map: The namespaces mapping dictionary + :param mapping_dict: A dictionary of mapping dictionaries where the key is the + XBRL fact id and the value is its corresponding field, + for each type of administrator (legal and natural person) + :param admin: A res_partner instance (administrator or accountant) + """ + values_list = [] + + for key, value in mapping_dict.items(): + if value in values_list: + continue + if not self._fact_has_value(key, admin, mapping_dict, json_data_dict): + continue + ns = key.split("#")[0] + if value == "zip" or value == "city": + zip_code = ( + self._parse_zip(admin.mapped(value)[0], json_data_dict) + if value == "zip" + else None + ) + if zip_code: + if "pcd-enum:list1" in key: + root = self._write_fact_value( + root, + ns_map[ns.split(":")[0]], + ns.split(":")[1], + index, + zip_code, + ) + values_list.append(value) + index += 1 + else: + if "pcd-enum:list1" not in key: + root = self._write_fact_value( + root, + ns_map[ns.split(":")[0]], + ns.split(":")[1], + index, + admin.mapped(value)[0], + ) + values_list.append(value) + index += 1 + else: + if admin[value]: + root = self._write_fact_value( + root, + ns_map[ns.split(":")[0]], + ns.split(":")[1], + index, + admin[value], + ) + values_list.append(value) + index += 1 + return root + + def _parse_street(self, street): + """Returns a dictionary containing the street name, the street + number and the street box, if street follows the correct format""" + matched_street = re.match( + r"(?P\d+[a-zA-Z]*)\s*\/*\s*(?P\w*)\s*,\s*(?P.+)", + street, + ) + if not matched_street: + raise UserError( + _( + "Contact address should be like : " + "STREET_NUMBER/STREET_BOX(optional), STREET_NAME. " + "Example : 718A(/14), Pink Road" + ) + ) + else: + return { + "street_name": matched_street.group("street"), + "street_number": matched_street.group("number"), + "street_box": matched_street.group("box"), + } + + def _parse_zip(self, zip_value, json_data_dict): + """Checks if the zip code is in zip code list of the json dictionary + :param zip_value: The zip code + :param json_data_dict: Data dictionary containing data from the NBB taxonomy + """ + for pcd_enum in json_data_dict["internalModels"][0]["editorModel"][ + "codeListsMap" + ]["pcd-enum:list1"]: + code = pcd_enum.get("code") + if not pcd_enum: + continue + if code == f"pcd:m{zip_value}": + return code if len(code) > 0 else None + + def _write_fact_value(self, root, ns_map, ns, index, value): + """Add the value of an XBRL fact as a child of root + :param root: The root tag of the XBRL document + :param ns_map: The namespaces mapping dictionary + :param ns: The namespace + :param index: The index of the XBRL context to reference + :param value: The value of the XBRL fact + """ + fact_value = etree.SubElement( + root, "{" + ns_map + "}" + ns, contextRef=f"c{index}" + ) + fact_value.text = str(value) + return root diff --git a/l10n_be_annual_account_xbrl/models/mis_report.py b/l10n_be_annual_account_xbrl/models/mis_report.py new file mode 100644 index 000000000..bb9a8090d --- /dev/null +++ b/l10n_be_annual_account_xbrl/models/mis_report.py @@ -0,0 +1,11 @@ +from odoo import fields, models + + +class MisReport(models.Model): + + _inherit = "mis.report" + + json_data_file = fields.Binary(string="JSON Data File") + json_data_filename = fields.Char(string="JSON Data Filename") + json_calc_file = fields.Binary(string="JSON Calculation File") + json_calc_filename = fields.Char(string="JSON Calculation Filename") diff --git a/l10n_be_annual_account_xbrl/models/res_company.py b/l10n_be_annual_account_xbrl/models/res_company.py new file mode 100644 index 000000000..ac9e56000 --- /dev/null +++ b/l10n_be_annual_account_xbrl/models/res_company.py @@ -0,0 +1,71 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +import re + +from odoo import api, fields, models + + +class ResCompany(models.Model): + _name = "res.company" + _inherit = "res.company" + + street_name = fields.Char(compute="_compute_street_name") + street_number = fields.Char(compute="_compute_street_number") + street_box = fields.Char(compute="_compute_street_box") + country_list = fields.Char(compute="_compute_country") + + @api.depends("street") + def _compute_street_name(self): + for rec in self: + rec.street_name = False + matched_street = self._get_matched_street(rec.street) + if matched_street: + rec.street_name = matched_street.group("street") + + @api.depends("street") + def _compute_street_number(self): + for rec in self: + rec.street_number = False + matched_street = self._get_matched_street(rec.street) + if matched_street: + rec.street_number = matched_street.group("number") + + @api.depends("street") + def _compute_street_box(self): + for rec in self: + rec.street_box = False + matched_street = self._get_matched_street(rec.street) + if matched_street: + rec.street_box = matched_street.group("box") + + @api.depends("country_id") + def _compute_country(self): + for rec in self: + rec.country_list = f"cty:m{rec.country_id.code}" + + # flake8: noqa: B950 + def get_mapping_dict(self): + """Returns a mapping dictionary where the key is the XBRL fact id + and the value is its corresponding field + """ + return { + "met:str2#dim:bas=bas:m29#dim:part=part:m2#dim:psn=psn:m1": "name", + "met:str2#dim:bas=bas:m31#dim:ctc=ctc:m1#dim:part=part:m2#dim:psn=psn:m1": "street_name", + "met:str2#dim:bas=bas:m31#dim:ctc=ctc:m2#dim:part=part:m2#dim:psn=psn:m1": "street_number", + "met:str2#dim:bas=bas:m31#dim:ctc=ctc:m3#dim:part=part:m2#dim:psn=psn:m1": "street_box", + "pcd-enum:list1#dim:bas=bas:m31#dim:ctc=ctc:m4#dim:part=part:m2#dim:psn=psn:m1": "zip", + "met:str2#dim:bas=bas:m31#dim:ctc=ctc:m4#dim:part=part:m2#dim:psn=psn:m1": "zip", + "met:str2#dim:bas=bas:m31#dim:ctc=ctc:m5#dim:part=part:m2#dim:psn=psn:m1": "city", + "cty-enum:list1#dim:bas=bas:m31#dim:ctc=ctc:m6#dim:part=part:m2#dim:psn=psn:m1": "country_list", + "met:str2#dim:bas=bas:m31#dim:ctc=ctc:m7#dim:part=part:m2#dim:psn=psn:m1": "email", + "met:str2#dim:bas=bas:m31#dim:ctc=ctc:m8#dim:part=part:m2#dim:psn=psn:m21": "website", + } + + def _get_matched_street(self, street): + """Returns a match object containing 3 subgroups (street number, street box + and street name), if street matches the regular expression + """ + return re.match( + r"(?P\d+[a-zA-Z]*)\s*\/*\s*(?P\w*)\s*,\s*(?P.+)", + street, + ) diff --git a/l10n_be_annual_account_xbrl/models/res_partner.py b/l10n_be_annual_account_xbrl/models/res_partner.py new file mode 100644 index 000000000..b33cb9bbf --- /dev/null +++ b/l10n_be_annual_account_xbrl/models/res_partner.py @@ -0,0 +1,190 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +import re + +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError + + +class Partner(models.Model): + _name = "res.partner" + _inherit = "res.partner" + + kind_of_address = fields.Selection( + selection=[ + ("atc:m002", "Address of the business unit"), + ("atc:m001", "Address of the head office"), + ("atc:m003", "Branch of a foreign company"), + ("other", "Other"), + ], + string="Kind of Address", + ) + other_kind_of_address = fields.Char(string="Other Kind Of Address") + kind_of_entity_number_list = fields.Char( + compute="_compute_kind_of_entity_number_list" + ) + entity_number = fields.Char(compute="_compute_entity_number") + member_number = fields.Char(compute="_compute_member_number") + street_name = fields.Char(compute="_compute_street_name") + street_number = fields.Char(compute="_compute_street_number") + street_box = fields.Char(compute="_compute_street_box") + country_list = fields.Char(compute="_compute_country") + + @api.onchange("kind_of_address") + def _onchange_kind_of_address(self): + self.other_kind_of_address = False + + @api.constrains("kind_of_address", "other_kind_of_address") + def _check_other_kind_of_address(self): + if any( + rec.kind_of_address == "other" and not rec.other_kind_of_address + for rec in self + ): + raise ValidationError(_("Other Kind Of Address cannot be empty")) + + @api.depends("id_numbers") + def _compute_kind_of_entity_number_list(self): + for rec in self: + rec.kind_of_entity_number_list = False + for id_number in rec.id_numbers: + if id_number.category_id.code == "nmt:m1": + rec.kind_of_entity_number_list = id_number.category_id.code + + @api.depends("id_numbers") + def _compute_entity_number(self): + for rec in self: + rec.entity_number = False + for id_number in rec.id_numbers: + if id_number.category_id.code == "nmt:m1": + rec.entity_number = id_number.name + + @api.depends("id_numbers") + def _compute_member_number(self): + for rec in self: + rec.member_number = False + for id_number in rec.id_numbers: + if id_number.category_id.code == "member_number": + rec.member_number = id_number.name + + def _get_matched_street(self, street): + """Returns a match object containing 3 subgroups (street number, street box + and street name), if street matches the regular expression + """ + return re.match( + r"(?P\d+[a-zA-Z]*)\s*\/*\s*(?P\w*)\s*,\s*(?P.+)", + street, + ) + + @api.depends("street") + def _compute_street_name(self): + for rec in self: + rec.street_name = False + matched_street = self._get_matched_street(rec.street) + if matched_street: + rec.street_name = matched_street.group("street") + + @api.depends("street") + def _compute_street_number(self): + for rec in self: + rec.street_number = False + matched_street = self._get_matched_street(rec.street) + if matched_street: + rec.street_number = matched_street.group("number") + + @api.depends("street") + def _compute_street_box(self): + for rec in self: + rec.street_box = False + matched_street = self._get_matched_street(rec.street) + if matched_street: + rec.street_box = matched_street.group("box") + + @api.depends("country_id") + def _compute_country(self): + for rec in self: + rec.country_list = f"cty:m{rec.country_id.code}" + + def get_kind_of_number(self): + return { + "nmt:m1": "entity_number", + "other_id_number": "Other Identification Number", + } + + def get_member_number(self): + self.ensure_one() + for id_number in self.id_numbers: + if id_number.category_id.code == "member_number": + return id_number.name + return None + + # flake8: noqa: B950 + def _get_admin_id_mapping(self): + """Returns a dictionary of mapping dictionaries where the key is the XBRL fact id and the + value is its corresponding field, for each type of administrator (legal and natural person) + """ + return { + # Administratror : legal person + "company": { + "nmt-enum:list1#dim:anlp=#dim:bas=bas:m26#dim:dcl=dcl:m7#dim:part=part:m2#dim:psn=psn:m10": "kind_of_entity_number_list", # Kind of entity number (list) id_numbers.category_id.code" + "met:str2#dim:anlp=#dim:bas=bas:m26#dim:part=part:m2#dim:psn=psn:m10#dim:qlt=qlt:m1": "entity_number", # Kind of entity number (value) ????? id_numbers.name + "atc-enum:list1#dim:anlp=#dim:bas=bas:m31#dim:dcl=dcl:m7#dim:part=part:m2#dim:psn=psn:m10": "kind_of_address", # Kind of address (list) + "met:str2#dim:anlp=#dim:bas=bas:m31#dim:dcl=dcl:m7#dim:part=part:m2#dim:psn=psn:m10": "kind_of_address", # Kind of address (other) + "met:str2#dim:anlp=#dim:bas=bas:m31#dim:ctc=ctc:m1#dim:part=part:m2#dim:psn=psn:m10": "street_name", # Street name but same field + "met:str2#dim:anlp=#dim:bas=bas:m31#dim:ctc=ctc:m2#dim:part=part:m2#dim:psn=psn:m10": "street_number", # Street number but same field + "met:str2#dim:anlp=#dim:bas=bas:m31#dim:ctc=ctc:m3#dim:part=part:m2#dim:psn=psn:m10": "street_box", # Street box + "pcd-enum:list1#dim:anlp=#dim:bas=bas:m31#dim:ctc=ctc:m4#dim:part=part:m2#dim:psn=psn:m10": "zip", # Postal code and city (list) + "met:str2#dim:anlp=#dim:bas=bas:m31#dim:ctc=ctc:m4#dim:part=part:m2#dim:psn=psn:m10": "zip", # Postal code (other) + "met:str2#dim:anlp=#dim:bas=bas:m31#dim:ctc=ctc:m5#dim:part=part:m2#dim:psn=psn:m10": "city", # City (other) + "cty-enum:list1#dim:anlp=#dim:bas=bas:m31#dim:ctc=ctc:m6#dim:part=part:m2#dim:psn=psn:m10": "country_list", # Country name (list) + }, + # Administrator : natural person + "person": { + "met:str2#dim:afnp=#dim:annp=#dim:bas=bas:m28#dim:dcl=dcl:m27#dim:part=part:m2#dim:psn=psn:m12": "function", # Profession + "atc-enum:list1#dim:afnp=#dim:annp=#dim:bas=bas:m31#dim:dcl=dcl:m7#dim:part=part:m2#dim:psn=psn:m12": "kind_of_address", # Kind of address (list) + "met:str2#dim:afnp=#dim:annp=#dim:bas=bas:m31#dim:dcl=dcl:m7#dim:part=part:m2#dim:psn=psn:m12": "other_kind_of_address", # Kind of address (other) + "met:str2#dim:afnp=#dim:annp=#dim:bas=bas:m31#dim:ctc=ctc:m1#dim:part=part:m2#dim:psn=psn:m12": "street_name", # Street name + "met:str2#dim:afnp=#dim:annp=#dim:bas=bas:m31#dim:ctc=ctc:m2#dim:part=part:m2#dim:psn=psn:m12": "street_number", # Street number + "met:str2#dim:afnp=#dim:annp=#dim:bas=bas:m31#dim:ctc=ctc:m3#dim:part=part:m2#dim:psn=psn:m12": "street_box", # Street box + "pcd-enum:list1#dim:afnp=#dim:annp=#dim:bas=bas:m31#dim:ctc=ctc:m4#dim:part=part:m2#dim:psn=psn:m12": "zip", # Postal code and city (list) + "met:str2#dim:afnp=#dim:annp=#dim:bas=bas:m31#dim:ctc=ctc:m4#dim:part=part:m2#dim:psn=psn:m12": "zip", # Postal code (other) + "met:str2#dim:afnp=#dim:annp=#dim:bas=bas:m31#dim:ctc=ctc:m5#dim:part=part:m2#dim:psn=psn:m12": "city", # City (other) + "cty-enum:list1#dim:afnp=#dim:annp=#dim:bas=bas:m31#dim:ctc=ctc:m6#dim:part=part:m2#dim:psn=psn:m12": "country_list", # Country name (list) + }, + } + + # flake8: noqa: B950 + def _get_accountant_id_mapping(self): + return { + """Returns a dictionary of mapping dictionaries where the key is the XBRL fact id and the + value is its corresponding field, for each type of administrator (legal and natural person) + """ + # Accountant : legal person + "company": { + "nmt-enum:list1#dim:aclp=#dim:bas=bas:m26#dim:dcl=dcl:m7#dim:part=part:m2#dim:psn=psn:m13": "kind_of_entity_number_list", # Kind of entity number (list) + "met:str2#dim:aclp=#dim:bas=bas:m26#dim:part=part:m2#dim:psn=psn:m13#dim:qlt=qlt:m1": "entity_number", # Kind of entity number (value) + "met:str2#dim:aclp=#dim:bas=bas:m34#dim:part=part:m2#dim:psn=psn:m13#dim:qlt=qlt:m5": "member_number", # Member number + "atc-enum:list1#dim:aclp=#dim:bas=bas:m31#dim:dcl=dcl:m7#dim:part=part:m2#dim:psn=psn:m13": "kind_of_address", # Kind of address (list) + "met:str2#dim:aclp=#dim:bas=bas:m31#dim:dcl=dcl:m7#dim:part=part:m2#dim:psn=psn:m13": "kind_of_address", # Kind of address (other) + "met:str2#dim:aclp=#dim:bas=bas:m31#dim:ctc=ctc:m1#dim:part=part:m2#dim:psn=psn:m13": "street_name", # Street name + "met:str2#dim:aclp=#dim:bas=bas:m31#dim:ctc=ctc:m2#dim:part=part:m2#dim:psn=psn:m13": "street_number", # Street number + "met:str2#dim:aclp=#dim:bas=bas:m31#dim:ctc=ctc:m3#dim:part=part:m2#dim:psn=psn:m13": "street_box", # Street box + "pcd-enum:list1#dim:aclp=#dim:bas=bas:m31#dim:ctc=ctc:m4#dim:part=part:m2#dim:psn=psn:m13": "zip", # Postal code and city (list) + "met:str2#dim:aclp=#dim:bas=bas:m31#dim:ctc=ctc:m4#dim:part=part:m2#dim:psn=psn:m13": "zip", # Postal code (other) + "met:str2#dim:aclp=#dim:bas=bas:m31#dim:ctc=ctc:m5#dim:part=part:m2#dim:psn=psn:m13": "city", # City (other) + "cty-enum:list1#dim:aclp=#dim:bas=bas:m31#dim:ctc=ctc:m6#dim:part=part:m2#dim:psn=psn:m13": "country_list", # Country name (list) + }, + # Accountant : natural person + "person": { + "met:str2#dim:acfn=#dim:acnp=#dim:bas=bas:m28#dim:dcl=dcl:m27#dim:part=part:m2#dim:psn=psn:m15": "function", # Profession + "met:str2#dim:acfn=#dim:acnp=#dim:bas=bas:m34#dim:part=part:m2#dim:psn=psn:m15#dim:qlt=qlt:m5": "member_number", # Member number + "atc-enum:list1#dim:acfn=#dim:acnp=#dim:bas=bas:m31#dim:dcl=dcl:m7#dim:part=part:m2#dim:psn=psn:m15": "kind_of_address", # Kind of address (list) + "met:str2#dim:acfn=#dim:acnp=#dim:bas=bas:m31#dim:dcl=dcl:m7#dim:part=part:m2#dim:psn=psn:m15": "other_kind_of_address", # Kind of address (other) + "met:str2#dim:acfn=#dim:acnp=#dim:bas=bas:m31#dim:ctc=ctc:m1#dim:part=part:m2#dim:psn=psn:m15": "street_name", # Street name + "met:str2#dim:acfn=#dim:acnp=#dim:bas=bas:m31#dim:ctc=ctc:m2#dim:part=part:m2#dim:psn=psn:m15": "street_number", # Street number + "met:str2#dim:acfn=#dim:acnp=#dim:bas=bas:m31#dim:ctc=ctc:m3#dim:part=part:m2#dim:psn=psn:m15": "street_box", # Street box + "pcd-enum:list1#dim:acfn=#dim:acnp=#dim:bas=bas:m31#dim:ctc=ctc:m4#dim:part=part:m2#dim:psn=psn:m15": "zip", # Postal code and city (list) + "met:str2#dim:acfn=#dim:acnp=#dim:bas=bas:m31#dim:ctc=ctc:m4#dim:part=part:m2#dim:psn=psn:m15": "zip", # Postal code (other) + "met:str2#dim:acfn=#dim:acnp=#dim:bas=bas:m31#dim:ctc=ctc:m5#dim:part=part:m2#dim:psn=psn:m15": "city", # City (other) + "cty-enum:list1#dim:acfn=#dim:acnp=#dim:bas=bas:m31#dim:ctc=ctc:m6#dim:part=part:m2#dim:psn=psn:m15": "country_list", # Country name (list) + }, + } diff --git a/l10n_be_annual_account_xbrl/readme/CONFIGURE.rst b/l10n_be_annual_account_xbrl/readme/CONFIGURE.rst new file mode 100644 index 000000000..6d11d53ee --- /dev/null +++ b/l10n_be_annual_account_xbrl/readme/CONFIGURE.rst @@ -0,0 +1,9 @@ +To use this module, you need to go to Invoicing > Configuration > MIS Report Template +and add the JSON Data File and the JSON Calculation File, for each template you +want to use. You can find those JSON files at l10n_be_mis_reports/script + +You also need to add the company registry on the company that you want to generate the +annual report. + +To generate the Balance Sheet and Profit & Loss templates, use the script located at +l10n_be_mis_reports/script, generate_xml.py diff --git a/l10n_be_annual_account_xbrl/readme/CONTRIBUTORS.rst b/l10n_be_annual_account_xbrl/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..69418e188 --- /dev/null +++ b/l10n_be_annual_account_xbrl/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +Mathis Jacoby diff --git a/l10n_be_annual_account_xbrl/readme/DESCRIPTION.rst b/l10n_be_annual_account_xbrl/readme/DESCRIPTION.rst new file mode 100644 index 000000000..bb1aa883a --- /dev/null +++ b/l10n_be_annual_account_xbrl/readme/DESCRIPTION.rst @@ -0,0 +1,10 @@ +This module provides the micro, abbreviated and full model templates for the +Balance Sheet and the Profit & Loss for : + +- Companies with capital +- Companies without capital +- Non-profit institution + +It also provides the possibility to generate and download an XBRL file containing +the information of a company or an Non-profit Organization for an accounting period. +The XBRL file is ready to be submitted to the National Bank of Belgium. diff --git a/l10n_be_annual_account_xbrl/readme/INSTALL.rst b/l10n_be_annual_account_xbrl/readme/INSTALL.rst new file mode 100644 index 000000000..116b93da5 --- /dev/null +++ b/l10n_be_annual_account_xbrl/readme/INSTALL.rst @@ -0,0 +1,8 @@ +The normal Odoo module installation procedure applies. + +This module depends on the mis_builder module which can +be found on apps.odoo.com or the OCA/mis-builder +github repository. + +It also depends on the partner_firstname and partner_identification +modules (OCA/partner-contact github repository) diff --git a/l10n_be_annual_account_xbrl/readme/ROADMAP.rst b/l10n_be_annual_account_xbrl/readme/ROADMAP.rst new file mode 100644 index 000000000..b707b9e51 --- /dev/null +++ b/l10n_be_annual_account_xbrl/readme/ROADMAP.rst @@ -0,0 +1 @@ +- Add a post hook to link MIS Builder templates with the corresponding JSON files. diff --git a/l10n_be_annual_account_xbrl/readme/USAGE.rst b/l10n_be_annual_account_xbrl/readme/USAGE.rst new file mode 100644 index 000000000..6ecb9558d --- /dev/null +++ b/l10n_be_annual_account_xbrl/readme/USAGE.rst @@ -0,0 +1,29 @@ +To configure this module, you neet to go to Invoicing > Reporting > Belgium Annual Account +and create a report instance according to the desired accounting time period. + +You need to specify two MIS Builder templates, the first one for the Balance Sheet +and the second one for the Profit & Loss, provided by this module : + +- Micro model company with capital [m07-f] +- Abbreviated model company with capital [m01-f] +- Full model company with capital [m02-f] +- Micro model company without capital [m87-f] +- Abbreviated model company without capital [m81-f] +- Full model company without capital [m82-f] +- Micro schema non-profit institution [m08-f] +- Abbreviated schema non-profit institution [m04-f] +- Full schema non-profit institution [m05-f] + +The prefixes in square brackets are the prefixes given by the National Bank of Belgium. + +You will need to edit those templates to add the json data file and the json calculation file. +Those files are located in l10n_be_mis_report/script/calc and l10n_be_mis_report/script/data. + +Pay attention to add the json files with the same prefix present in the template name. + +After completing the report, you can confirm it. Some verifications will be made and exceptions +will be thrown if information is missing or if it does not correspond to the expected format. + +When the report is confirmed, you are able to download the XBRL file containing the data of the report. + +If you need to make some modifications, the report must be in state draft. diff --git a/l10n_be_annual_account_xbrl/security/acl_l10n_be_annual_account_xbrl.xml b/l10n_be_annual_account_xbrl/security/acl_l10n_be_annual_account_xbrl.xml new file mode 100644 index 000000000..dcb8da2db --- /dev/null +++ b/l10n_be_annual_account_xbrl/security/acl_l10n_be_annual_account_xbrl.xml @@ -0,0 +1,23 @@ + + + + + l10n.be.annual.account.xbrl access base user + + + + + + + + + l10n.be.annual.account.xbrl access adviser + + + + + + + + diff --git a/l10n_be_annual_account_xbrl/security/acl_rule_l10n_be_annual_account_xbrl.xml b/l10n_be_annual_account_xbrl/security/acl_rule_l10n_be_annual_account_xbrl.xml new file mode 100644 index 000000000..6186b9165 --- /dev/null +++ b/l10n_be_annual_account_xbrl/security/acl_rule_l10n_be_annual_account_xbrl.xml @@ -0,0 +1,26 @@ + + + + + l10n.be.annual.account.xbrl multi company + + + + + + + ['|',('company_id','=',False),('company_id', 'in', company_ids)] + + + + diff --git a/l10n_be_annual_account_xbrl/static/description/icon.png b/l10n_be_annual_account_xbrl/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d GIT binary patch literal 9455 zcmW++2RxMjAAjx~&dlBk9S+%}OXg)AGE&Cb*&}d0jUxM@u(PQx^-s)697TX`ehR4?GS^qbkof1cslKgkU)h65qZ9Oc=ml_0temigYLJfnz{IDzUf>bGs4N!v3=Z3jMq&A#7%rM5eQ#dc?k~! zVpnB`o+K7|Al`Q_U;eD$B zfJtP*jH`siUq~{KE)`jP2|#TUEFGRryE2`i0**z#*^6~AI|YzIWy$Cu#CSLW3q=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&!?O+%Rv;b?B??gSzdp?6Uug9{ zd@V08Z$BdI?fpoCS$)t4mg4rT8Q_I}h`0d-vYZ^|dOB*Q^S|xqTV*vIg?@fVFSmMpaw0qtTRbx} z({Pg?#{2`sc9)M5N$*N|4;^t$+QP?#mov zGVC@I*lBVrOU-%2y!7%)fAKjpEFsgQc4{amtiHb95KQEwvf<(3T<9-Zm$xIew#P22 zc2Ix|App^>v6(3L_MCU0d3W##AB0M~3D00EWoKZqsJYT(#@w$Y_H7G22M~ApVFTRHMI_3be)Lkn#0F*V8Pq zc}`Cjy$bE;FJ6H7p=0y#R>`}-m4(0F>%@P|?7fx{=R^uFdISRnZ2W_xQhD{YuR3t< z{6yxu=4~JkeA;|(J6_nv#>Nvs&FuLA&PW^he@t(UwFFE8)|a!R{`E`K`i^ZnyE4$k z;(749Ix|oi$c3QbEJ3b~D_kQsPz~fIUKym($a_7dJ?o+40*OLl^{=&oq$<#Q(yyrp z{J-FAniyAw9tPbe&IhQ|a`DqFTVQGQ&Gq3!C2==4x{6EJwiPZ8zub-iXoUtkJiG{} zPaR&}_fn8_z~(=;5lD-aPWD3z8PZS@AaUiomF!G8I}Mf>e~0g#BelA-5#`cj;O5>N Xviia!U7SGha1wx#SCgwmn*{w2TRX*I literal 0 HcmV?d00001 diff --git a/l10n_be_annual_account_xbrl/views/l10n_be_annual_account_xbrl.xml b/l10n_be_annual_account_xbrl/views/l10n_be_annual_account_xbrl.xml new file mode 100644 index 000000000..5da1aa2d7 --- /dev/null +++ b/l10n_be_annual_account_xbrl/views/l10n_be_annual_account_xbrl.xml @@ -0,0 +1,229 @@ + + + + + l10n.be.annual.account.xbrl.form (in l10n_be_annual_account_xbrl) + l10n.be.annual.account.xbrl + +
+
+
+ + + +
+

+ Report name : + +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + l10n.be.annual.account.xbrl.tree (in l10n_be_annual_account_xbrl) + l10n.be.annual.account.xbrl + + + + + + + + + + + + + + + l10n.be.annual.account.xbrl.search + l10n.be.annual.account.xbrl + + + + + + + + + + + + Annual Accounts + ir.actions.act_window + l10n.be.annual.account.xbrl + tree,form + {} + +

+ create an annual account ! +

+
+
+ + + + diff --git a/l10n_be_annual_account_xbrl/views/mis_report.xml b/l10n_be_annual_account_xbrl/views/mis_report.xml new file mode 100644 index 000000000..ad938ac4c --- /dev/null +++ b/l10n_be_annual_account_xbrl/views/mis_report.xml @@ -0,0 +1,16 @@ + + + + mis.report.view.form (in mis_builder) + mis.report + + + + + + + + + + + diff --git a/l10n_be_annual_account_xbrl/views/res_partner.xml b/l10n_be_annual_account_xbrl/views/res_partner.xml new file mode 100644 index 000000000..857b77c77 --- /dev/null +++ b/l10n_be_annual_account_xbrl/views/res_partner.xml @@ -0,0 +1,17 @@ + + + + res.partner.form + res.partner + + + + + + + + + diff --git a/l10n_be_mis_reports/__manifest__.py b/l10n_be_mis_reports/__manifest__.py index cf41ff6dc..1d1563c3e 100644 --- a/l10n_be_mis_reports/__manifest__.py +++ b/l10n_be_mis_reports/__manifest__.py @@ -13,11 +13,26 @@ "depends": ["mis_builder", "l10n_be"], # OCA/account-financial-reporting "data": [ "data/mis_report_styles.xml", - "data/mis_report_pl.xml", + "data/mis_report_bs_m01-f.xml", + "data/mis_report_pl_m01-f.xml", + "data/mis_report_bs_m02-f.xml", + "data/mis_report_pl_m02-f.xml", + "data/mis_report_bs_m04-f.xml", + "data/mis_report_pl_m04-f.xml", + "data/mis_report_bs_m05-f.xml", + "data/mis_report_pl_m05-f.xml", + "data/mis_report_bs_m07-f.xml", + "data/mis_report_pl_m07-f.xml", + "data/mis_report_bs_m08-f.xml", + "data/mis_report_pl_m08-f.xml", + "data/mis_report_bs_m81-f.xml", + "data/mis_report_pl_m81-f.xml", + "data/mis_report_bs_m82-f.xml", + "data/mis_report_pl_m82-f.xml", + "data/mis_report_bs_m87-f.xml", + "data/mis_report_pl_m87-f.xml", "data/mis_report_bs.xml", - "data/new_mis_report_pl.xml", - "data/new_mis_report_bs.xml", - "data/mis_report_pl_no_share_corporation_short.xml", + "data/mis_report_pl.xml", "data/mis_report_vat.xml", ], "installable": True, diff --git a/setup/l10n_be_annual_account_xbrl/odoo/addons/l10n_be_annual_account_xbrl b/setup/l10n_be_annual_account_xbrl/odoo/addons/l10n_be_annual_account_xbrl new file mode 120000 index 000000000..2d5398049 --- /dev/null +++ b/setup/l10n_be_annual_account_xbrl/odoo/addons/l10n_be_annual_account_xbrl @@ -0,0 +1 @@ +../../../../l10n_be_annual_account_xbrl \ No newline at end of file diff --git a/setup/l10n_be_annual_account_xbrl/setup.py b/setup/l10n_be_annual_account_xbrl/setup.py new file mode 100644 index 000000000..79c246bb2 --- /dev/null +++ b/setup/l10n_be_annual_account_xbrl/setup.py @@ -0,0 +1,7 @@ +import setuptools + + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)