diff --git a/hr_expense_advance_clearing_sequence/README.rst b/hr_expense_advance_clearing_sequence/README.rst new file mode 100644 index 000000000..6491e6f9f --- /dev/null +++ b/hr_expense_advance_clearing_sequence/README.rst @@ -0,0 +1,93 @@ +==================================== +HR Expense Advance Clearing Sequence +==================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:bfb44e1f94dd5b3f2274755eae3238cdc9d7b44059d4ee5165ee90f38a2e1256 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/17.0/hr_expense_advance_clearing_sequence + :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-17-0/hr-expense-17-0-hr_expense_advance_clearing_sequence + :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=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds the possibility to define a sequence for the expense +report's reference that Employee advance. This reference is then set as +default when you create a new expense report, using the defined +sequence. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +You can change the default sequence (EXAV0001) by the one of your choice +going to *Settings > Technical > Sequences & Identifiers > Sequences*, +and editing the record Expense report sequence (Advance). + +You will only have access to that section if your section has Technical +features permission check marked. + +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 +------------ + +- Pimolnat Suntian +- Saran Lim. +- `Heliconia Solutions Pvt. Ltd. `__ + + - Bhavesh Heliconia + +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/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_advance_clearing_sequence/__init__.py b/hr_expense_advance_clearing_sequence/__init__.py new file mode 100644 index 000000000..8ebc8a7c5 --- /dev/null +++ b/hr_expense_advance_clearing_sequence/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +from . import models diff --git a/hr_expense_advance_clearing_sequence/__manifest__.py b/hr_expense_advance_clearing_sequence/__manifest__.py new file mode 100644 index 000000000..f872bb80c --- /dev/null +++ b/hr_expense_advance_clearing_sequence/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +{ + "name": "HR Expense Advance Clearing Sequence", + "version": "17.0.1.0.0", + "license": "AGPL-3", + "category": "Human Resources", + "author": "Ecosoft, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/hr-expense", + "depends": ["hr_expense_sequence", "hr_expense_advance_clearing"], + "data": ["data/hr_expense_data.xml"], + "installable": True, + "maintainer": ["ps-tubtim"], +} diff --git a/hr_expense_advance_clearing_sequence/data/hr_expense_data.xml b/hr_expense_advance_clearing_sequence/data/hr_expense_data.xml new file mode 100644 index 000000000..6f93de1e9 --- /dev/null +++ b/hr_expense_advance_clearing_sequence/data/hr_expense_data.xml @@ -0,0 +1,9 @@ + + + + Expense report sequence (Advance) + hr.expense.sheet.advance + + AV + + diff --git a/hr_expense_advance_clearing_sequence/i18n/hr_expense_advance_clearing_sequence.pot b/hr_expense_advance_clearing_sequence/i18n/hr_expense_advance_clearing_sequence.pot new file mode 100644 index 000000000..2e08bcb70 --- /dev/null +++ b/hr_expense_advance_clearing_sequence/i18n/hr_expense_advance_clearing_sequence.pot @@ -0,0 +1,19 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_expense_advance_clearing_sequence +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.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: hr_expense_advance_clearing_sequence +#: model:ir.model,name:hr_expense_advance_clearing_sequence.model_hr_expense_sheet +msgid "Expense Report" +msgstr "" diff --git a/hr_expense_advance_clearing_sequence/i18n/it.po b/hr_expense_advance_clearing_sequence/i18n/it.po new file mode 100644 index 000000000..cfbf0117f --- /dev/null +++ b/hr_expense_advance_clearing_sequence/i18n/it.po @@ -0,0 +1,22 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_expense_advance_clearing_sequence +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-06-28 17:08+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: hr_expense_advance_clearing_sequence +#: model:ir.model,name:hr_expense_advance_clearing_sequence.model_hr_expense_sheet +msgid "Expense Report" +msgstr "Nota spese" diff --git a/hr_expense_advance_clearing_sequence/models/__init__.py b/hr_expense_advance_clearing_sequence/models/__init__.py new file mode 100644 index 000000000..38117e21e --- /dev/null +++ b/hr_expense_advance_clearing_sequence/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +from . import hr_expense_sheet diff --git a/hr_expense_advance_clearing_sequence/models/hr_expense_sheet.py b/hr_expense_advance_clearing_sequence/models/hr_expense_sheet.py new file mode 100644 index 000000000..2be1473b5 --- /dev/null +++ b/hr_expense_advance_clearing_sequence/models/hr_expense_sheet.py @@ -0,0 +1,20 @@ +# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +from odoo import api, models + + +class HrExpenseSheet(models.Model): + _inherit = "hr.expense.sheet" + + @api.model_create_multi + def create(self, vals_list): + default_advance = self.env.context.get("default_advance") + for vals in vals_list: + if vals.get("advance") or default_advance: + number = ( + self.env["ir.sequence"].next_by_code("hr.expense.sheet.advance") + or "/" + ) + vals["number"] = number + return super().create(vals) diff --git a/hr_expense_advance_clearing_sequence/pyproject.toml b/hr_expense_advance_clearing_sequence/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/hr_expense_advance_clearing_sequence/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/hr_expense_advance_clearing_sequence/readme/CONFIGURE.md b/hr_expense_advance_clearing_sequence/readme/CONFIGURE.md new file mode 100644 index 000000000..6ad0f01f7 --- /dev/null +++ b/hr_expense_advance_clearing_sequence/readme/CONFIGURE.md @@ -0,0 +1,6 @@ +You can change the default sequence (EXAV0001) by the one of your choice +going to *Settings \> Technical \> Sequences & Identifiers \> +Sequences*, and editing the record Expense report sequence (Advance). + +You will only have access to that section if your section has Technical +features permission check marked. diff --git a/hr_expense_advance_clearing_sequence/readme/CONTRIBUTORS.md b/hr_expense_advance_clearing_sequence/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..454301e66 --- /dev/null +++ b/hr_expense_advance_clearing_sequence/readme/CONTRIBUTORS.md @@ -0,0 +1,5 @@ +- Pimolnat Suntian \<\> +- Saran Lim. \<\> +- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io) + - Bhavesh Heliconia + diff --git a/hr_expense_advance_clearing_sequence/readme/DESCRIPTION.md b/hr_expense_advance_clearing_sequence/readme/DESCRIPTION.md new file mode 100644 index 000000000..9e1458424 --- /dev/null +++ b/hr_expense_advance_clearing_sequence/readme/DESCRIPTION.md @@ -0,0 +1,4 @@ +This module adds the possibility to define a sequence for the expense +report's reference that Employee advance. This reference is then set as +default when you create a new expense report, using the defined +sequence. diff --git a/hr_expense_advance_clearing_sequence/static/description/icon.png b/hr_expense_advance_clearing_sequence/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/hr_expense_advance_clearing_sequence/static/description/icon.png differ diff --git a/hr_expense_advance_clearing_sequence/static/description/index.html b/hr_expense_advance_clearing_sequence/static/description/index.html new file mode 100644 index 000000000..964fa1a00 --- /dev/null +++ b/hr_expense_advance_clearing_sequence/static/description/index.html @@ -0,0 +1,440 @@ + + + + + +HR Expense Advance Clearing Sequence + + + +
+

