Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
15aaf1a
hr_expense_cancel: lets to cancel and correct expenses
ernestotejeda Feb 11, 2019
de64e0c
[MIG] hr_expense_cancel: Migration to 12.0
danhvo-novobi Mar 11, 2019
b4b6f64
[FIX] hr_expense_cancel: Avoid singleton error in post_init_hook
pedrobaeza Oct 21, 2019
fd9b67b
[FIX] Avoid not intended warnings
MiquelRForgeFlow Nov 14, 2019
691c90f
[IMP] hr_expense_cancel : black, isort
Saran440 Mar 30, 2020
09448d8
[13.0][MIG] hr_expense_cancel
Saran440 Mar 30, 2020
6e17538
[14.0][MIG] hr_expense_cancel
Saran440 Oct 18, 2020
7e48022
Overwrite core function create payment
Saran440 Oct 22, 2020
56f122a
[FIX] hr_expense_cancel: Fix tests + Cancel move payments.
victoralmau Jan 17, 2022
e223654
[ENH] hr_expense_cancel depend on hr_expense_payment
Saran440 Jul 27, 2021
c015415
[MIG]hr_expense_cancel: Migration to 15.0
manuelregidor Apr 26, 2022
9cc1041
[MIG] hr_expense_cancel: Migration to 16.0
stefan-tecnativa Jun 15, 2023
1f77bf4
Added translation using Weblate (Italian)
mymage Jun 28, 2023
0286ea8
[FIX] hr_expense_cancel: Adjust test to product w/o cost behavior
Saran440 Sep 18, 2023
666ff33
[FIX] no create payments with paid by company
Saran440 May 19, 2022
b4de29d
[IMP] hr_expense_cancel: pre-commit auto fixes
imlopes May 15, 2024
904b1ec
[MIG] hr_expense_cancel: Migration to 17.0
imlopes May 15, 2024
d193be0
Translated using Weblate (Italian)
mymage Jul 31, 2024
11271a3
[FIX] hr_expense_cancel: Fix + improve tests
victoralmau Nov 27, 2024
f29521a
[MIG] hr_expense_cancel: Migration to 18.0
mav-adhoc Dec 6, 2024
21e3866
[FIX]hr_expense_cancel: submitted sheets in test
mav-adhoc Jan 29, 2025
b184e27
[FIX]hr_expense_cancel:rename of action_sheet_move_cancel into action…
mav-adhoc Jan 29, 2025
0a8eb12
[FIX]hr_expense_cancel: payment_ids.state cancel rename
mav-adhoc Jan 31, 2025
26bea99
[IMP] hr_expense_cancel: pre-commit auto fixes
dnplkndll Jun 19, 2026
45a6ab4
[MIG] hr_expense_cancel: Migration to 19.0
dnplkndll Jul 27, 2026
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
107 changes: 107 additions & 0 deletions hr_expense_cancel/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

=================
Hr expense cancel
=================

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

.. |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_cancel
: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_cancel
: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 lets you reset a posted employee expense back to draft. It
draft-cancels the linked payments and unreconciles their journal lines
before core reverses the expense's move. Reconciliations created by
related modules (such as bills from ``hr_expense_invoice``) are
cancelled in step.

**Table of contents**

.. contents::
:local:

Usage
=====

To use this module, you need to:

1. Go to *Expenses* and create a new *Expense* paid by *Employee (to
reimburse)*
2. Submit and approve it, then click on *Post Journal Entries*
3. Click on *Register Payment*, fill in the wizard and validate: the
expense's journal entry is now reconciled with a payment
4. Click on *Reset to Draft*
5. The expense goes back to *Draft*; the payment is cancelled and the
journal entry deleted

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_cancel%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

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

- `Tecnativa <https://www.tecnativa.com>`__:

- Pedro M. Baeza
- Ernesto Tejeda
- Stefan Ungureanu

