diff --git a/hr_expense_payment_term/README.rst b/hr_expense_payment_term/README.rst new file mode 100644 index 000000000..9bce758cc --- /dev/null +++ b/hr_expense_payment_term/README.rst @@ -0,0 +1,91 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +======================= +HR Expense Payment Term +======================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:0207814f6e1c7d1a21101035941f41d66e9778250f1eaae02202e02e155dce81 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/16.0/hr_expense_payment_term + :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-16-0/hr-expense-16-0-hr_expense_payment_term + :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=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows selecting payment terms on expense sheets and transfers +them to the generated accounting move. + +**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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Escodoo + +Contributors +~~~~~~~~~~~~ + +* `Escodoo `_: + + * Wesley Oliveira + +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-WesleyOliveira98| image:: https://github.com/WesleyOliveira98.png?size=40px + :target: https://github.com/WesleyOliveira98 + :alt: WesleyOliveira98 + +Current `maintainer `__: + +|maintainer-WesleyOliveira98| + +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_payment_term/__init__.py b/hr_expense_payment_term/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/hr_expense_payment_term/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/hr_expense_payment_term/__manifest__.py b/hr_expense_payment_term/__manifest__.py new file mode 100644 index 000000000..0de0db152 --- /dev/null +++ b/hr_expense_payment_term/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2026 - TODAY, Wesley Oliveira +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + + +{ + "name": "HR Expense Payment Term", + "version": "16.0.1.0.0", + "category": "Human Resources/Expenses", + "summary": "Set payment terms on expense sheets and their accounting moves", + "author": "Escodoo, Odoo Community Association (OCA)", + "license": "AGPL-3", + "website": "https://github.com/OCA/hr-expense", + "depends": ["hr_expense"], + "data": [ + "views/hr_expense_sheet_views.xml", + ], + "installable": True, + "maintainers": ["WesleyOliveira98"], +} diff --git a/hr_expense_payment_term/models/__init__.py b/hr_expense_payment_term/models/__init__.py new file mode 100644 index 000000000..02264fd7e --- /dev/null +++ b/hr_expense_payment_term/models/__init__.py @@ -0,0 +1 @@ +from . import hr_expense_sheet diff --git a/hr_expense_payment_term/models/hr_expense_sheet.py b/hr_expense_payment_term/models/hr_expense_sheet.py new file mode 100644 index 000000000..46ac6ab3e --- /dev/null +++ b/hr_expense_payment_term/models/hr_expense_sheet.py @@ -0,0 +1,23 @@ +# Copyright 2026 - TODAY, Wesley Oliveira +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class HrExpenseSheet(models.Model): + _inherit = "hr.expense.sheet" + + payment_term_id = fields.Many2one( + comodel_name="account.payment.term", + string="Payment Terms", + check_company=True, + ) + invoice_date_due = fields.Date(string="Due Date") + + def _prepare_bill_vals(self): + vals = super()._prepare_bill_vals() + if self.payment_term_id: + vals["invoice_payment_term_id"] = self.payment_term_id.id + elif self.invoice_date_due: + vals["invoice_date_due"] = self.invoice_date_due + return vals diff --git a/hr_expense_payment_term/readme/CONTRIBUTORS.rst b/hr_expense_payment_term/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..2f9bd6d02 --- /dev/null +++ b/hr_expense_payment_term/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Escodoo `_: + + * Wesley Oliveira diff --git a/hr_expense_payment_term/readme/DESCRIPTION.rst b/hr_expense_payment_term/readme/DESCRIPTION.rst new file mode 100644 index 000000000..b1d6b3442 --- /dev/null +++ b/hr_expense_payment_term/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module allows selecting payment terms on expense sheets and transfers +them to the generated accounting move. diff --git a/hr_expense_payment_term/static/description/icon.png b/hr_expense_payment_term/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/hr_expense_payment_term/static/description/icon.png differ diff --git a/hr_expense_payment_term/static/description/index.html b/hr_expense_payment_term/static/description/index.html new file mode 100644 index 000000000..dfe8d0199 --- /dev/null +++ b/hr_expense_payment_term/static/description/index.html @@ -0,0 +1,435 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

