diff --git a/account_reconcile_model_no_numerical_token/README.rst b/account_reconcile_model_no_numerical_token/README.rst new file mode 100644 index 000000000..0d1356c18 --- /dev/null +++ b/account_reconcile_model_no_numerical_token/README.rst @@ -0,0 +1,96 @@ +========================================== +Account Reconcile Model No Numerical Token +========================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:fc89fd82413d4800348392c27b1ede21655c0afa5789275d21213f28a333f62d + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/16.0/account_reconcile_model_no_numerical_token + :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-16-0/account-reconcile-16-0-account_reconcile_model_no_numerical_token + :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/account-reconcile&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +By default, when Odoo encounters a bank statement line ref such as a34bc3xxx1, it +will extract the numerical characters and concatenate them into a numerical token, +eg. 3431 in this case. If then a move line is found that has for example cxxx343y1 +as a ref, it will match with this one also: not on the text ref but via the +numerical component. + +Sometimes this is not desirable. + +This module allows to configure a checkbox on a reconcile model to disable +numerical token matching for this model. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to: + +#. Open any reconcile model +#. Check the box: No Numerical Token Matching +#. Reconcile like usual, and less matches will be found (but hopefully better ones) + +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 +~~~~~~~ + +* Therp BV + +Contributors +~~~~~~~~~~~~ + +* `Therp BV `_: + + * Tom Blauwendraat + +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_no_numerical_token/__init__.py b/account_reconcile_model_no_numerical_token/__init__.py new file mode 100644 index 000000000..31660d6a9 --- /dev/null +++ b/account_reconcile_model_no_numerical_token/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models diff --git a/account_reconcile_model_no_numerical_token/__manifest__.py b/account_reconcile_model_no_numerical_token/__manifest__.py new file mode 100644 index 000000000..326a8ca37 --- /dev/null +++ b/account_reconcile_model_no_numerical_token/__manifest__.py @@ -0,0 +1,14 @@ +# Copyright 2024 Therp BV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Account Reconcile Model No Numerical Token", + "summary": "Disable the use of numerical token in Odoo native reconcilation", + "version": "16.0.1.0.0", + "category": "Finance", + "website": "https://github.com/OCA/account-reconcile", + "author": "Therp BV, Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": ["account"], + "data": ["views/account_reconcile_model.xml"], +} diff --git a/account_reconcile_model_no_numerical_token/models/__init__.py b/account_reconcile_model_no_numerical_token/models/__init__.py new file mode 100644 index 000000000..5b7501d56 --- /dev/null +++ b/account_reconcile_model_no_numerical_token/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import account_reconcile_model diff --git a/account_reconcile_model_no_numerical_token/models/account_reconcile_model.py b/account_reconcile_model_no_numerical_token/models/account_reconcile_model.py new file mode 100644 index 000000000..b74f2e1da --- /dev/null +++ b/account_reconcile_model_no_numerical_token/models/account_reconcile_model.py @@ -0,0 +1,22 @@ +# Copyright 2024 Therp BV +# 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" + + no_numerical_tokens = fields.Boolean( + "No numerical token matching", help="Don't match on numerical tokens" + ) + + def _get_invoice_matching_st_line_tokens(self, st_line): + ( + numerical_tokens, + exact_tokens, + _text_tokens, + ) = super()._get_invoice_matching_st_line_tokens(st_line) + if self.no_numerical_tokens: + return [], exact_tokens, _text_tokens + return numerical_tokens, exact_tokens, _text_tokens diff --git a/account_reconcile_model_no_numerical_token/readme/CONTRIBUTORS.rst b/account_reconcile_model_no_numerical_token/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..57367f559 --- /dev/null +++ b/account_reconcile_model_no_numerical_token/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Therp BV `_: + + * Tom Blauwendraat diff --git a/account_reconcile_model_no_numerical_token/readme/DESCRIPTION.rst b/account_reconcile_model_no_numerical_token/readme/DESCRIPTION.rst new file mode 100644 index 000000000..1ff498454 --- /dev/null +++ b/account_reconcile_model_no_numerical_token/readme/DESCRIPTION.rst @@ -0,0 +1,10 @@ +By default, when Odoo encounters a bank statement line ref such as a34bc3xxx1, it +will extract the numerical characters and concatenate them into a numerical token, +eg. 3431 in this case. If then a move line is found that has for example cxxx343y1 +as a ref, it will match with this one also: not on the text ref but via the +numerical component. + +Sometimes this is not desirable. + +This module allows to configure a checkbox on a reconcile model to disable +numerical token matching for this model. diff --git a/account_reconcile_model_no_numerical_token/readme/USAGE.rst b/account_reconcile_model_no_numerical_token/readme/USAGE.rst new file mode 100644 index 000000000..8226d8c3c --- /dev/null +++ b/account_reconcile_model_no_numerical_token/readme/USAGE.rst @@ -0,0 +1,5 @@ +To use this module, you need to: + +#. Open any reconcile model +#. Check the box: No Numerical Token Matching +#. Reconcile like usual, and less matches will be found (but hopefully better ones) diff --git a/account_reconcile_model_no_numerical_token/static/description/icon.png b/account_reconcile_model_no_numerical_token/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/account_reconcile_model_no_numerical_token/static/description/icon.png differ diff --git a/account_reconcile_model_no_numerical_token/static/description/index.html b/account_reconcile_model_no_numerical_token/static/description/index.html new file mode 100644 index 000000000..a96eb2689 --- /dev/null +++ b/account_reconcile_model_no_numerical_token/static/description/index.html @@ -0,0 +1,443 @@ + + + + + +Account Reconcile Model No Numerical Token + + + +
+

Account Reconcile Model No Numerical Token

+ + +

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

+

By default, when Odoo encounters a bank statement line ref such as a34bc3xxx1, it +will extract the numerical characters and concatenate them into a numerical token, +eg. 3431 in this case. If then a move line is found that has for example cxxx343y1 +as a ref, it will match with this one also: not on the text ref but via the +numerical component.

+

Sometimes this is not desirable.

+

This module allows to configure a checkbox on a reconcile model to disable +numerical token matching for this model.

+

Table of contents

+ +
+

Usage

+

To use this module, you need to:

+
    +
  1. Open any reconcile model
  2. +
  3. Check the box: No Numerical Token Matching
  4. +
  5. Reconcile like usual, and less matches will be found (but hopefully better ones)
  6. +
+
+
+

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

+
    +
  • Therp BV
  • +
+
+
+

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/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_no_numerical_token/tests/__init__.py b/account_reconcile_model_no_numerical_token/tests/__init__.py new file mode 100644 index 000000000..5a9a55610 --- /dev/null +++ b/account_reconcile_model_no_numerical_token/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_account_reconcile_no_numerical_token diff --git a/account_reconcile_model_no_numerical_token/tests/test_account_reconcile_no_numerical_token.py b/account_reconcile_model_no_numerical_token/tests/test_account_reconcile_no_numerical_token.py new file mode 100644 index 000000000..4627cbcc0 --- /dev/null +++ b/account_reconcile_model_no_numerical_token/tests/test_account_reconcile_no_numerical_token.py @@ -0,0 +1,139 @@ +# Copyright 2024 Therp BV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from contextlib import contextmanager + +from freezegun import freeze_time + +from odoo import Command +from odoo.tests import tagged + +from odoo.addons.account.tests.common import AccountTestInvoicingCommon + + +@tagged("post_install", "-at_install") +class TestAccountReconcileNoNumericalToken(AccountTestInvoicingCommon): + @classmethod + def setUpClass(cls, chart_template_ref=None): + super().setUpClass(chart_template_ref=chart_template_ref) + + cls.company = cls.company_data["company"] + + cls.bank_journal = cls.env["account.journal"].search( + [("type", "=", "bank"), ("company_id", "=", cls.company.id)], limit=1 + ) + + @classmethod + def _create_st_line( + cls, amount=1000.0, date="2019-01-01", payment_ref="turlututu", **kwargs + ): + st_line = cls.env["account.bank.statement.line"].create( + { + "journal_id": kwargs.get("journal_id", cls.bank_journal.id), + "amount": amount, + "date": date, + "payment_ref": payment_ref, + "partner_id": cls.partner_a.id, + **kwargs, + } + ) + return st_line + + @classmethod + def _create_reconcile_model(cls, **kwargs): + return cls.env["account.reconcile.model"].create( + { + "name": "test", + "rule_type": "invoice_matching", + "allow_payment_tolerance": True, + "payment_tolerance_type": "percentage", + "payment_tolerance_param": 0.0, + **kwargs, + "line_ids": [ + Command.create( + { + "account_id": cls.company_data[ + "default_account_revenue" + ].id, + "amount_type": "percentage", + "label": f"test {i}", + **line_vals, + } + ) + for i, line_vals in enumerate(kwargs.get("line_ids", [])) + ], + "partner_mapping_line_ids": [ + Command.create(line_vals) + for i, line_vals in enumerate( + kwargs.get("partner_mapping_line_ids", []) + ) + ], + } + ) + + @freeze_time("2019-01-01") + def test_invoice_matching_using_match_text_location(self): + @contextmanager + def rollback(): + savepoint = self.cr.savepoint() + yield + savepoint.rollback() + + rule = self._create_reconcile_model( + match_partner=False, + allow_payment_tolerance=False, + match_text_location_label=False, + match_text_location_reference=False, + match_text_location_note=False, + ) + st_line = self._create_st_line(amount=1000, partner_id=False) + invoice = self.env["account.move"].create( + { + "move_type": "out_invoice", + "partner_id": self.partner_a.id, + "invoice_date": "2019-01-01", + "invoice_line_ids": [ + Command.create( + { + "product_id": self.product_a.id, + "price_unit": 100, + } + ) + ], + } + ) + invoice.action_post() + term_line = invoice.line_ids.filtered( + lambda x: x.display_type == "payment_term" + ) + invoice2 = invoice.copy() + invoice2.action_post() + term_line2 = invoice2.line_ids.filtered( + lambda x: x.display_type == "payment_term" + ) + + # No match at all. + self.assertDictEqual( + rule._apply_rules(st_line, None), + {}, + ) + + with rollback(): + # both will match because when chars are stripped they contain 1234 + term_line.name = "1a2b3c4d" + term_line2.name = "x1y2z3z4" + st_line.payment_ref = "1234" + + # matching when numerical tokens are enabled + self.assertDictEqual( + rule._apply_rules(st_line, None), + {"amls": term_line + term_line2, "model": rule}, + ) + + # not matching when numerical tokens are disabled + rule.no_numerical_tokens = True + term_line2.name = "1234" + self.assertDictEqual( + rule._apply_rules(st_line, None), + {"amls": term_line2, "model": rule}, + ) diff --git a/account_reconcile_model_no_numerical_token/views/account_reconcile_model.xml b/account_reconcile_model_no_numerical_token/views/account_reconcile_model.xml new file mode 100644 index 000000000..76f0a3404 --- /dev/null +++ b/account_reconcile_model_no_numerical_token/views/account_reconcile_model.xml @@ -0,0 +1,18 @@ + + + + account.reconcile.model.form.inherit.no.numerical.tokens + account.reconcile.model + + + + + + + + diff --git a/setup/account_reconcile_model_no_numerical_token/odoo/addons/account_reconcile_model_no_numerical_token b/setup/account_reconcile_model_no_numerical_token/odoo/addons/account_reconcile_model_no_numerical_token new file mode 120000 index 000000000..6bd7272b1 --- /dev/null +++ b/setup/account_reconcile_model_no_numerical_token/odoo/addons/account_reconcile_model_no_numerical_token @@ -0,0 +1 @@ +../../../../account_reconcile_model_no_numerical_token \ No newline at end of file diff --git a/setup/account_reconcile_model_no_numerical_token/setup.py b/setup/account_reconcile_model_no_numerical_token/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/account_reconcile_model_no_numerical_token/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)