diff --git a/account_reconcile_model_strict_match_amount/README.rst b/account_reconcile_model_strict_match_amount/README.rst new file mode 100644 index 00000000..a3135759 --- /dev/null +++ b/account_reconcile_model_strict_match_amount/README.rst @@ -0,0 +1,83 @@ +================================================ +Account Reconciliation Model Strict Match Amount +================================================ + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Faccount--reconcile-lightgray.png?logo=github + :target: https://github.com/OCA/account-reconcile/tree/14.0/account_reconcile_model_strict_match_amount + :alt: OCA/account-reconcile +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/account-reconcile-14-0/account-reconcile-14-0-account_reconcile_model_strict_match_amount + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/98/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to cancel the bypassing of Amount Matching feature on +Reconciliation models "in case of a statement line communication matching +exactly existing entries", to ensure only statement lines matching the total +amount (or according to its percentage) will be reconciled automatically. + +**Table of contents** + +.. contents:: + :local: + +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Camptocamp + +Contributors +~~~~~~~~~~~~ + +* Akim Juillerat +* `Trobz `_: + * Nguyen Ho + +Other credits +~~~~~~~~~~~~~ + +The migration of this module from 13.0 to 14.0 was financially supported by Camptocamp + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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/account-reconcile `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_reconcile_model_strict_match_amount/__init__.py b/account_reconcile_model_strict_match_amount/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/account_reconcile_model_strict_match_amount/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/account_reconcile_model_strict_match_amount/__manifest__.py b/account_reconcile_model_strict_match_amount/__manifest__.py new file mode 100644 index 00000000..9dcc1875 --- /dev/null +++ b/account_reconcile_model_strict_match_amount/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2020 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) +{ + "name": "Account Reconciliation Model Strict Match Amount", + "summary": "Restrict reconciliation propositions to matching amount parameter", + "version": "14.0.1.0.0", + "category": "Accounting", + "website": "https://github.com/OCA/account-reconcile", + "author": "Camptocamp, Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": ["account"], + "data": ["views/account_reconcile_model.xml"], +} diff --git a/account_reconcile_model_strict_match_amount/i18n/account_reconcile_model_strict_match_amount.pot b/account_reconcile_model_strict_match_amount/i18n/account_reconcile_model_strict_match_amount.pot new file mode 100644 index 00000000..0710fd74 --- /dev/null +++ b/account_reconcile_model_strict_match_amount/i18n/account_reconcile_model_strict_match_amount.pot @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_reconcile_model_strict_match_amount +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_reconcile_model_strict_match_amount +#: model:ir.model.fields,help:account_reconcile_model_strict_match_amount.field_account_reconcile_model__strict_match_total_amount +msgid "" +"Avoid bypassing the Amount Matching parameter in case of a statement line " +"communication matching exactly existing entries." +msgstr "" + +#. module: account_reconcile_model_strict_match_amount +#: model:ir.model,name:account_reconcile_model_strict_match_amount.model_account_reconcile_model +msgid "" +"Preset to create journal entries during a invoices and payments matching" +msgstr "" + +#. module: account_reconcile_model_strict_match_amount +#: model:ir.model.fields,field_description:account_reconcile_model_strict_match_amount.field_account_reconcile_model__strict_match_total_amount +msgid "Strict Amount Matching" +msgstr "" diff --git a/account_reconcile_model_strict_match_amount/models/__init__.py b/account_reconcile_model_strict_match_amount/models/__init__.py new file mode 100644 index 00000000..e27d0c6c --- /dev/null +++ b/account_reconcile_model_strict_match_amount/models/__init__.py @@ -0,0 +1 @@ +from . import account_reconcile_model diff --git a/account_reconcile_model_strict_match_amount/models/account_reconcile_model.py b/account_reconcile_model_strict_match_amount/models/account_reconcile_model.py new file mode 100644 index 00000000..ab1783a0 --- /dev/null +++ b/account_reconcile_model_strict_match_amount/models/account_reconcile_model.py @@ -0,0 +1,63 @@ +# Copyright 2020 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) +from odoo import fields, models + + +class AccountReconcileModel(models.Model): + + _inherit = "account.reconcile.model" + + strict_match_total_amount = fields.Boolean( + string="Strict Amount Matching", + help="Avoid bypassing the Amount Matching parameter in case of a " + "statement line communication matching exactly existing entries.", + ) + + # flake8: noqa + def _get_select_communication_flag(self): + comm_flag = super()._get_select_communication_flag() + if not self.match_total_amount or not self.strict_match_total_amount: + return comm_flag + # comm_flag.replace is for 13.0 + comm_flag = ( + r""" + COALESCE( + """ + + comm_flag.replace("AS communication_flag", "") + + r""" + , FALSE) + AND + CASE + WHEN abs(st_line.amount) < abs(aml.balance) THEN abs(st_line.amount) / abs(aml.balance) * 100 + WHEN abs(st_line.amount) > abs(aml.balance) THEN abs(aml.balance) / abs(st_line.amount) * 100 + ELSE 100 + END >= {match_total_amount_param} + """.format( + match_total_amount_param=self.match_total_amount_param + ) + ) + return comm_flag + + def _get_select_payment_reference_flag(self): + ref_flag = super()._get_select_payment_reference_flag() + if not self.match_total_amount or not self.strict_match_total_amount: + return ref_flag + # ref_flag.replace is for 13.0 + ref_flag = ( + r""" + COALESCE( + """ + + ref_flag.replace("AS reference_flag", "") + + r""" + , FALSE) + AND + CASE + WHEN abs(st_line.amount) < abs(aml.balance) THEN abs(st_line.amount) / abs(aml.balance) * 100 + WHEN abs(st_line.amount) > abs(aml.balance) THEN abs(aml.balance) / abs(st_line.amount) * 100 + ELSE 100 + END >= {match_total_amount_param} + """.format( + match_total_amount_param=self.match_total_amount_param + ) + ) + return ref_flag diff --git a/account_reconcile_model_strict_match_amount/readme/CONTRIBUTORS.rst b/account_reconcile_model_strict_match_amount/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..ff1c829b --- /dev/null +++ b/account_reconcile_model_strict_match_amount/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* Akim Juillerat +* `Trobz `_: + * Nguyen Ho diff --git a/account_reconcile_model_strict_match_amount/readme/CREDITS.rst b/account_reconcile_model_strict_match_amount/readme/CREDITS.rst new file mode 100644 index 00000000..f37ebe75 --- /dev/null +++ b/account_reconcile_model_strict_match_amount/readme/CREDITS.rst @@ -0,0 +1 @@ +The migration of this module from 13.0 to 14.0 was financially supported by Camptocamp diff --git a/account_reconcile_model_strict_match_amount/readme/DESCRIPTION.rst b/account_reconcile_model_strict_match_amount/readme/DESCRIPTION.rst new file mode 100644 index 00000000..0c77d35b --- /dev/null +++ b/account_reconcile_model_strict_match_amount/readme/DESCRIPTION.rst @@ -0,0 +1,4 @@ +This module allows to cancel the bypassing of Amount Matching feature on +Reconciliation models "in case of a statement line communication matching +exactly existing entries", to ensure only statement lines matching the total +amount (or according to its percentage) will be reconciled automatically. diff --git a/account_reconcile_model_strict_match_amount/static/description/icon.png b/account_reconcile_model_strict_match_amount/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/account_reconcile_model_strict_match_amount/static/description/icon.png differ diff --git a/account_reconcile_model_strict_match_amount/static/description/index.html b/account_reconcile_model_strict_match_amount/static/description/index.html new file mode 100644 index 00000000..22ee33c6 --- /dev/null +++ b/account_reconcile_model_strict_match_amount/static/description/index.html @@ -0,0 +1,435 @@ + + + + + + +Account Reconciliation Model Strict Match Amount + + + +
+