- Danh Vo <https://github.com/danhvophuong>
- Saran Lim. <saranl@ecosoft.co.th>
- Manuel Regidor <manuel.regidor@sygel.es>
- Italo LOPES <italo.lopes@camptocamp.com>

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_cancel>`_ project on GitHub.

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

from . import models
14 changes: 14 additions & 0 deletions hr_expense_cancel/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2019 Tecnativa - Ernesto Tejeda
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

{
"name": "Hr expense cancel",
"version": "19.0.1.0.0",
"author": "Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/hr-expense",
"license": "AGPL-3",
"category": "Human Resources",
"depends": ["hr_expense"],
"data": [],
"installable": True,
}
37 changes: 37 additions & 0 deletions hr_expense_cancel/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_expense_cancel
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-06-02 07:12+0000\n"
"PO-Revision-Date: 2023-06-02 07:12+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: hr_expense_cancel
#: model_terms:ir.ui.view,arch_db:hr_expense_cancel.view_hr_expense_sheet_form
msgid "Cancel all related operations"
msgstr "Cancelar todas las operaciones relacionadas"

#. module: hr_expense_cancel
#: model_terms:ir.ui.view,arch_db:hr_expense_cancel.view_hr_expense_sheet_form
msgid "Cancel journal entries, payments and reconciliations"
msgstr "Cancelar asientos, pagos y conciliaciones"

#. module: hr_expense_cancel
#: model:ir.model,name:hr_expense_cancel.model_hr_expense_sheet
msgid "Expense Report"
msgstr "Informe de gastos"

#. module: hr_expense_cancel
#: model:ir.model,name:hr_expense_cancel.model_account_payment
msgid "Payments"
msgstr ""
34 changes: 34 additions & 0 deletions hr_expense_cancel/i18n/hr_expense_cancel.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_expense_cancel
#
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_cancel
#: model_terms:ir.ui.view,arch_db:hr_expense_cancel.view_hr_expense_sheet_form
msgid "Cancel all related operations"
msgstr ""

#. module: hr_expense_cancel
#: model_terms:ir.ui.view,arch_db:hr_expense_cancel.view_hr_expense_sheet_form
msgid "Cancel journal entries, payments and reconciliations"
msgstr ""

#. module: hr_expense_cancel
#: model:ir.model,name:hr_expense_cancel.model_hr_expense_sheet
msgid "Expense Report"
msgstr ""

#. module: hr_expense_cancel
#: model:ir.model,name:hr_expense_cancel.model_account_payment
msgid "Payments"
msgstr ""
37 changes: 37 additions & 0 deletions hr_expense_cancel/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_expense_cancel
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-07-31 08:58+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_cancel
#: model_terms:ir.ui.view,arch_db:hr_expense_cancel.view_hr_expense_sheet_form
msgid "Cancel all related operations"
msgstr "Annulla tutte le operazioni relative"

#. module: hr_expense_cancel
#: model_terms:ir.ui.view,arch_db:hr_expense_cancel.view_hr_expense_sheet_form
msgid "Cancel journal entries, payments and reconciliations"
msgstr "Annulla registrazioni contabili, pagamenti e riconciliazioni"

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

#. module: hr_expense_cancel
#: model:ir.model,name:hr_expense_cancel.model_account_payment
msgid "Payments"
msgstr "Pagamenti"
4 changes: 4 additions & 0 deletions hr_expense_cancel/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.html).

from . import account_payment
from . import hr_expense
12 changes: 12 additions & 0 deletions hr_expense_cancel/models/account_payment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import models


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

def action_draft_cancel(self):
for payment in self:
payment.action_draft()
payment.action_cancel()
56 changes: 56 additions & 0 deletions hr_expense_cancel/models/hr_expense.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# 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 action_reset(self):
"""Tear down linked payments and the posted move so core's reset
guard passes, then let super reset the expense. Runs with the
caller's rights, as in 18.0."""
for expense in self:
moves = expense.account_move_id
if not moves:
continue
payments = moves.reconciled_payment_ids.filtered(
lambda p: p.state != "canceled"
)
self._remove_reconcile_hr_invoice(moves)
if expense.payment_mode == "own_account":
self._remove_move_reconcile(payments, moves)
payments.action_draft_cancel()
non_draft = moves.filtered(lambda m: m.state != "draft")
if non_draft:
non_draft.button_draft()
non_draft.button_cancel()
moves.with_context(force_delete=True).unlink()
return super().action_reset()

def _remove_reconcile_hr_invoice(self, account_moves):
"""Cancel bills made by hr_expense_invoice automatically."""
exp_move_lines = self.env["account.move.line"].search(
[
(
"full_reconcile_id",
"in",
account_moves.line_ids.full_reconcile_id.ids,
),
("move_id", "not in", account_moves.ids),
]
)
if exp_move_lines:
moves = exp_move_lines.move_id
moves.button_draft()
moves.button_cancel()

def _remove_move_reconcile(self, payments, account_moves):
"""Unreconcile only the lines matched with the expense's own payments,
partial reconciliations included."""
to_unreconcile_move_lines = account_moves._get_reconciled_amls().filtered(
lambda line: line.move_id in payments.move_id
)
if to_unreconcile_move_lines:
to_unreconcile_move_lines.remove_move_reconcile()
3 changes: 3 additions & 0 deletions hr_expense_cancel/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
8 changes: 8 additions & 0 deletions hr_expense_cancel/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- [Tecnativa](https://www.tecnativa.com):
- Pedro M. Baeza
- Ernesto Tejeda
- Stefan Ungureanu
- Danh Vo \<<https://github.com/danhvophuong>\>
- Saran Lim. \<<saranl@ecosoft.co.th>\>
- Manuel Regidor \<<manuel.regidor@sygel.es>\>
- Italo LOPES \<<italo.lopes@camptocamp.com>\>
5 changes: 5 additions & 0 deletions hr_expense_cancel/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This module lets you reset a posted employee expense back to draft. It
draft-cancels the linked payments and unreconciles their journal lines
before core reverses the expense's move. Reconciliations created by
related modules (such as bills from `hr_expense_invoice`) are cancelled
in step.
10 changes: 10 additions & 0 deletions hr_expense_cancel/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
To use this module, you need to:

1. Go to *Expenses* and create a new *Expense* paid by *Employee (to
reimburse)*
2. Submit and approve it, then click on *Post Journal Entries*
3. Click on *Register Payment*, fill in the wizard and validate: the
expense's journal entry is now reconciled with a payment
4. Click on *Reset to Draft*
5. The expense goes back to *Draft*; the payment is cancelled and the
journal entry deleted
Binary file added hr_expense_cancel/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