HR Expense Payment Term

+ +

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

+

This module allows selecting payment terms on expense sheets and transfers +them to the generated accounting move.

+

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 to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Escodoo
  • +
+
+
+

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:

+

WesleyOliveira98

+

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_payment_term/tests/__init__.py b/hr_expense_payment_term/tests/__init__.py new file mode 100644 index 000000000..8e38fa4a8 --- /dev/null +++ b/hr_expense_payment_term/tests/__init__.py @@ -0,0 +1 @@ +from . import test_hr_expense_payment_term diff --git a/hr_expense_payment_term/tests/test_hr_expense_payment_term.py b/hr_expense_payment_term/tests/test_hr_expense_payment_term.py new file mode 100644 index 000000000..38f33a5c2 --- /dev/null +++ b/hr_expense_payment_term/tests/test_hr_expense_payment_term.py @@ -0,0 +1,59 @@ +# Copyright 2026 - TODAY, Wesley Oliveira +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields +from odoo.tests import Form, tagged + +from odoo.addons.hr_expense.tests.common import TestExpenseCommon + + +@tagged("-at_install", "post_install") +class TestHrExpensePaymentTerm(TestExpenseCommon): + @classmethod + def setUpClass(cls, chart_template_ref=None): + super().setUpClass(chart_template_ref=chart_template_ref) + + cls.payment_term = cls.env.ref("account.account_payment_term_30days") + + expense_form = Form( + cls.env["hr.expense"].with_context( + default_product_id=cls.product_a.id, + default_employee_id=cls.expense_employee.id, + ) + ) + expense_form.name = "Expense with payment term" + cls.expense = expense_form.save() + res = cls.expense.action_submit_expenses() + sheet_form = Form(cls.env[res["res_model"]].with_context(**res["context"])) + cls.expense_sheet_1 = sheet_form.save() + cls.expense_sheet_1.payment_term_id = cls.payment_term + cls.expense_sheet_1.approve_expense_sheets() + + expense_form_2 = Form( + cls.env["hr.expense"].with_context( + default_product_id=cls.product_a.id, + default_employee_id=cls.expense_employee.id, + ) + ) + expense_form_2.name = "Expense with date due" + cls.expense_2 = expense_form_2.save() + res = cls.expense_2.action_submit_expenses() + sheet_form = Form(cls.env[res["res_model"]].with_context(**res["context"])) + cls.expense_sheet_2 = sheet_form.save() + cls.expense_sheet_2.invoice_date_due = fields.Date.today() + cls.expense_sheet_2._do_approve() + + def test_payment_term_is_propagated_to_expense_move(self): + self.expense_sheet_1.action_sheet_move_create() + self.assertEqual( + self.expense_sheet_1.account_move_id.invoice_payment_term_id, + self.payment_term, + ) + + def test_invoice_date_due_is_propagated_to_expense_move(self): + self.expense_sheet_2.action_sheet_move_create() + self.assertFalse(self.expense_sheet_2.account_move_id.invoice_payment_term_id) + self.assertEqual( + self.expense_sheet_2.account_move_id.invoice_date_due, + fields.Date.today(), + ) diff --git a/hr_expense_payment_term/views/hr_expense_sheet_views.xml b/hr_expense_payment_term/views/hr_expense_sheet_views.xml new file mode 100644 index 000000000..8f98ae89e --- /dev/null +++ b/hr_expense_payment_term/views/hr_expense_sheet_views.xml @@ -0,0 +1,47 @@ + + + hr.expense.sheet.form.inherit.payment.term + hr.expense.sheet + + + +
+
+
+ + or + +
+
+
+
+
diff --git a/setup/hr_expense_payment_term/odoo/addons/hr_expense_payment_term b/setup/hr_expense_payment_term/odoo/addons/hr_expense_payment_term new file mode 120000 index 000000000..f0a990a14 --- /dev/null +++ b/setup/hr_expense_payment_term/odoo/addons/hr_expense_payment_term @@ -0,0 +1 @@ +../../../../hr_expense_payment_term \ No newline at end of file diff --git a/setup/hr_expense_payment_term/setup.py b/setup/hr_expense_payment_term/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/hr_expense_payment_term/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)