diff --git a/hr_expense_journal/README.rst b/hr_expense_journal/README.rst new file mode 100644 index 000000000..df769de78 --- /dev/null +++ b/hr_expense_journal/README.rst @@ -0,0 +1,105 @@ +====================== +Select Expense Journal +====================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:d987377265ba11bd365fe142c94dec85cbe1191060dfffbd5c6f0cac46832b67 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_journal + :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_journal + :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| + +Employees can pay for expenses using company Credit Cards. + +In this case, there is the need for the Expense to identify what Credit +Card was used for that payment. + +This allows the Expense report to use the correct journal, and have the +payment accounting enty to be posted in the correct place. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +- Create an Expense and select "Paid By Company". +- A "Payment Type" field will be available, to select the journal + corresponding to teh credit card or payment method used. +- When creating the Expense Report, the selected Payment Type is used to + populate the "Bank Journal" field, in the "Other Setting" tab. + +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 +------- + +* Open Source Integrators + +Contributors +------------ + +- `Open Source Integrators `__: + + - Daniel Reis + - Freni Patel + +- Saran Lim. +- Panithan K. + +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-dreispt| image:: https://github.com/dreispt.png?size=40px + :target: https://github.com/dreispt + :alt: dreispt + +Current `maintainer `__: + +|maintainer-dreispt| + +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_journal/__init__.py b/hr_expense_journal/__init__.py new file mode 100644 index 000000000..bb83730e9 --- /dev/null +++ b/hr_expense_journal/__init__.py @@ -0,0 +1,4 @@ +# Copyright (C) 2021 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models diff --git a/hr_expense_journal/__manifest__.py b/hr_expense_journal/__manifest__.py new file mode 100644 index 000000000..26d5da2e1 --- /dev/null +++ b/hr_expense_journal/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright (C) 2021 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Select Expense Journal", + "version": "18.0.1.0.0", + "author": "Open Source Integrators, Odoo Community Association (OCA)", + "summary": "Set the Journal for the payment type used to pay the expense", + "website": "https://github.com/OCA/hr-expense", + "license": "AGPL-3", + "depends": ["hr_expense"], + "category": "Human Resources/Expenses", + "data": [ + "views/hr_expense_views.xml", + ], + "installable": True, + "maintainers": ["dreispt"], + "development_status": "Beta", +} diff --git a/hr_expense_journal/i18n/hr_expense_journal.pot b/hr_expense_journal/i18n/hr_expense_journal.pot new file mode 100644 index 000000000..35e4b75a5 --- /dev/null +++ b/hr_expense_journal/i18n/hr_expense_journal.pot @@ -0,0 +1,53 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_expense_journal +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.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_journal +#: model:ir.model,name:hr_expense_journal.model_hr_expense +msgid "Expense" +msgstr "" + +#. module: hr_expense_journal +#: model:ir.model.fields,field_description:hr_expense_journal.field_hr_expense__payment_method_line_id +msgid "Payment Method" +msgstr "" + +#. module: hr_expense_journal +#: model:ir.model,name:hr_expense_journal.model_account_payment_method_line +msgid "Payment Methods" +msgstr "" + +#. module: hr_expense_journal +#: model:ir.model.fields,help:hr_expense_journal.field_account_payment_method_line__journal_type +msgid "" +"Select 'Sale' for customer invoices journals.\n" +"Select 'Purchase' for vendor bills journals.\n" +"Select 'Cash' or 'Bank' for journals that are used in customer or vendor payments.\n" +"Select 'General' for miscellaneous operations journals." +msgstr "" + +#. module: hr_expense_journal +#: model:ir.model.fields,field_description:hr_expense_journal.field_hr_expense__selectable_payment_method_line_ids +msgid "Selectable Payment Method Line" +msgstr "" + +#. module: hr_expense_journal +#: model:ir.model.fields,help:hr_expense_journal.field_hr_expense__payment_method_line_id +msgid "The payment method used when the expense is paid by the company." +msgstr "" + +#. module: hr_expense_journal +#: model:ir.model.fields,field_description:hr_expense_journal.field_account_payment_method_line__journal_type +msgid "Type" +msgstr "" diff --git a/hr_expense_journal/i18n/it.po b/hr_expense_journal/i18n/it.po new file mode 100644 index 000000000..14e161aa4 --- /dev/null +++ b/hr_expense_journal/i18n/it.po @@ -0,0 +1,27 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_expense_journal +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-11-12 17:36+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_journal +#: model:ir.model,name:hr_expense_journal.model_hr_expense +msgid "Expense" +msgstr "Spesa" + +#. module: hr_expense_journal +#: model:ir.model.fields,field_description:hr_expense_journal.field_hr_expense__payment_type_id +msgid "Payment Journal" +msgstr "Registro pagamenti" diff --git a/hr_expense_journal/models/__init__.py b/hr_expense_journal/models/__init__.py new file mode 100644 index 000000000..f4ef77ecc --- /dev/null +++ b/hr_expense_journal/models/__init__.py @@ -0,0 +1,5 @@ +# Copyright (C) 2021 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import hr_expense +from . import account_payment_method_line diff --git a/hr_expense_journal/models/account_payment_method_line.py b/hr_expense_journal/models/account_payment_method_line.py new file mode 100644 index 000000000..8f07230e4 --- /dev/null +++ b/hr_expense_journal/models/account_payment_method_line.py @@ -0,0 +1,10 @@ +# Copyright (C) 2021 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class AccountPaymentMethodLine(models.Model): + _inherit = "account.payment.method.line" + + journal_type = fields.Selection(related="journal_id.type") diff --git a/hr_expense_journal/models/hr_expense.py b/hr_expense_journal/models/hr_expense.py new file mode 100644 index 000000000..65f570dcf --- /dev/null +++ b/hr_expense_journal/models/hr_expense.py @@ -0,0 +1,44 @@ +# Copyright (C) 2021 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class HrExpense(models.Model): + _inherit = "hr.expense" + + selectable_payment_method_line_ids = fields.Many2many( + comodel_name="account.payment.method.line", + compute="_compute_selectable_payment_method_line_ids", + ) + payment_method_line_id = fields.Many2one( + comodel_name="account.payment.method.line", + string="Payment Method", + domain="[('id', 'in', selectable_payment_method_line_ids)]", + help="The payment method used when the expense is paid by the company.", + ) + + @api.depends("company_id") + def _compute_selectable_payment_method_line_ids(self): + for sheet in self: + allowed_method_line_ids = ( + sheet.company_id.company_expense_allowed_payment_method_line_ids + ) + if allowed_method_line_ids: + sheet.selectable_payment_method_line_ids = allowed_method_line_ids + else: + sheet.selectable_payment_method_line_ids = self.env[ + "account.payment.method.line" + ].search( + [ + ("payment_type", "=", "outbound"), + ("company_id", "parent_of", sheet.company_id.id), + ] + ) + + def _get_default_expense_sheet_values(self): + values = super()._get_default_expense_sheet_values() + if self.payment_method_line_id: + for val in values: + val["payment_method_line_id"] = self.payment_method_line_id.id + return values diff --git a/hr_expense_journal/pyproject.toml b/hr_expense_journal/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/hr_expense_journal/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/hr_expense_journal/readme/CONTRIBUTORS.md b/hr_expense_journal/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..14b65da17 --- /dev/null +++ b/hr_expense_journal/readme/CONTRIBUTORS.md @@ -0,0 +1,5 @@ +- [Open Source Integrators](https://www.opensourceintegrators.com): + - Daniel Reis \ + - Freni Patel \ +- Saran Lim. \ +- Panithan K. \ diff --git a/hr_expense_journal/readme/DESCRIPTION.md b/hr_expense_journal/readme/DESCRIPTION.md new file mode 100644 index 000000000..73321071a --- /dev/null +++ b/hr_expense_journal/readme/DESCRIPTION.md @@ -0,0 +1,7 @@ +Employees can pay for expenses using company Credit Cards. + +In this case, there is the need for the Expense to identify what Credit +Card was used for that payment. + +This allows the Expense report to use the correct journal, and have the +payment accounting enty to be posted in the correct place. diff --git a/hr_expense_journal/readme/USAGE.md b/hr_expense_journal/readme/USAGE.md new file mode 100644 index 000000000..1411becd0 --- /dev/null +++ b/hr_expense_journal/readme/USAGE.md @@ -0,0 +1,5 @@ +- Create an Expense and select "Paid By Company". +- A "Payment Type" field will be available, to select the journal + corresponding to teh credit card or payment method used. +- When creating the Expense Report, the selected Payment Type is used to + populate the "Bank Journal" field, in the "Other Setting" tab. diff --git a/hr_expense_journal/static/description/icon.png b/hr_expense_journal/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/hr_expense_journal/static/description/icon.png differ diff --git a/hr_expense_journal/static/description/index.html b/hr_expense_journal/static/description/index.html new file mode 100644 index 000000000..b091e69b7 --- /dev/null +++ b/hr_expense_journal/static/description/index.html @@ -0,0 +1,446 @@ + + + + + +Select Expense Journal + + + +
+

