Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions hr_expense_payment/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
.. 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
==================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:5517c634f0be5269334c9330a559431ffb4ee03d0b2a1b7fcf65c70a1976ef95
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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_payment
: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_payment
: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|

This module links each employee expense to the payment(s) that settled
it. When you Register Payment on a posted employee-paid expense, the
resulting payment back-links to the source expense, and vice versa. A
post-install hook backfills the link for payments made before the module
was installed.

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/hr-expense/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 <https://github.com/OCA/hr-expense/issues/new?body=module:%20hr_expense_payment%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
-------

* Tecnativa
* Ecosoft

Contributors
------------

- Saran Lim. <saranl@ecosoft.co.th>
- Manuel Regidor <manuel.regidor@sygel.es>
- ``APSL <https://apsl.tech>``\ \_\_:

- Antoni Marroig <amarroig@apsl.net>

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 <https://github.com/OCA/hr-expense/tree/19.0/hr_expense_payment>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
5 changes: 5 additions & 0 deletions hr_expense_payment/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
from . import wizard
from .hooks import post_init_hook
16 changes: 16 additions & 0 deletions hr_expense_payment/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2019 Tecnativa - Ernesto Tejeda
# Copyright 2021 Ecosoft Co., Ltd (http://ecosoft.co.th/)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "HR Expense Payment",
"version": "19.0.1.0.0",
"category": "Human Resources",
"author": "Tecnativa, Ecosoft, Odoo Community Association (OCA)",
"license": "AGPL-3",
"website": "https://github.com/OCA/hr-expense",
"depends": ["hr_expense"],
"data": [],
"installable": True,
"post_init_hook": "post_init_hook",
}
19 changes: 19 additions & 0 deletions hr_expense_payment/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2019 Tecnativa - Ernesto Tejeda
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).


def post_init_hook(env):
"""Backfill payment_ids on expenses paid before the module was installed,
via the expense move's reconciliation."""
expenses = env["hr.expense"].search(
[("payment_mode", "=", "own_account"), ("account_move_id", "!=", False)]
)
for expense in expenses:
amls = expense.account_move_id.line_ids
reconcile = amls.mapped("full_reconcile_id")
aml_payment = reconcile.mapped("reconciled_line_ids").filtered(
lambda r, amls=amls: r not in amls
)
payment = aml_payment.mapped("payment_id")
if payment:
payment.write({"expense_ids": [(4, expense.id)]})
39 changes: 39 additions & 0 deletions hr_expense_payment/i18n/hr_expense_payment.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_expense_payment
#
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_payment
#: model:ir.model,name:hr_expense_payment.model_hr_expense_sheet
msgid "Expense Report"
msgstr ""

#. module: hr_expense_payment
#: model:ir.model.fields,field_description:hr_expense_payment.field_account_payment__expense_sheet_ids
msgid "Expense sheet"
msgstr ""

#. module: hr_expense_payment
#: model:ir.model,name:hr_expense_payment.model_account_payment_register
msgid "Pay"
msgstr ""

#. module: hr_expense_payment
#: model:ir.model.fields,field_description:hr_expense_payment.field_hr_expense_sheet__payment_ids
msgid "Payment"
msgstr ""

#. module: hr_expense_payment
#: model:ir.model,name:hr_expense_payment.model_account_payment
msgid "Payments"
msgstr ""
48 changes: 48 additions & 0 deletions hr_expense_payment/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_expense_payment
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2025-01-09 11:06+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\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 5.6.2\n"

#. module: hr_expense_payment
#: model:ir.model,name:hr_expense_payment.model_hr_expense_sheet
msgid "Expense Report"
msgstr "Nota spese"

#. module: hr_expense_payment
#: model:ir.model.fields,field_description:hr_expense_payment.field_account_payment__expense_sheet_ids
msgid "Expense sheet"
msgstr "Foglio spesa"

#. module: hr_expense_payment
#: model:ir.model,name:hr_expense_payment.model_account_payment_register
msgid "Pay"
msgstr "Paga"

#. module: hr_expense_payment
#: model:ir.model.fields,field_description:hr_expense_payment.field_hr_expense_sheet__payment_ids
msgid "Payment"
msgstr "Pagamento"

#. module: hr_expense_payment
#: model:ir.model,name:hr_expense_payment.model_account_payment
msgid "Payments"
msgstr "Pagamenti"

#~ msgid "Register Payment"
#~ msgstr "Registra pagamento"

#~ msgid "Expense"
#~ msgstr "Spesa"
4 changes: 4 additions & 0 deletions hr_expense_payment/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import account_payment
from . import hr_expense
19 changes: 19 additions & 0 deletions hr_expense_payment/models/account_payment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2019 Tecnativa - Ernesto Tejeda
# Copyright 2021 Ecosoft Co., Ltd (http://ecosoft.co.th/)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class AccountPayment(models.Model):
_inherit = "account.payment"

expense_ids = fields.Many2many(
comodel_name="hr.expense",
relation="payment_hr_expense_rel",
column1="payment_id",
column2="expense_id",
string="Expenses",
readonly=True,
copy=False,
)
29 changes: 29 additions & 0 deletions hr_expense_payment/models/hr_expense.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2019 Tecnativa - Ernesto Tejeda
# Copyright 2021 Ecosoft Co., Ltd (http://ecosoft.co.th/)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class HrExpense(models.Model):
_inherit = "hr.expense"

payment_ids = fields.Many2many(
comodel_name="account.payment",
relation="payment_hr_expense_rel",
column1="expense_id",
column2="payment_id",
string="Payments",
readonly=True,
copy=False,
)

def action_pay(self):
"""Pass the expense ids to the payment wizard so created payments
back-link here."""
action = super().action_pay()
if action and isinstance(action, dict):
ctx = dict(action.get("context") or {})
ctx["hr_expense_ids"] = self.ids
action["context"] = ctx
return action
3 changes: 3 additions & 0 deletions hr_expense_payment/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
4 changes: 4 additions & 0 deletions hr_expense_payment/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Saran Lim. \<<saranl@ecosoft.co.th>\>
- Manuel Regidor \<<manuel.regidor@sygel.es>\>
- `APSL <https://apsl.tech>`__:
- Antoni Marroig \<<amarroig@apsl.net>\>
4 changes: 4 additions & 0 deletions hr_expense_payment/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This module links each employee expense to the payment(s) that settled it.
When you Register Payment on a posted employee-paid expense, the resulting
payment back-links to the source expense, and vice versa. A post-install
hook backfills the link for payments made before the module was installed.
Binary file added hr_expense_payment/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading