Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.0][MIG] hr_expense_payment: Migration to 18.0 #280

Merged
merged 26 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
958f048
[14.0][ADD] hr_expense_payment
Saran440 Jul 27, 2021
1fb90c1
[ENH] hr_expense_cancel depend on hr_expense_payment
Saran440 Jul 27, 2021
3117aaf
[UPD] Update hr_expense_payment.pot
oca-travis Mar 5, 2022
8af8d1d
[UPD] README.rst
OCA-git-bot Mar 5, 2022
58e36ee
[IMP] update dotfiles [ci skip]
OCA-git-bot Mar 30, 2022
288a719
[MIG]hr_expense_payment: Migration to 15.0
manuelregidor Apr 25, 2022
e209ca1
[UPD] Update hr_expense_payment.pot
Apr 26, 2022
cb26762
[UPD] README.rst
OCA-git-bot Apr 26, 2022
caf1f0b
[MIG] hr_expense_payment: Migration to 16.0
AungKoKoLin1997 Nov 24, 2022
956f61c
[UPD] Update hr_expense_payment.pot
Jun 19, 2023
dac1f33
[UPD] README.rst
OCA-git-bot Jun 19, 2023
e242daf
Added translation using Weblate (Italian)
mymage Jun 28, 2023
4aee4df
Translated using Weblate (Italian)
mymage Jun 28, 2023
7069276
[UPD] README.rst
OCA-git-bot Sep 3, 2023
c797712
[FIX] no create payments with paid by company
Saran440 May 19, 2022
cd2e59b
[UPD] Update hr_expense_payment.pot
Nov 30, 2023
0cf4e03
[BOT] post-merge updates
OCA-git-bot Nov 30, 2023
57cb790
Update translation files
weblate Nov 30, 2023
c71a6fa
[IMP] hr_expense_payment: pre-commit auto fixes
peluko00 Apr 4, 2024
69560c7
[MIG] hr_expense_payment: Migration to 17.0
peluko00 Apr 4, 2024
02e018f
[UPD] Update hr_expense_payment.pot
May 24, 2024
c9932e4
[BOT] post-merge updates
OCA-git-bot May 24, 2024
8692a69
[FIX] hr_expense_payment: Fix + improve tests
victoralmau Nov 27, 2024
72ceb08
[BOT] post-merge updates
OCA-git-bot Nov 27, 2024
6660847
[MIG] hr_expense_payment: Migration to 18.0
lef-adhoc Dec 4, 2024
a82dace
[IMP] hr_expense_payment: Optimize _create_payment_vals_from_batch me…
lef-adhoc Jan 2, 2025
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
Next Next commit
[14.0][ADD] hr_expense_payment
  • Loading branch information
Saran440 authored and lef-adhoc committed Dec 4, 2024
commit 958f0483ef96ca924c91b21cebf2ebf21180f179
82 changes: 82 additions & 0 deletions hr_expense_payment/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
==================
HR Expense Payment
==================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/14.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-14-0/hr-expense-14-0-hr_expense_payment
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/289/14.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allow payment link to expense.
After you register payment on expense sheet, it will link between expense sheet and payment.

**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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/hr-expense/issues/new?body=module:%20hr_expense_payment%0Aversion:%2014.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
~~~~~~~

* Ecosoft

Contributors
~~~~~~~~~~~~

* Saran Lim. <[email protected]>

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-Saran440| image:: https://github.com/Saran440.png?size=40px
:target: https://github.com/Saran440
:alt: Saran440

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-Saran440|

This module is part of the `OCA/hr-expense <https://github.com/OCA/hr-expense/tree/14.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 (http://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 (http://www.gnu.org/licenses/agpl).

{
"name": "HR Expense Payment",
"version": "14.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 (http://www.gnu.org/licenses/agpl.html).

from odoo import SUPERUSER_ID, api


def post_init_hook(cr, registry):
""" Trying to fill the source expense sheet in payments """
with api.Environment.manage():
env = api.Environment(cr, SUPERUSER_ID, {})
sheets = env["hr.expense.sheet"].search([("payment_mode", "=", "own_account")])
for sheet in sheets:
amls = sheet.account_move_id.mapped("line_ids")
reconcile = amls.mapped("full_reconcile_id")
aml_payment = reconcile.mapped("reconciled_line_ids").filtered(
lambda r: r not in amls
)
payment = aml_payment.mapped("payment_id")
payment.write({"expense_sheet_ids": sheet.ids})
5 changes: 5 additions & 0 deletions hr_expense_payment/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import account_payment
from . import hr_expense
from . import hr_expense_sheet
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_sheet_ids = fields.Many2many(
comodel_name="hr.expense.sheet",
relation="payment_expense_sheet_rel",
column1="payment_id",
column2="sheet_id",
string="Expense sheet",
readonly=True,
copy=False,
)
63 changes: 63 additions & 0 deletions hr_expense_payment/models/hr_expense.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright 2019 Tecnativa - Ernesto Tejeda
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import models


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

def _prepare_payment_expense_company(
self,
payment_methods,
journal,
different_currency,
journal_currency,
total_amount_currency,
):
self.ensure_one()
commercial_partner_id = (
self.employee_id.sudo().address_home_id.commercial_partner_id
)
payment_dict = {
"date": self.date,
"amount": total_amount_currency,
"payment_type": "outbound",
"partner_type": "supplier",
"ref": self.name,
"journal_id": journal.id,
"currency_id": self.currency_id.id
if different_currency
else journal_currency.id,
"partner_id": commercial_partner_id.id,
"payment_method_id": payment_methods and payment_methods[0].id or False,
"expense_sheet_ids": self.sheet_id.ids,
}
return payment_dict

def action_move_create(self):
move_group_by_sheet = super().action_move_create()
payment_list = []
for expense in self:
if expense.payment_mode == "company_account":
total_amount_currency = expense.total_amount
different_currency = (
expense.currency_id != expense.company_id.currency_id
)
journal = expense.sheet_id.bank_journal_id
journal_currency = journal.currency_id or journal.company_id.currency_id
payment_methods = journal.outbound_payment_method_ids
# prepare payment dict value for case paid by company
payment_dict = expense._prepare_payment_expense_company(
payment_methods,
journal,
different_currency,
journal_currency,
total_amount_currency,
)
payment_list.append(payment_dict)
# create payment and auto post from expense paid by company
if payment_list:
payment = self.env["account.payment"].create(payment_list)
payment.action_post()
return move_group_by_sheet
26 changes: 26 additions & 0 deletions hr_expense_payment/models/hr_expense_sheet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2019 Tecnativa - Ernesto Tejeda
# Copyright 2021 Ecosoft Co., Ltd (http://ecosoft.co.th/)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


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

payment_ids = fields.Many2many(
comodel_name="account.payment",
relation="payment_expense_sheet_rel",
column1="sheet_id",
column2="payment_id",
string="Payment",
readonly=True,
copy=False,
)

def action_register_payment(self):
""" Send context when you register payment from expense sheet """
action = super().action_register_payment()
if self._name == "hr.expense.sheet":
action["context"].update({"expense_sheet_ids": self.ids})
return action
1 change: 1 addition & 0 deletions hr_expense_payment/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Saran Lim. <[email protected]>
2 changes: 2 additions & 0 deletions hr_expense_payment/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module allow payment link to expense.
After you register payment on expense sheet, it will link between expense sheet and payment.
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