- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 112
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
[17.0][MIG] hr_expense_cancel #233
Changes from all commits
6742ea2
1f6bc06
44f5def
2f397b4
ecef6dd
13f8f2f
4fcda51
6ead784
b82523a
cceddad
fc4201d
f12197f
59d76d1
302d2ae
4686efc
6bd7f3f
d547481
26f832f
a74cff8
8c8ce19
ab4a85f
20c897c
0d378d9
8b5454b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
================= | ||
Hr expense cancel | ||
================= | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:dd9d0bd40b90578c3646bf029a19cfa4dd593fee766bc787e401c069918694dd | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
.. |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/17.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-17-0/hr-expense-17-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=17.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module allows you to cancel and correct expenses. It adds a cancel | ||
button on the expense sheet that undo reconciliations and delete | ||
payments and journal entries. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Installation | ||
============ | ||
|
||
It's assumed that for each expense sheet, the *payments* that are | ||
reconciled with their *journal entry* were created and reconciled by the | ||
*Expense Tracker* module automatically. Therefore, when this module is | ||
installed, these payments will automatically be associated with said | ||
expense sheet so that they can be deleted in case the expense sheet is | ||
canceled. | ||
|
||
Usage | ||
===== | ||
|
||
To use this module, you need to: | ||
|
||
1. Go to *Expenses -> My Expenses -> Expenses to Submit* and create a | ||
new *Expense* with *Employee (to reimburse)* checked on the field | ||
*Payment By* | ||
2. Click on *Submit to Manager* button | ||
3. Click on *Approve* button | ||
4. Click on *Post Journal Entries* button | ||
5. Click on *Register Payment* button, fill in the data of the wizard | ||
and click on *Validate* button | ||
6. After that, the *Expense report* will have an associated journal | ||
entry reconciled with a payment | ||
7. Click on *Cancel* button | ||
8. The *Expense report* will be set to *Submitted* state; the journal | ||
entry and the payment will be 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:%2017.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/17.0/hr_expense_cancel>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright 2019 Tecnativa - Ernesto Tejeda | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
{ | ||
"name": "Hr expense cancel", | ||
"version": "17.0.1.0.2", | ||
"author": "Tecnativa, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/hr-expense", | ||
"license": "AGPL-3", | ||
"category": "Human Resources", | ||
# The module hr_expense_payment function is to link the generated payments | ||
# with it's corresponding expense sheet. | ||
# So when you want to cancel payments associated to a expense_sheet, | ||
# you need to know which payments are related with your expense sheet. | ||
# And that information is not available by inheriting hr_expense alone, | ||
# we need the module | ||
"depends": ["hr_expense_payment"], | ||
"data": ["views/hr_expense_views.xml"], | ||
"installable": True, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# 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" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# 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" | ||
"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 "" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# 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: 2023-06-28 17:08+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 4.17\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" |
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 hr_expense |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,65 @@ | ||||||||||||||||||||||||||||
# Copyright 2019 Tecnativa - Ernesto Tejeda | ||||||||||||||||||||||||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
from odoo import models | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
class HrExpenseSheet(models.Model): | ||||||||||||||||||||||||||||
_inherit = "hr.expense.sheet" | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
def action_cancel(self): | ||||||||||||||||||||||||||||
for sheet in self: | ||||||||||||||||||||||||||||
account_move = sheet.account_move_ids | ||||||||||||||||||||||||||||
sheet.account_move_ids = False | ||||||||||||||||||||||||||||
payments = sheet.payment_ids.filtered(lambda line: line.state != "cancel") | ||||||||||||||||||||||||||||
# case : cancel invoice from hr_expense | ||||||||||||||||||||||||||||
self._remove_reconcile_hr_invoice(account_move) | ||||||||||||||||||||||||||||
# If the sheet is paid then remove payments | ||||||||||||||||||||||||||||
if sheet.state in ("done", "approve"): | ||||||||||||||||||||||||||||
if sheet.expense_line_ids[:1].payment_mode == "own_account": | ||||||||||||||||||||||||||||
self._remove_move_reconcile(payments, account_move) | ||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're changing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hello @yankinmax Here if I'm not wrong : OCA/OCB@68fbdc9#diff-42c75e4d29952aadf0abdd1bfe7e066bef3db1275c16d64dd3f3b96a332a2ff3 |
||||||||||||||||||||||||||||
self._cancel_payments(payments) | ||||||||||||||||||||||||||||
else: | ||||||||||||||||||||||||||||
# In this case, during the cancellation the journal entry | ||||||||||||||||||||||||||||
# will be deleted | ||||||||||||||||||||||||||||
self._cancel_payments(payments) | ||||||||||||||||||||||||||||
Comment on lines
+19
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can remove the
Suggested change
|
||||||||||||||||||||||||||||
# Deleting the Journal entry if in the previous steps | ||||||||||||||||||||||||||||
# (if the expense sheet is paid and payment_mode == 'own_account') | ||||||||||||||||||||||||||||
# it has not been deleted | ||||||||||||||||||||||||||||
if account_move.exists(): | ||||||||||||||||||||||||||||
move_to_cancel = account_move.filtered( | ||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename to |
||||||||||||||||||||||||||||
lambda move: move.state != "draft" | ||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||
if move_to_cancel: | ||||||||||||||||||||||||||||
move_to_cancel.button_cancel() | ||||||||||||||||||||||||||||
account_move.with_context(force_delete=True).unlink() | ||||||||||||||||||||||||||||
sheet.state = "submit" | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
def _remove_reconcile_hr_invoice(self, account_move): | ||||||||||||||||||||||||||||
"""Cancel invoice made by hr_expense_invoice module automatically""" | ||||||||||||||||||||||||||||
reconcile = account_move.mapped("line_ids.full_reconcile_id") | ||||||||||||||||||||||||||||
aml = self.env["account.move.line"].search( | ||||||||||||||||||||||||||||
[("full_reconcile_id", "in", reconcile.ids)] | ||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||
exp_move_line = aml.filtered( | ||||||||||||||||||||||||||||
lambda line: line.move_id.id not in account_move.ids | ||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||
Comment on lines
+40
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why run a
Suggested change
|
||||||||||||||||||||||||||||
# set state to cancel | ||||||||||||||||||||||||||||
exp_move_line.move_id.button_draft() | ||||||||||||||||||||||||||||
exp_move_line.move_id.button_cancel() | ||||||||||||||||||||||||||||
Comment on lines
+48
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
def _remove_move_reconcile(self, payments, account_move): | ||||||||||||||||||||||||||||
"""Delete only reconciliations made with the payments generated | ||||||||||||||||||||||||||||
by hr_expense module automatically""" | ||||||||||||||||||||||||||||
reconcile = account_move.mapped("line_ids.full_reconcile_id") | ||||||||||||||||||||||||||||
payments_aml = payments.move_id.line_ids | ||||||||||||||||||||||||||||
aml_unreconcile = payments_aml.filtered( | ||||||||||||||||||||||||||||
lambda r: r.full_reconcile_id in reconcile | ||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
aml_unreconcile.remove_move_reconcile() | ||||||||||||||||||||||||||||
Comment on lines
+54
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method could be improved just like the one above |
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
def _cancel_payments(self, payments): | ||||||||||||||||||||||||||||
for rec in payments: | ||||||||||||||||||||||||||||
rec.move_id.button_draft() | ||||||||||||||||||||||||||||
rec.move_id.button_cancel() | ||||||||||||||||||||||||||||
Comment on lines
+62
to
+65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
requires = ["whool"] | ||
build-backend = "whool.buildapi" |
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>\> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This module allows you to cancel and correct expenses. It adds a cancel | ||
button on the expense sheet that undo reconciliations and delete | ||
payments and journal entries. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
It's assumed that for each expense sheet, the *payments* that are | ||
reconciled with their *journal entry* were created and reconciled by the | ||
*Expense Tracker* module automatically. Therefore, when this module is | ||
installed, these payments will automatically be associated with said | ||
expense sheet so that they can be deleted in case the expense sheet is | ||
canceled. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
To use this module, you need to: | ||
|
||
1. Go to *Expenses -\> My Expenses -\> Expenses to Submit* and create a | ||
new *Expense* with *Employee (to reimburse)* checked on the field | ||
*Payment By* | ||
2. Click on *Submit to Manager* button | ||
3. Click on *Approve* button | ||
4. Click on *Post Journal Entries* button | ||
5. Click on *Register Payment* button, fill in the data of the wizard | ||
and click on *Validate* button | ||
6. After that, the *Expense report* will have an associated journal | ||
entry reconciled with a payment | ||
7. Click on *Cancel* button | ||
8. The *Expense report* will be set to *Submitted* state; the journal | ||
entry and the payment will be deleted |
Large diffs are not rendered by default.
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 test_hr_expense_cancel |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# Copyright 2019 Tecnativa - Ernesto Tejeda | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo.exceptions import UserError | ||
from odoo.tests.common import Form, TransactionCase | ||
|
||
|
||
class TestHrExpenseCancel(TransactionCase): | ||
def setUp(self): | ||
super().setUp() | ||
self.partner = self.env["res.partner"].create({"name": "Test partner"}) | ||
self.payment_obj = self.env["account.payment"] | ||
self.account_payment_register = self.env["account.payment.register"] | ||
self.payment_journal = self.env["account.journal"].search( | ||
[("type", "in", ["cash", "bank"])], limit=1 | ||
) | ||
|
||
self.main_company = company = self.env.ref("base.main_company") | ||
self.expense_journal = self.env["account.journal"].create( | ||
{ | ||
"name": "Purchase Journal - Test", | ||
"code": "HRTPJ", | ||
"type": "purchase", | ||
"company_id": company.id, | ||
} | ||
) | ||
|
||
self.expense = self.env["hr.expense"].create( | ||
{ | ||
"name": "Expense test", | ||
"employee_id": self.ref("hr.employee_admin"), | ||
"product_id": self.ref( | ||
"hr_expense.expense_product_travel_accommodation" | ||
), | ||
"total_amount": 10, | ||
} | ||
) | ||
self.expense.action_submit_expenses() | ||
|
||
self.expense_sheet = self.expense.sheet_id | ||
self.expense_sheet.journal_id = self.expense_journal | ||
self.expense_sheet.action_approve_expense_sheets() | ||
|
||
def _get_payment_wizard(self, expense_sheet): | ||
action = expense_sheet.action_register_payment() | ||
ctx = action.get("context") | ||
with Form( | ||
self.account_payment_register.with_context(**ctx), | ||
view="account.view_account_payment_register_form", | ||
) as f: | ||
f.amount = expense_sheet.total_amount | ||
register_payment = f.save() | ||
return register_payment | ||
|
||
def test_action_cancel_posted(self): | ||
self.expense_sheet.action_sheet_move_create() | ||
|
||
self.assertFalse(len(self.expense_sheet.payment_ids), 1) | ||
self.assertTrue(self.expense_sheet.account_move_ids) | ||
|
||
self.expense_sheet.action_cancel() | ||
|
||
self.assertFalse(self.expense_sheet.payment_ids) | ||
self.assertFalse(self.expense_sheet.account_move_ids) | ||
|
||
def test_action_cancel_no_update_posted(self): | ||
journals = self.payment_journal | self.expense_journal | ||
journals.write({"restrict_mode_hash_table": True}) | ||
with self.assertRaises(UserError): | ||
self.test_action_cancel_company_account() | ||
self.test_action_cancel_own_account() | ||
|
||
def test_action_cancel_company_account(self): | ||
self.expense.payment_mode = "company_account" | ||
self.expense_sheet.journal_id = self.payment_journal | ||
self.expense_sheet.action_sheet_move_create() | ||
self.assertTrue(self.expense_sheet.account_move_ids) | ||
self.expense_sheet.action_cancel() | ||
self.assertFalse(self.expense_sheet.account_move_ids) | ||
|
||
def test_action_cancel_own_account(self): | ||
self.expense_sheet.action_sheet_move_create() | ||
|
||
payment_wizard = self._get_payment_wizard(self.expense_sheet) | ||
payment_wizard.action_create_payments() | ||
|
||
self.assertTrue(self.expense_sheet.payment_ids) | ||
|
||
self.expense_sheet.action_cancel() # assertFalse(payment.exist) | ||
self.assertFalse(self.expense_sheet.payment_ids.state != "cancel") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- Copyright 2019 Tecnativa - Ernesto Tejeda | ||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> | ||
<odoo> | ||
<record id="view_hr_expense_sheet_form" model="ir.ui.view"> | ||
<field name="name">hr.expense.sheet.form.inherit</field> | ||
<field name="model">hr.expense.sheet</field> | ||
<field name="inherit_id" ref="hr_expense.view_hr_expense_sheet_form" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//header/field[@name='state']" position="before"> | ||
<button | ||
name="action_cancel" | ||
invisible="state not in ('post', 'done')" | ||
string="Cancel all related operations" | ||
type="object" | ||
groups="account.group_account_manager" | ||
help="Cancel journal entries, payments and reconciliations" | ||
/> | ||
</xpath> | ||
</field> | ||
</record> | ||
</odoo> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we have a
X2many
field, variable name should be plural