Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
173 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
.. |company| replace:: ADHOC SA | ||
|
||
.. |company_logo| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-logo.png | ||
:alt: ADHOC SA | ||
:target: https://www.adhoc.com.ar | ||
|
||
.. |icon| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-icon.png | ||
|
||
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png | ||
:target: https://www.gnu.org/licenses/agpl | ||
:alt: License: AGPL-3 | ||
|
||
===================== | ||
Accounting Reports UX | ||
===================== | ||
This module adds validations on batch payment operations: | ||
|
||
#. Restrict unlink payments linked to the batch payment if the batch is not on draft state. | ||
#. Restrict delete an account batch payment if it's not on draft state. | ||
#. Restrict set batch payments to draft if any associated payment line is reconciled. | ||
|
||
Installation | ||
============ | ||
|
||
To install this module, you need to: | ||
|
||
#. Only need to install the module | ||
|
||
Configuration | ||
============= | ||
|
||
To configure this module, you need to: | ||
|
||
#. Nothing to configure | ||
|
||
Usage | ||
===== | ||
|
||
To use this module, you need to: | ||
|
||
#. Go to ... | ||
|
||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
:alt: Try me on Runbot | ||
:target: http://runbot.adhoc.com.ar/ | ||
|
||
Credits | ||
======= | ||
|
||
Images | ||
------ | ||
|
||
* |company| |icon| | ||
|
||
Contributors | ||
------------ | ||
|
||
Maintainer | ||
---------- | ||
|
||
|company_logo| | ||
|
||
This module is maintained by the |company|. | ||
|
||
To contribute to this module, please visit https://www.adhoc.com.ar. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
############################################################################## | ||
# For copyright and license notices, see __manifest__.py file in module root | ||
# directory | ||
############################################################################## | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
############################################################################## | ||
# | ||
# Copyright (C) 2024 ADHOC SA (http://www.adhoc.com.ar) | ||
# All Rights Reserved. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
{ | ||
'name': 'Account Batch Payment UX', | ||
'version': "17.0.0.1.0", | ||
'category': 'Accounting', | ||
'sequence': 14, | ||
'summary': '', | ||
'author': 'ADHOC SA', | ||
'website': 'www.adhoc.com.ar', | ||
'license': 'AGPL-3', | ||
'images': [ | ||
], | ||
'depends': [ | ||
'account_batch_payment', | ||
], | ||
'data': [ | ||
'views/account_batch_payment.xml', | ||
], | ||
'demo': [ | ||
], | ||
'installable': True, | ||
'auto_install': True, | ||
'application': False, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
############################################################################## | ||
# For copyright and license notices, see __manifest__.py file in module root | ||
# directory | ||
############################################################################## | ||
from . import account_batch_payment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from odoo import models, fields, api, _ | ||
from odoo.exceptions import UserError, RedirectWarning | ||
|
||
|
||
class AccountBatchPayment(models.Model): | ||
_inherit = 'account.batch.payment' | ||
|
||
@api.depends('payment_ids') | ||
def verify_unlinked_payments_from_batch(self): | ||
"""don´t allow to unlink payments linked to the batch payment if the batch is not on draft state""" | ||
if (self._origin.filtered(lambda x: x.state != 'draft') and len(self._origin.payment_ids) != len(self.payment_ids)): | ||
raise UserError(_("You are not allowed to delete payments from a batch payment if the batch is not on draft state.")) | ||
|
||
def unlink(self): | ||
"""This method don't allow to delete an account batch payment if it's not on draft state""" | ||
if self.filtered(lambda x: x.state != 'draft'): | ||
raise UserError(_("You are not allowed to delete a batch payment if is not on draft state.")) | ||
return super().unlink() | ||
|
||
def action_draft(self): | ||
"""Only sent batch payments can be changed to draft state""" | ||
matched_entries = self.payment_ids.filtered('is_matched') | ||
if matched_entries: | ||
error_msg = ("The following payments are reconciled and cannot be reset to draft state: \n") | ||
for entry in matched_entries: | ||
error_msg += f"{entry.name} \n" | ||
action_error = { | ||
'view_mode': 'tree', | ||
'name': _('Matched Entries'), | ||
'res_model': 'account.bank.statement.line', | ||
'type': 'ir.actions.act_window', | ||
'domain': [('id', 'in', matched_entries.mapped('reconciled_statement_line_ids').ids)], | ||
'views': [ | ||
(self.env.ref('account_accountant.view_bank_statement_line_kanban_bank_rec_widget').id, 'kanban'), | ||
(self.env.ref('account_accountant.view_bank_statement_line_tree_bank_rec_widget').id, 'list'), | ||
] | ||
} | ||
raise RedirectWarning(error_msg, action_error, _('Show matched entries')) | ||
|
||
self.payment_ids.is_move_sent = False | ||
self.write({'state': 'draft'}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<record id="view_batch_payment_form_inherit" model="ir.ui.view"> | ||
<field name="name">account.batch.payment.form.inherit</field> | ||
<field name="model">account.batch.payment</field> | ||
<field name="inherit_id" ref="account_batch_payment.view_batch_payment_form"/> | ||
<field name="arch" type="xml"> | ||
<button name="print_batch_payment" position="after"> | ||
<button name="action_draft" class="btn btn-secondary" confirm="Payments will be returned to draft and marked as unsent and unreconciled." data-hotkey="w" string="Reset To Draft" type='object' invisible="state != 'sent'"/> | ||
</button> | ||
</field> | ||
</record> | ||
|
||
</odoo> |