Account Reconciliation Model Strict Match Amount

+ + +

Beta License: AGPL-3 OCA/account-reconcile Translate me on Weblate Try me on Runbot

+

This module allows to cancel the bypassing of Amount Matching feature on +Reconciliation models “in case of a statement line communication matching +exactly existing entries”, to ensure only statement lines matching the total +amount (or according to its percentage) will be reconciled automatically.

+

Table of contents

+ +
+

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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Camptocamp
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

The migration of this module from 13.0 to 14.0 was financially supported by Camptocamp

+
+
+

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/account-reconcile project on GitHub.

+

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

+
+
+
+ + diff --git a/account_reconcile_model_strict_match_amount/tests/__init__.py b/account_reconcile_model_strict_match_amount/tests/__init__.py new file mode 100644 index 00000000..97a05422 --- /dev/null +++ b/account_reconcile_model_strict_match_amount/tests/__init__.py @@ -0,0 +1 @@ +from . import test_account_reconcile_model_strict_match_amount diff --git a/account_reconcile_model_strict_match_amount/tests/test_account_reconcile_model_strict_match_amount.py b/account_reconcile_model_strict_match_amount/tests/test_account_reconcile_model_strict_match_amount.py new file mode 100644 index 00000000..5202c1b6 --- /dev/null +++ b/account_reconcile_model_strict_match_amount/tests/test_account_reconcile_model_strict_match_amount.py @@ -0,0 +1,150 @@ +# Copyright 2020 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) +from odoo.tests import tagged + +from odoo.addons.account.tests.test_reconciliation_matching_rules import ( + TestReconciliationMatchingRules, +) + + +@tagged("post_install", "-at_install") +class TestAccountReconcileModelStrictMatchAmount(TestReconciliationMatchingRules): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.partner_s_3 = cls.env["res.partner"].create({"name": "partner_s_3"}) + cls.partner_s_4 = cls.env["res.partner"].create({"name": "partner_s_4"}) + cls.partner_s_5 = cls.env["res.partner"].create({"name": "partner_s_5"}) + cls.partner_s_6 = cls.env["res.partner"].create({"name": "partner_s_6"}) + cls.invoice_line_s_5 = cls._create_invoice_line( + 150, cls.partner_s_3, "out_invoice" + ) + # Explicitly set the ref on the account.move after field on the line + # was defined as readonly and value is not written anymore + # cf https://github.com/odoo/odoo/commit/38c13bbef39e3e82a77cfd4a316be94280e3cee5 # noqa + cls.invoice_line_s_5.move_id.ref = "ABC001XYZ" + cls.invoice_line_s_6 = cls._create_invoice_line( + 300, cls.partner_s_4, "out_invoice" + ) + cls.invoice_line_s_6.name = "ABC002XYZ" + cls.invoice_line_s_7 = cls._create_invoice_line( + 450, cls.partner_s_5, "out_invoice" + ) + cls.invoice_line_s_7.move_id.ref = "ABC003XYZ" + cls.invoice_line_s_8 = cls._create_invoice_line( + 600, cls.partner_s_6, "out_invoice" + ) + cls.invoice_line_s_8.move_id.payment_reference = "ABC004XYZ" + cls.bank_st_s = cls.env["account.bank.statement"].create( + { + "name": "test bank journal 2", + "journal_id": cls.company_data["default_journal_bank"].id, + } + ) + + cls.bank_line_s_3 = cls.env["account.bank.statement.line"].create( + { + "statement_id": cls.bank_st_s.id, + "payment_ref": "ABC001XYZ", + "partner_id": cls.partner_s_3.id, + "amount": 135, + "sequence": 1, + } + ) + cls.bank_line_s_4 = cls.env["account.bank.statement.line"].create( + { + "statement_id": cls.bank_st_s.id, + "payment_ref": "ABC002XYZ", + "partner_id": cls.partner_s_4.id, + "amount": 270, + "sequence": 2, + } + ) + cls.bank_line_s_5 = cls.env["account.bank.statement.line"].create( + { + "statement_id": cls.bank_st_s.id, + "payment_ref": "ABC003XYZ", + "partner_id": cls.partner_s_5.id, + "amount": 405, + "sequence": 3, + } + ) + cls.bank_line_s_6 = cls.env["account.bank.statement.line"].create( + { + "statement_id": cls.bank_st_s.id, + "payment_ref": "ABC004XYZ", + "partner_id": cls.partner_s_6.id, + "amount": 540, + "sequence": 4, + } + ) + cls.bank_st_s.balance_end_real = cls.bank_st_s.balance_end + cls.bank_st_s.button_post() + + def test_auto_reconcile_strict_match_100(self): + my_rule = self.env["account.reconcile.model"].create( + { + "name": "Strict Invoice matching amount 100%", + "rule_type": "invoice_matching", + "auto_reconcile": True, + "match_nature": "both", + "match_same_currency": True, + "match_total_amount": True, + "match_total_amount_param": 100.0, + "strict_match_total_amount": True, + } + ) + self._check_statement_matching( + my_rule, + { + self.bank_line_s_3.id: {"aml_ids": []}, + self.bank_line_s_4.id: {"aml_ids": []}, + self.bank_line_s_5.id: {"aml_ids": []}, + self.bank_line_s_6.id: {"aml_ids": []}, + }, + statements=self.bank_st_s, + ) + + def test_auto_reconcile_strict_match_90(self): + my_rule = self.env["account.reconcile.model"].create( + { + "name": "Strict Invoice matching amount 90%", + "rule_type": "invoice_matching", + "auto_reconcile": True, + "match_nature": "both", + "match_same_currency": True, + "match_total_amount": True, + "match_total_amount_param": 90.0, + "strict_match_total_amount": True, + } + ) + self._check_statement_matching( + my_rule, + { + self.bank_line_s_3.id: { + "aml_ids": [self.invoice_line_s_5.id], + "model": my_rule, + "status": "reconciled", + "partner": self.partner_s_3, + }, + self.bank_line_s_4.id: { + "aml_ids": [self.invoice_line_s_6.id], + "model": my_rule, + "status": "reconciled", + "partner": self.partner_s_4, + }, + self.bank_line_s_5.id: { + "aml_ids": [self.invoice_line_s_7.id], + "model": my_rule, + "status": "reconciled", + "partner": self.partner_s_5, + }, + self.bank_line_s_6.id: { + "aml_ids": [self.invoice_line_s_8.id], + "model": my_rule, + "status": "reconciled", + "partner": self.partner_s_6, + }, + }, + statements=self.bank_st_s, + ) diff --git a/account_reconcile_model_strict_match_amount/views/account_reconcile_model.xml b/account_reconcile_model_strict_match_amount/views/account_reconcile_model.xml new file mode 100644 index 00000000..a55833fe --- /dev/null +++ b/account_reconcile_model_strict_match_amount/views/account_reconcile_model.xml @@ -0,0 +1,24 @@ + + + + account.reconcile.model.form + account.reconcile.model + + + + + + + {'invisible': ['|', '|', ('rule_type', '!=', 'invoice_matching'), ('match_total_amount', '=', False), ('strict_match_total_amount', '=', True)]} + + + + diff --git a/setup/account_reconcile_model_strict_match_amount/odoo/addons/account_reconcile_model_strict_match_amount b/setup/account_reconcile_model_strict_match_amount/odoo/addons/account_reconcile_model_strict_match_amount new file mode 120000 index 00000000..96241da0 --- /dev/null +++ b/setup/account_reconcile_model_strict_match_amount/odoo/addons/account_reconcile_model_strict_match_amount @@ -0,0 +1 @@ +../../../../account_reconcile_model_strict_match_amount \ No newline at end of file diff --git a/setup/account_reconcile_model_strict_match_amount/setup.py b/setup/account_reconcile_model_strict_match_amount/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/account_reconcile_model_strict_match_amount/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)