From e51d1f2dfe6cedbda81afcaeb56c3b0ff09def9d Mon Sep 17 00:00:00 2001 From: Denis Roussel Date: Tue, 5 Sep 2023 15:30:54 +0200 Subject: [PATCH] [16.0][MIG] l10n_be_antibiotic_tax --- l10n_be_antibiotic_tax/README.rst | 75 +- l10n_be_antibiotic_tax/__init__.py | 1 + l10n_be_antibiotic_tax/__manifest__.py | 5 +- .../data/account_account_template_data.xml | 4 +- ...ccount_tax_template_antibiotic_in_data.xml | 1380 +++++++++++++++-- ...count_tax_template_antibiotic_out_data.xml | 1379 ++++++++++++++-- l10n_be_antibiotic_tax/hooks.py | 76 + l10n_be_antibiotic_tax/readme/CONFIGURE.rst | 6 + .../readme/CONTRIBUTORS.rst | 1 + l10n_be_antibiotic_tax/readme/DESCRIPTION.rst | 2 + l10n_be_antibiotic_tax/readme/INSTALL.rst | 1 + l10n_be_antibiotic_tax/readme/USAGE.rst | 20 + .../static/description/index.html | 457 ++++++ setup/l10n_be_antibiotic_tax/odoo/__init__.py | 1 - .../odoo/addons/__init__.py | 1 - 15 files changed, 3103 insertions(+), 306 deletions(-) create mode 100644 l10n_be_antibiotic_tax/hooks.py create mode 100644 l10n_be_antibiotic_tax/readme/CONFIGURE.rst create mode 100644 l10n_be_antibiotic_tax/readme/CONTRIBUTORS.rst create mode 100644 l10n_be_antibiotic_tax/readme/DESCRIPTION.rst create mode 100644 l10n_be_antibiotic_tax/readme/INSTALL.rst create mode 100644 l10n_be_antibiotic_tax/readme/USAGE.rst create mode 100644 l10n_be_antibiotic_tax/static/description/index.html delete mode 100644 setup/l10n_be_antibiotic_tax/odoo/__init__.py delete mode 100644 setup/l10n_be_antibiotic_tax/odoo/addons/__init__.py diff --git a/l10n_be_antibiotic_tax/README.rst b/l10n_be_antibiotic_tax/README.rst index ee7aa08d6..60cbc8f79 100644 --- a/l10n_be_antibiotic_tax/README.rst +++ b/l10n_be_antibiotic_tax/README.rst @@ -1,14 +1,41 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html - :alt: License: AGPL-3 - -======================== -Belgium Antibiotic Taxes -======================== +========================= +Belgium Antibiotics Taxes +========================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:54775e33696ffa4548414d7622091f6281470109f85166bbf7ef36c510c74a22 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--belgium-lightgray.png?logo=github + :target: https://github.com/OCA/l10n-belgium/tree/16.0/l10n_be_antibiotic_tax + :alt: OCA/l10n-belgium +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/l10n-belgium-16-0/l10n-belgium-16-0-l10n_be_antibiotic_tax + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-belgium&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| This is a data module which extends the l10n_be chart of taxes to support Antibiotics Taxes. +**Table of contents** + +.. contents:: + :local: + Installation ============ @@ -48,43 +75,43 @@ For further information, please visit: * https://www.odoo.com/forum/help-1 -Known issues / Roadmap -====================== - -* N/A - Bug Tracker =========== Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and -welcomed feedback. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. Credits ======= -Images ------- +Authors +~~~~~~~ -* Odoo Community Association: `Icon `_. +* BCIM sprl +* Okia Contributors ------------- +~~~~~~~~~~~~ -* Jacques-Etienne Baudoux +* Denis Roussel -Maintainer ----------- +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. .. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association :target: https://odoo-community.org -This module is maintained by the OCA. - OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -To contribute to this module, please visit http://odoo-community.org. +This module is part of the `OCA/l10n-belgium `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/l10n_be_antibiotic_tax/__init__.py b/l10n_be_antibiotic_tax/__init__.py index e69de29bb..e315f7b24 100644 --- a/l10n_be_antibiotic_tax/__init__.py +++ b/l10n_be_antibiotic_tax/__init__.py @@ -0,0 +1 @@ +from .hooks import post_init_hook diff --git a/l10n_be_antibiotic_tax/__manifest__.py b/l10n_be_antibiotic_tax/__manifest__.py index 348faeae4..5e191664a 100644 --- a/l10n_be_antibiotic_tax/__manifest__.py +++ b/l10n_be_antibiotic_tax/__manifest__.py @@ -5,8 +5,8 @@ { "name": "Belgium Antibiotics Taxes", "summary": "Data module to support antibiotics taxes", - "version": "10.0.1.0.0", - "author": "BCIM sprl, " "Okia, " "Odoo Community Association (OCA)", + "version": "16.0.1.0.0", + "author": "BCIM sprl, Okia, Odoo Community Association (OCA)", "category": "Generic Modules/Accounting", "website": "https://github.com/OCA/l10n-belgium", "depends": ["account", "l10n_be"], @@ -18,4 +18,5 @@ ], "license": "AGPL-3", "installable": True, + "post_init_hook": "post_init_hook", } diff --git a/l10n_be_antibiotic_tax/data/account_account_template_data.xml b/l10n_be_antibiotic_tax/data/account_account_template_data.xml index 92ce8274f..5fdbd4421 100644 --- a/l10n_be_antibiotic_tax/data/account_account_template_data.xml +++ b/l10n_be_antibiotic_tax/data/account_account_template_data.xml @@ -4,7 +4,7 @@ ANTIBIOTIC Sale 70097 - + income @@ -12,7 +12,7 @@ ANTIBIOTIC Purchase 60197 - + expense diff --git a/l10n_be_antibiotic_tax/data/account_tax_template_antibiotic_in_data.xml b/l10n_be_antibiotic_tax/data/account_tax_template_antibiotic_in_data.xml index b065aaa85..0b5e87d05 100644 --- a/l10n_be_antibiotic_tax/data/account_tax_template_antibiotic_in_data.xml +++ b/l10n_be_antibiotic_tax/data/account_tax_template_antibiotic_in_data.xml @@ -10,10 +10,34 @@ 0.01 fixed purchase - - + + - + 1 @@ -24,10 +48,34 @@ 0.02 fixed purchase - - + + - + 1 @@ -38,10 +86,34 @@ 0.03 fixed purchase - - + + - + 1 @@ -52,10 +124,34 @@ 0.04 fixed purchase - - + + - + 1 @@ -66,10 +162,34 @@ 0.05 fixed purchase - - + + - + 1 @@ -80,10 +200,34 @@ 0.06 fixed purchase - - + + - + 1 @@ -94,10 +238,34 @@ 0.07 fixed purchase - - + + - + 1 @@ -108,10 +276,34 @@ 0.08 fixed purchase - - + + - + 1 @@ -122,10 +314,34 @@ 0.09 fixed purchase - - + + - + 1 @@ -136,10 +352,34 @@ 0.10 fixed purchase - - + + - + 1 @@ -150,10 +390,34 @@ 0.11 fixed purchase - - + + - + 1 @@ -164,10 +428,34 @@ 0.12 fixed purchase - - + + - + 1 @@ -178,10 +466,34 @@ 0.13 fixed purchase - - + + - + 1 @@ -192,10 +504,34 @@ 0.14 fixed purchase - - + + - + 1 @@ -206,10 +542,34 @@ 0.16 fixed purchase - - + + - + 1 @@ -220,10 +580,34 @@ 0.17 fixed purchase - - + + - + 1 @@ -234,10 +618,34 @@ 0.18 fixed purchase - - + + - + 1 @@ -248,10 +656,34 @@ 0.20 fixed purchase - - + + - + 1 @@ -262,10 +694,34 @@ 0.24 fixed purchase - - + + - + 1 @@ -276,10 +732,34 @@ 0.26 fixed purchase - - + + - + 1 @@ -290,10 +770,34 @@ 0.31 fixed purchase - - + + - + 1 @@ -304,10 +808,34 @@ 0.32 fixed purchase - - + + - + 1 @@ -318,10 +846,34 @@ 0.33 fixed purchase - - + + - + 1 @@ -332,10 +884,34 @@ 0.35 fixed purchase - - + + - + 1 @@ -346,10 +922,34 @@ 0.37 fixed purchase - - + + - + 1 @@ -360,10 +960,34 @@ 0.39 fixed purchase - - + + - + 1 @@ -374,10 +998,34 @@ 0.41 fixed purchase - - + + - + 1 @@ -388,10 +1036,34 @@ 0.42 fixed purchase - - + + - + 1 @@ -402,10 +1074,34 @@ 0.50 fixed purchase - - + + - + 1 @@ -416,10 +1112,34 @@ 0.53 fixed purchase - - + + - + 1 @@ -430,10 +1150,34 @@ 0.61 fixed purchase - - + + - + 1 @@ -444,10 +1188,34 @@ 0.63 fixed purchase - - + + - + 1 @@ -458,10 +1226,34 @@ 0.66 fixed purchase - - + + - + 1 @@ -472,10 +1264,34 @@ 0.79 fixed purchase - - + + - + 1 @@ -486,10 +1302,34 @@ 0.88 fixed purchase - - + + - + 1 @@ -500,10 +1340,34 @@ 0.90 fixed purchase - - + + - + 1 @@ -514,10 +1378,34 @@ 0.92 fixed purchase - - + + - + 1 @@ -528,10 +1416,34 @@ 1.05 fixed purchase - - + + - + 1 @@ -542,10 +1454,34 @@ 1.23 fixed purchase - - + + - + 1 @@ -556,10 +1492,34 @@ 1.31 fixed purchase - - + + - + 1 @@ -570,10 +1530,34 @@ 1.40 fixed purchase - - + + - + 1 @@ -584,10 +1568,34 @@ 1.58 fixed purchase - - + + - + 1 @@ -598,10 +1606,34 @@ 1.75 fixed purchase - - + + - + 1 @@ -612,10 +1644,34 @@ 2.04 fixed purchase - - + + - + 1 @@ -626,10 +1682,34 @@ 2.14 fixed purchase - - + + - + 1 @@ -640,10 +1720,34 @@ 2.63 fixed purchase - - + + - + diff --git a/l10n_be_antibiotic_tax/data/account_tax_template_antibiotic_out_data.xml b/l10n_be_antibiotic_tax/data/account_tax_template_antibiotic_out_data.xml index 0d41734f4..ab5228f5d 100644 --- a/l10n_be_antibiotic_tax/data/account_tax_template_antibiotic_out_data.xml +++ b/l10n_be_antibiotic_tax/data/account_tax_template_antibiotic_out_data.xml @@ -10,10 +10,33 @@ 0.01 fixed sale - - + + - 1 @@ -24,10 +47,34 @@ 0.02 fixed sale - - + + - + 1 @@ -38,10 +85,34 @@ 0.03 fixed sale - - + + - + 1 @@ -52,10 +123,34 @@ 0.04 fixed sale - - + + - + 1 @@ -66,10 +161,34 @@ 0.05 fixed sale - - + + - + 1 @@ -80,10 +199,34 @@ 0.06 fixed sale - - + + - + 1 @@ -94,10 +237,34 @@ 0.07 fixed sale - - + + - + 1 @@ -108,10 +275,34 @@ 0.08 fixed sale - - + + - + 1 @@ -122,10 +313,34 @@ 0.09 fixed sale - - + + - + 1 @@ -136,10 +351,34 @@ 0.10 fixed sale - - + + - + 1 @@ -150,10 +389,34 @@ 0.11 fixed sale - - + + - + 1 @@ -164,10 +427,34 @@ 0.12 fixed sale - - + + - + 1 @@ -178,10 +465,34 @@ 0.13 fixed sale - - + + - + 1 @@ -192,10 +503,34 @@ 0.14 fixed sale - - + + - + 1 @@ -206,10 +541,34 @@ 0.16 fixed sale - - + + - + 1 @@ -220,10 +579,34 @@ 0.17 fixed sale - - + + - + 1 @@ -234,10 +617,34 @@ 0.18 fixed sale - - + + - + 1 @@ -248,10 +655,34 @@ 0.20 fixed sale - - + + - + 1 @@ -262,10 +693,34 @@ 0.24 fixed sale - - + + - + 1 @@ -276,10 +731,34 @@ 0.26 fixed sale - - + + - + 1 @@ -290,10 +769,34 @@ 0.31 fixed sale - - + + - + 1 @@ -304,10 +807,34 @@ 0.32 fixed sale - - + + - + 1 @@ -318,10 +845,34 @@ 0.33 fixed sale - - + + - + 1 @@ -332,10 +883,34 @@ 0.35 fixed sale - - + + - + 1 @@ -346,10 +921,34 @@ 0.37 fixed sale - - + + - + 1 @@ -360,10 +959,34 @@ 0.39 fixed sale - - + + - + 1 @@ -374,10 +997,34 @@ 0.41 fixed sale - - + + - + 1 @@ -388,10 +1035,34 @@ 0.42 fixed sale - - + + - + 1 @@ -402,10 +1073,34 @@ 0.50 fixed sale - - + + - + 1 @@ -416,10 +1111,34 @@ 0.53 fixed sale - - + + - + 1 @@ -430,10 +1149,34 @@ 0.61 fixed sale - - + + - + 1 @@ -444,10 +1187,34 @@ 0.63 fixed sale - - + + - + 1 @@ -458,10 +1225,34 @@ 0.65 fixed sale - - + + - + 1 @@ -472,10 +1263,34 @@ 0.79 fixed sale - - + + - + 1 @@ -486,10 +1301,34 @@ 0.88 fixed sale - - + + - + 1 @@ -500,10 +1339,34 @@ 0.90 fixed sale - - + + - + 1 @@ -514,10 +1377,34 @@ 0.92 fixed sale - - + + - + 1 @@ -528,10 +1415,34 @@ 1.05 fixed sale - - + + - + 1 @@ -542,10 +1453,34 @@ 1.23 fixed sale - - + + - + 1 @@ -556,10 +1491,34 @@ 1.31 fixed sale - - + + - + 1 @@ -570,10 +1529,34 @@ 1.40 fixed sale - - + + - + 1 @@ -584,10 +1567,34 @@ 1.58 fixed sale - - + + - + 1 @@ -598,10 +1605,34 @@ 1.75 fixed sale - - + + - + 1 @@ -612,10 +1643,34 @@ 2.04 fixed sale - - + + - + 1 @@ -626,10 +1681,34 @@ 2.14 fixed sale - - + + - + 1 @@ -640,10 +1719,34 @@ 2.63 fixed sale - - + + - + diff --git a/l10n_be_antibiotic_tax/hooks.py b/l10n_be_antibiotic_tax/hooks.py new file mode 100644 index 000000000..963ff8da8 --- /dev/null +++ b/l10n_be_antibiotic_tax/hooks.py @@ -0,0 +1,76 @@ +# Copyright 2023 ACSONE SA/V +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + + +import logging + +from odoo import SUPERUSER_ID, api + +_logger = logging.getLogger(__name__) + + +def load_taxes(env): + # Inspirated from : + # https://github.com/odoo/odoo/blob/0d67107ab2fc048d8b9fdf11296db1460ba539ac + # /addons/l10n_in_tcs_tds/__init__.py#L13 + in_chart_template = env.ref("l10n_be.l10nbe_chart_template") + for company in env["res.company"].search( + [("chart_template_id", "=", in_chart_template.id)] + ): + try: + with env.cr.savepoint(): + tax_template_ids = ( + env["ir.model.data"] + .search( + [ + ("module", "=", "l10n_be_antibiotic_tax"), + ("model", "=", "account.tax.template"), + ] + ) + .mapped("res_id") + ) + generated_tax_res = ( + env["account.tax.template"] + .browse(tax_template_ids) + ._generate_tax(company) + ) + taxes_ref = generated_tax_res["tax_template_to_tax"] + except Exception: + taxes_ref = {} + _logger.error( + "Can't load Antibiotic taxes for company: %s(%s).", + company.name, + company.id, + ) + if taxes_ref: + try: + with env.cr.savepoint(): + account_ref = {} + # Generating Accounts from templates. + account_template_ref = in_chart_template.generate_account( + taxes_ref, {}, in_chart_template.code_digits, company + ) + account_ref.update(account_template_ref) + + # writing account values after creation of accounts + for key, value in generated_tax_res["account_dict"][ + "account.tax.repartition.line" + ].items(): + if value["account_id"]: + key.write( + { + "account_id": account_ref.get(value["account_id"]), + } + ) + except Exception: + _logger.error( + "Can't load Antibiotic account so account is not set" + " in taxes of company: %s(%s).", + company.name, + company.id, + ) + + +def post_init_hook(cr, registry): + env = api.Environment(cr, SUPERUSER_ID, {}) + load_taxes(env) diff --git a/l10n_be_antibiotic_tax/readme/CONFIGURE.rst b/l10n_be_antibiotic_tax/readme/CONFIGURE.rst new file mode 100644 index 000000000..44d0a63bc --- /dev/null +++ b/l10n_be_antibiotic_tax/readme/CONFIGURE.rst @@ -0,0 +1,6 @@ +If you install this module after instanciating the chart of account +for your company, it is recommanded to use the account_chart_update +module from the OCA/account-financial-tools repository . + +You may also need to customize your invoice layout to render +these antibiotic taxes in the desired way. diff --git a/l10n_be_antibiotic_tax/readme/CONTRIBUTORS.rst b/l10n_be_antibiotic_tax/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..9179ee4b8 --- /dev/null +++ b/l10n_be_antibiotic_tax/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Denis Roussel diff --git a/l10n_be_antibiotic_tax/readme/DESCRIPTION.rst b/l10n_be_antibiotic_tax/readme/DESCRIPTION.rst new file mode 100644 index 000000000..761affcf4 --- /dev/null +++ b/l10n_be_antibiotic_tax/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This is a data module which extends the l10n_be chart of taxes +to support Antibiotics Taxes. diff --git a/l10n_be_antibiotic_tax/readme/INSTALL.rst b/l10n_be_antibiotic_tax/readme/INSTALL.rst new file mode 100644 index 000000000..9d94322d9 --- /dev/null +++ b/l10n_be_antibiotic_tax/readme/INSTALL.rst @@ -0,0 +1 @@ +There is no specific installation procedure for this module. diff --git a/l10n_be_antibiotic_tax/readme/USAGE.rst b/l10n_be_antibiotic_tax/readme/USAGE.rst new file mode 100644 index 000000000..c0cbca0d3 --- /dev/null +++ b/l10n_be_antibiotic_tax/readme/USAGE.rst @@ -0,0 +1,20 @@ +To use this module, you need to add the antibiotic +taxes on the products which are subjected to these rules: + +* https://www.fagg-afmps.be/fr/veterinaire/medicaments/medicaments/distribution/taxe_antibiotique + +You must make sure that the sequences of the ANTIOTIC taxes +is smaller than the sequences of the VAT taxes so the VAT is correctly +computed on top of the ANTIBIOTIC taxes. The sequences are correct +when using l10n_be_taxes. + +The module also define a specific tax code template for antibiotic taxes which +may help in reporting, and specific expense and income account templates. + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/119/9.0 + +For further information, please visit: + +* https://www.odoo.com/forum/help-1 diff --git a/l10n_be_antibiotic_tax/static/description/index.html b/l10n_be_antibiotic_tax/static/description/index.html new file mode 100644 index 000000000..51de7c7de --- /dev/null +++ b/l10n_be_antibiotic_tax/static/description/index.html @@ -0,0 +1,457 @@ + + + + + + +Belgium Antibiotics Taxes + + + +
+

