diff --git a/hr_expense_duplicate_disable/README.rst b/hr_expense_duplicate_disable/README.rst new file mode 100644 index 000000000..60563d458 --- /dev/null +++ b/hr_expense_duplicate_disable/README.rst @@ -0,0 +1,99 @@ +========================= +Expense Duplicate Disable +========================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:a9b86db180799124e6c8f8782b0d34f0e305b4cccac2468e9592f1188c893f68 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fhr--expense-lightgray.png?logo=github + :target: https://github.com/OCA/hr-expense/tree/18.0/hr_expense_duplicate_disable + :alt: OCA/hr-expense +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/hr-expense-18-0/hr-expense-18-0-hr_expense_duplicate_disable + :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/hr-expense&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to disable the duplicate expense detection in +hr.expense. + +When enabled, it will skip computing duplicate expense warnings, +improving performance for large expense datasets where duplicate +detection is not needed. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To disable the duplicate expense detection: + +#. Go to Expenses > Configuration > Settings. #. Check **Duplicate +Detection** and Save. + +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 +------- + +* Ecosoft + +Contributors +------------ + +- `Ecosoft `__: + + - Saran Lim. + +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. + +.. |maintainer-Saran440| image:: https://github.com/Saran440.png?size=40px + :target: https://github.com/Saran440 + :alt: Saran440 + +Current `maintainer `__: + +|maintainer-Saran440| + +This module is part of the `OCA/hr-expense `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/hr_expense_duplicate_disable/__init__.py b/hr_expense_duplicate_disable/__init__.py new file mode 100644 index 000000000..69f7babdf --- /dev/null +++ b/hr_expense_duplicate_disable/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models diff --git a/hr_expense_duplicate_disable/__manifest__.py b/hr_expense_duplicate_disable/__manifest__.py new file mode 100644 index 000000000..c83d1de72 --- /dev/null +++ b/hr_expense_duplicate_disable/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2026 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Expense Duplicate Disable", + "summary": "Allow to disable duplicate expense detection", + "version": "18.0.1.0.0", + "category": "Human Resources", + "author": "Ecosoft, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/hr-expense", + "depends": ["hr_expense"], + "license": "AGPL-3", + "data": [ + "views/res_config_settings_view.xml", + ], + "installable": True, + "maintainers": ["Saran440"], +} diff --git a/hr_expense_duplicate_disable/models/__init__.py b/hr_expense_duplicate_disable/models/__init__.py new file mode 100644 index 000000000..40e8502cb --- /dev/null +++ b/hr_expense_duplicate_disable/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import res_config_settings +from . import hr_expense diff --git a/hr_expense_duplicate_disable/models/hr_expense.py b/hr_expense_duplicate_disable/models/hr_expense.py new file mode 100644 index 000000000..25a366646 --- /dev/null +++ b/hr_expense_duplicate_disable/models/hr_expense.py @@ -0,0 +1,19 @@ +# Copyright 2026 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import Command, api, models +from odoo.tools import str2bool + + +class HrExpense(models.Model): + _inherit = "hr.expense" + + @api.depends("employee_id", "product_id", "total_amount_currency") + def _compute_duplicate_expense_ids(self): + if not str2bool( + self.env["ir.config_parameter"] + .sudo() + .get_param("hr_expense_disable_duplicate_detection", "False") + ): + return super()._compute_duplicate_expense_ids() + self.duplicate_expense_ids = [Command.clear()] diff --git a/hr_expense_duplicate_disable/models/res_config_settings.py b/hr_expense_duplicate_disable/models/res_config_settings.py new file mode 100644 index 000000000..f974287b1 --- /dev/null +++ b/hr_expense_duplicate_disable/models/res_config_settings.py @@ -0,0 +1,14 @@ +# Copyright 2026 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + hr_expense_disable_duplicate_detection = fields.Boolean( + string="Disable duplicate expense detection", + config_parameter="hr_expense_disable_duplicate_detection", + help="If enabled, the system will not warn about duplicate expenses.", + ) diff --git a/hr_expense_duplicate_disable/pyproject.toml b/hr_expense_duplicate_disable/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/hr_expense_duplicate_disable/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/hr_expense_duplicate_disable/readme/CONFIGURE.md b/hr_expense_duplicate_disable/readme/CONFIGURE.md new file mode 100644 index 000000000..66a7eea0f --- /dev/null +++ b/hr_expense_duplicate_disable/readme/CONFIGURE.md @@ -0,0 +1,4 @@ +To disable the duplicate expense detection: + +#. Go to Expenses > Configuration > Settings. +#. Check **Duplicate Detection** and Save. diff --git a/hr_expense_duplicate_disable/readme/CONTRIBUTORS.md b/hr_expense_duplicate_disable/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..4e962847f --- /dev/null +++ b/hr_expense_duplicate_disable/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- [Ecosoft](): + - Saran Lim. \<\> diff --git a/hr_expense_duplicate_disable/readme/DESCRIPTION.md b/hr_expense_duplicate_disable/readme/DESCRIPTION.md new file mode 100644 index 000000000..123cb7c56 --- /dev/null +++ b/hr_expense_duplicate_disable/readme/DESCRIPTION.md @@ -0,0 +1,4 @@ +This module allows to disable the duplicate expense detection in hr.expense. + +When enabled, it will skip computing duplicate expense warnings, improving performance +for large expense datasets where duplicate detection is not needed. diff --git a/hr_expense_duplicate_disable/static/description/icon.png b/hr_expense_duplicate_disable/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/hr_expense_duplicate_disable/static/description/icon.png differ diff --git a/hr_expense_duplicate_disable/static/description/index.html b/hr_expense_duplicate_disable/static/description/index.html new file mode 100644 index 000000000..5869ba66a --- /dev/null +++ b/hr_expense_duplicate_disable/static/description/index.html @@ -0,0 +1,439 @@ + + + + + +Expense Duplicate Disable + + + +
+

Expense Duplicate Disable

+ + +

Beta License: AGPL-3 OCA/hr-expense Translate me on Weblate Try me on Runboat

+

This module allows to disable the duplicate expense detection in +hr.expense.

+

When enabled, it will skip computing duplicate expense warnings, +improving performance for large expense datasets where duplicate +detection is not needed.

+

Table of contents

+ +
+

Configuration

+

To disable the duplicate expense detection:

+

#. Go to Expenses > Configuration > Settings. #. Check Duplicate +Detection and Save.

+
+
+

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

+
    +
  • Ecosoft
  • +
+
+
+

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.

+

Current maintainer:

+

Saran440

+

This module is part of the OCA/hr-expense project on GitHub.

+

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

+
+
+
+ + diff --git a/hr_expense_duplicate_disable/tests/__init__.py b/hr_expense_duplicate_disable/tests/__init__.py new file mode 100644 index 000000000..58a764e14 --- /dev/null +++ b/hr_expense_duplicate_disable/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_duplicate_disable diff --git a/hr_expense_duplicate_disable/tests/test_duplicate_disable.py b/hr_expense_duplicate_disable/tests/test_duplicate_disable.py new file mode 100644 index 000000000..987068488 --- /dev/null +++ b/hr_expense_duplicate_disable/tests/test_duplicate_disable.py @@ -0,0 +1,56 @@ +# Copyright 2026 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests import TransactionCase + + +class TestDuplicateDisable(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context={"tracking_disable": True}) + cls.Employee = cls.env["hr.employee"] + cls.Product = cls.env["product.product"] + cls.Expense = cls.env["hr.expense"] + # Create employee + cls.employee = cls.Employee.create({"name": "Test Employee"}) + # Create product + cls.product = cls.Product.create({"name": "Test Product", "type": "service"}) + + def _create_expense(self, employee, product, amount): + return self.Expense.create( + { + "employee_id": employee.id, + "product_id": product.id, + "total_amount_currency": amount, + "name": "Test Expense", + } + ) + + def test_01_duplicate_detected_when_enabled(self): + """When duplicate detection is disable, duplicates should be found.""" + self.env["ir.config_parameter"].sudo().set_param( + "hr_expense_disable_duplicate_detection", "False" + ) + exp1 = self._create_expense(self.employee, self.product, 100.0) + exp2 = self._create_expense(self.employee, self.product, 100.0) + exp1._compute_duplicate_expense_ids() + exp2._compute_duplicate_expense_ids() + self.assertTrue( + exp2.duplicate_expense_ids, + "Duplicates should be detected when detection is enabled", + ) + + def test_02_duplicate_not_detected_when_disabled(self): + """When duplicate detection is disabled, no duplicates should be found.""" + self.env["ir.config_parameter"].sudo().set_param( + "hr_expense_disable_duplicate_detection", "True" + ) + exp1 = self._create_expense(self.employee, self.product, 100.0) + exp2 = self._create_expense(self.employee, self.product, 100.0) + exp1._compute_duplicate_expense_ids() + exp2._compute_duplicate_expense_ids() + self.assertFalse( + exp2.duplicate_expense_ids, + "Duplicates should NOT be detected when detection is disabled", + ) diff --git a/hr_expense_duplicate_disable/views/res_config_settings_view.xml b/hr_expense_duplicate_disable/views/res_config_settings_view.xml new file mode 100644 index 000000000..bb2da48ad --- /dev/null +++ b/hr_expense_duplicate_disable/views/res_config_settings_view.xml @@ -0,0 +1,23 @@ + + + res.config.settings.view.form.inherit.hr.expense.duplicate + res.config.settings + + + + + + + + + + +