Select Expense Journal

+ + +

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

+

Employees can pay for expenses using company Credit Cards.

+

In this case, there is the need for the Expense to identify what Credit +Card was used for that payment.

+

This allows the Expense report to use the correct journal, and have the +payment accounting enty to be posted in the correct place.

+

Table of contents

+ +
+

Usage

+
    +
  • Create an Expense and select “Paid By Company”.
  • +
  • A “Payment Type” field will be available, to select the journal +corresponding to teh credit card or payment method used.
  • +
  • When creating the Expense Report, the selected Payment Type is used to +populate the “Bank Journal” field, in the “Other Setting” tab.
  • +
+
+
+

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

+
    +
  • Open Source Integrators
  • +
+
+ +
+

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:

+

dreispt

+

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_journal/tests/__init__.py b/hr_expense_journal/tests/__init__.py new file mode 100644 index 000000000..12c982dad --- /dev/null +++ b/hr_expense_journal/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_hr_expense_journal diff --git a/hr_expense_journal/tests/test_hr_expense_journal.py b/hr_expense_journal/tests/test_hr_expense_journal.py new file mode 100644 index 000000000..5c8e564ef --- /dev/null +++ b/hr_expense_journal/tests/test_hr_expense_journal.py @@ -0,0 +1,82 @@ +# Copyright 2023 Ecosoft Co., Ltd (http://ecosoft.co.th/) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +from odoo.tests import common + + +class TestHrExpenseJournal(common.TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.expense_model = cls.env["hr.expense"] + cls.journal_model = cls.env["account.journal"] + cls.payment_method_model = cls.env["account.payment.method"] + cls.payment_method_line_model = cls.env["account.payment.method.line"] + + cls.employee_admin = cls.env.ref("hr.employee_admin") + cls.company_admin = cls.employee_admin.company_id + cls.product = cls.env.ref("hr_expense.product_product_no_cost") + cls.new_journal = cls.journal_model.create( + { + "name": "New Journal", + "type": "bank", + "code": "BANK1", + } + ) + cls.new_method = cls.payment_method_model.sudo().create( + { + "name": "checks", + "code": "check_printing_expense_test", + "payment_type": "outbound", + } + ) + cls.new_payment_method_line = cls.payment_method_line_model.create( + { + "name": "Check", + "payment_method_id": cls.new_method.id, + "journal_id": cls.new_journal.id, + } + ) + + def test_expense_payment_method_line(self): + expense = self.expense_model.create( + [ + { + "name": "Expense Line", + "employee_id": self.employee_admin.id, + "product_id": self.product.id, + "total_amount": 10, + "payment_mode": "company_account", + "payment_method_line_id": self.new_payment_method_line.id, + }, + ] + ) + expense.action_submit_expenses() + self.assertEqual( + expense.sheet_id.payment_method_line_id.id, + expense.payment_method_line_id.id, + ) + + def test_payment_method_line_selectable_company(self): + self.company_admin.company_expense_allowed_payment_method_line_ids = ( + self.new_payment_method_line + ) + expense = self.expense_model.create( + [ + { + "name": "Expense Line", + "employee_id": self.employee_admin.id, + "product_id": self.product.id, + "total_amount": 10, + "payment_mode": "company_account", + "payment_method_line_id": self.new_payment_method_line.id, + }, + ] + ) + expense._compute_selectable_payment_method_line_ids() + selectable = expense.selectable_payment_method_line_ids + self.assertEqual( + selectable, + self.new_payment_method_line, + ) diff --git a/hr_expense_journal/views/hr_expense_views.xml b/hr_expense_journal/views/hr_expense_views.xml new file mode 100644 index 000000000..74babbe5e --- /dev/null +++ b/hr_expense_journal/views/hr_expense_views.xml @@ -0,0 +1,38 @@ + + + hr.expense + + + + + + + + + + hr.expense.sheet + + + + + + + + + [('state', '=', 'draft'), ('employee_id', '=', employee_id), ('company_id', '=', company_id), + ('payment_mode', '=?', payment_mode), + '|', ('payment_method_line_id', '=', payment_method_line_id), ('payment_method_line_id', '=', False)] + + + + +