Belgium Antibiotics Taxes

+ + +

Beta License: AGPL-3 OCA/l10n-belgium Translate me on Weblate Try me on Runboat

+

This is a data module which extends the l10n_be chart of taxes +to support Antibiotics Taxes.

+

Table of contents

+ +
+

Installation

+

There is no specific installation procedure for this module.

+
+
+

Configuration

+

If you install this module after instanciating the chart of account +for your company, it is recommanded to use the account_chart_update +module from the OCA/account-financial-tools repository .

+

You may also need to customize your invoice layout to render +these antibiotic taxes in the desired way.

+
+
+

Usage

+

To use this module, you need to add the antibiotic +taxes on the products which are subjected to these rules:

+ +

You must make sure that the sequences of the ANTIOTIC taxes +is smaller than the sequences of the VAT taxes so the VAT is correctly +computed on top of the ANTIBIOTIC taxes. The sequences are correct +when using l10n_be_taxes.

+

The module also define a specific tax code template for antibiotic taxes which +may help in reporting, and specific expense and income account templates.

+Try me on Runbot +

For further information, please visit:

+ +
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • BCIM sprl
  • +
  • Okia
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/l10n-belgium project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/setup/l10n_be_antibiotic_tax/odoo/__init__.py b/setup/l10n_be_antibiotic_tax/odoo/__init__.py deleted file mode 100644 index de40ea7ca..000000000 --- a/setup/l10n_be_antibiotic_tax/odoo/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__('pkg_resources').declare_namespace(__name__) diff --git a/setup/l10n_be_antibiotic_tax/odoo/addons/__init__.py b/setup/l10n_be_antibiotic_tax/odoo/addons/__init__.py deleted file mode 100644 index de40ea7ca..000000000 --- a/setup/l10n_be_antibiotic_tax/odoo/addons/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__('pkg_resources').declare_namespace(__name__)