HR Expense Advance Clearing Sequence

+ + +

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

+

This module adds the possibility to define a sequence for the expense +report’s reference that Employee advance. This reference is then set as +default when you create a new expense report, using the defined +sequence.

+

Table of contents

+ +
+

Configuration

+

You can change the default sequence (EXAV0001) by the one of your choice +going to Settings > Technical > Sequences & Identifiers > Sequences, +and editing the record Expense report sequence (Advance).

+

You will only have access to that section if your section has Technical +features permission check marked.

+
+
+

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.

+

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_advance_clearing_sequence/tests/__init__.py b/hr_expense_advance_clearing_sequence/tests/__init__.py new file mode 100644 index 000000000..7cb5c3276 --- /dev/null +++ b/hr_expense_advance_clearing_sequence/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +from . import test_hr_expense_advance_clearing_sequence diff --git a/hr_expense_advance_clearing_sequence/tests/test_hr_expense_advance_clearing_sequence.py b/hr_expense_advance_clearing_sequence/tests/test_hr_expense_advance_clearing_sequence.py new file mode 100644 index 000000000..daf7ffd62 --- /dev/null +++ b/hr_expense_advance_clearing_sequence/tests/test_hr_expense_advance_clearing_sequence.py @@ -0,0 +1,102 @@ +# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +from odoo import Command + +from odoo.addons.base.tests.common import BaseCommon + + +class TestHrExpenseAdvanceClearingSequence(BaseCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.expense_model = cls.env["hr.expense"] + cls.expense_sheet_model = cls.env["hr.expense.sheet"] + cls.partner_1 = cls.env.ref("base.res_partner_12") + cls.employee_1 = cls.env.ref("hr.employee_hne") + account_expense = cls.env["account.account"].create( + { + "code": "NC1113", + "name": "HR Expense - Test Purchase Account", + "account_type": "expense", + } + ) + cls.emp_advance = cls.env.ref("hr_expense_advance_clearing.product_emp_advance") + cls.emp_advance.property_account_expense_id = account_expense + cls.expense = cls._create_expense( + cls, "Advance 1,000", cls.employee_1, cls.emp_advance, 1000.0, advance=True + ) + + cls.sheet = cls._create_expense_sheet( + cls, "Advance 1,000", cls.employee_1, cls.emp_advance, 1000.0, advance=True + ) + + def _create_expense( + self, + description, + employee, + product, + amount, + advance=False, + payment_mode="own_account", + ): + expense = ( + self.env["hr.expense"] + .with_context(default_advance=advance) + .create( + { + "name": description, + "employee_id": employee.id, + "product_id": product.id, + "quantity": 1.0, + "price_unit": amount, + "payment_mode": payment_mode, + } + ) + ) + expense.tax_ids = False # Test no vat + return expense + + def _create_expense_sheet( + self, description, employee, product, amount, advance=False + ): + expense = self._create_expense( + self, description, employee, product, amount, advance + ) + # Add expense to expense sheet + expense_sheet = self.expense_sheet_model.create( + { + "name": description, + "advance": advance, + "employee_id": expense.employee_id.id, + "expense_line_ids": [(6, 0, [expense.id])], + } + ) + return expense_sheet + + def test_01_create_sequence_from_expense(self): + # Test number != '/' + advance_sheet = self.expense_sheet_model.create( + { + "name": "Advance 1,000", + "advance": True, + "employee_id": self.expense.employee_id.id, + "expense_line_ids": [Command.link(self.expense.id)], + } + ) + self.assertNotEqual(advance_sheet.number, "/", "Number create") + self.assertNotEqual(advance_sheet.number.find("AV"), -1) + # Test number 1 != number 2 + self.assertNotEqual( + advance_sheet.number, advance_sheet.copy().number, "Numbers are different" + ) + + def test_02_create_sequence_from_report(self): + # Test number != '/' + self.assertNotEqual(self.sheet.number, "/", "Number create") + self.assertNotEqual(self.sheet.number.find("AV"), -1) + # Test number 1 != number 2 + sheet_number_1 = self.sheet.number + sheet2 = self.sheet.copy() + sheet_number_2 = sheet2.number + self.assertNotEqual(sheet_number_1, sheet_number_2, "Numbers are different")