diff --git a/hr_expense_advance_clearing_sequence/README.rst b/hr_expense_advance_clearing_sequence/README.rst new file mode 100644 index 000000000..58e49c5df --- /dev/null +++ b/hr_expense_advance_clearing_sequence/README.rst @@ -0,0 +1,112 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +==================================== +HR Expense Advance Clearing Sequence +==================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:7e0d7663c0c93b506d02b20fc60cfebc9ecb15be93fbe52286deab7bb5c3b579 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/license-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/19.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-19-0/hr-expense-19-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=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Adds a dedicated sequence for **advance** ``hr.expense`` records (those +with ``expense_type='advance'``). When an advance is created, its +``number`` field — added by ``hr_expense_sequence`` — is populated from +the ``hr.expense.advance`` sequence (prefix ``AV`` by default) instead +of the generic ``hr.expense`` sequence used for regular expenses. + +19.0 note: 18.0 keyed the sequence off the sheet-level ``advance`` flag +(sequence code ``hr.expense.sheet.advance``). The 19.0 redesign moves +the flag to per-expense ``expense_type``, so the sequence code is now +``hr.expense.advance`` and lives on ``hr.expense.create`` instead of +``hr.expense.sheet.create``. + +**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. + +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-ps-tubtim| image:: https://github.com/ps-tubtim.png?size=40px + :target: https://github.com/ps-tubtim + :alt: ps-tubtim +.. |maintainer-dnplkndll| image:: https://github.com/dnplkndll.png?size=40px + :target: https://github.com/dnplkndll + :alt: dnplkndll + +Current `maintainers `__: + +|maintainer-ps-tubtim| |maintainer-dnplkndll| + +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..40c7d5690 --- /dev/null +++ b/hr_expense_advance_clearing_sequence/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/) +# Copyright 2026 Ledo +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +{ + "name": "HR Expense Advance Clearing Sequence", + "version": "19.0.1.0.0", + "license": "AGPL-3", + "category": "Human Resources", + "author": "Ecosoft, Odoo Community Association (OCA)", + "maintainers": ["ps-tubtim", "dnplkndll"], + "website": "https://github.com/OCA/hr-expense", + "depends": ["hr_expense_sequence", "hr_expense_advance_clearing"], + "data": ["data/hr_expense_data.xml"], + "installable": True, +} 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..b7f33011b --- /dev/null +++ b/hr_expense_advance_clearing_sequence/data/hr_expense_data.xml @@ -0,0 +1,10 @@ + + + + Employee Advance sequence + hr.expense.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..5f1b3c89d --- /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 18.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..36af45d93 --- /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 diff --git a/hr_expense_advance_clearing_sequence/models/hr_expense.py b/hr_expense_advance_clearing_sequence/models/hr_expense.py new file mode 100644 index 000000000..dd3035263 --- /dev/null +++ b/hr_expense_advance_clearing_sequence/models/hr_expense.py @@ -0,0 +1,18 @@ +# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/) +# Copyright 2026 Ledo +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +from odoo import api, models + + +class HrExpense(models.Model): + _inherit = "hr.expense" + + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + if vals.get("expense_type") == "advance" and vals.get("number", "/") == "/": + vals["number"] = ( + self.env["ir.sequence"].next_by_code("hr.expense.advance") or "/" + ) + return super().create(vals_list) 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..e5c2f1d59 --- /dev/null +++ b/hr_expense_advance_clearing_sequence/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Pimolnat Suntian \<\> +- Saran Lim. \<\> 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..681def12d --- /dev/null +++ b/hr_expense_advance_clearing_sequence/readme/DESCRIPTION.md @@ -0,0 +1,11 @@ +Adds a dedicated sequence for **advance** `hr.expense` records (those +with `expense_type='advance'`). When an advance is created, its `number` +field — added by `hr_expense_sequence` — is populated from the +`hr.expense.advance` sequence (prefix `AV` by default) instead of the +generic `hr.expense` sequence used for regular expenses. + +19.0 note: 18.0 keyed the sequence off the sheet-level `advance` flag +(sequence code `hr.expense.sheet.advance`). The 19.0 redesign moves the +flag to per-expense `expense_type`, so the sequence code is now +`hr.expense.advance` and lives on `hr.expense.create` instead of +`hr.expense.sheet.create`. 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..e323718f0 --- /dev/null +++ b/hr_expense_advance_clearing_sequence/static/description/index.html @@ -0,0 +1,450 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

HR Expense Advance Clearing Sequence

+ +

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

+

Adds a dedicated sequence for advance hr.expense records (those +with expense_type='advance'). When an advance is created, its +number field — added by hr_expense_sequence — is populated from +the hr.expense.advance sequence (prefix AV by default) instead +of the generic hr.expense sequence used for regular expenses.

+

19.0 note: 18.0 keyed the sequence off the sheet-level advance flag +(sequence code hr.expense.sheet.advance). The 19.0 redesign moves +the flag to per-expense expense_type, so the sequence code is now +hr.expense.advance and lives on hr.expense.create instead of +hr.expense.sheet.create.

+

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.

+

Current maintainers:

+

ps-tubtim dnplkndll

+

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..d92d46802 --- /dev/null +++ b/hr_expense_advance_clearing_sequence/tests/test_hr_expense_advance_clearing_sequence.py @@ -0,0 +1,35 @@ +# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/) +# Copyright 2026 Ledo +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +from odoo.tests import tagged + +from odoo.addons.hr_expense_advance_clearing.tests.test_hr_expense_advance_clearing import ( # noqa: E501 + TestHrExpenseAdvanceClearing, +) + + +@tagged("-at_install", "post_install") +class TestHrExpenseAdvanceClearingSequence(TestHrExpenseAdvanceClearing): + def test_advance_gets_AV_sequence_number(self): + """Creating an advance expense fills `number` from the AV sequence.""" + advance = self._new_advance(500.0) + self.assertNotEqual(advance.number, "/") + self.assertIn("AV", advance.number) + # Second advance gets a different number. + advance2 = self._new_advance(500.0) + self.assertNotEqual(advance.number, advance2.number) + + def test_regular_expense_uses_default_sequence(self): + """A regular (non-advance) expense uses the standard hr.expense + sequence (provided by hr_expense_sequence), not the advance one.""" + regular = self.env["hr.expense"].create( + { + "name": "regular", + "employee_id": self.expense_employee.id, + "product_id": self.product_a.id, + "total_amount_currency": 100.0, + "payment_mode": "own_account", + } + ) + self.assertNotIn("AV", regular.number or "") diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 000000000..1253cf427 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,5 @@ +# DO NOT MERGE — temporary pins until upstream deps land. +# - OCA/hr-expense#353: hr_expense_sequence 19.0 MIG (A2 dep) +# - OCA/hr-expense#358: hr_expense_advance_clearing 19.0 MIG (D2 dep) +odoo-addon-hr_expense_sequence @ git+https://github.com/OCA/hr-expense.git@refs/pull/353/head#subdirectory=hr_expense_sequence +odoo-addon-hr_expense_advance_clearing @ git+https://github.com/OCA/hr-expense.git@refs/pull/358/head#subdirectory=hr_expense_advance_clearing