[IMP] account_usability_akretion : Replace error by warning in case a user try to reverse an already reversed account move
The goal is to allow multiple refund for a single invoice. It may happen to refund invoice partially and they refund again partially later.
This commit is contained in:
@@ -30,6 +30,7 @@
|
|||||||
'wizard/account_invoice_mark_sent_view.xml',
|
'wizard/account_invoice_mark_sent_view.xml',
|
||||||
'wizard/account_group_generate_view.xml',
|
'wizard/account_group_generate_view.xml',
|
||||||
'wizard/account_payment_register_views.xml',
|
'wizard/account_payment_register_views.xml',
|
||||||
|
'wizard/account_move_reversal.xml',
|
||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
# 'report/invoice_report.xml', # TODO
|
# 'report/invoice_report.xml', # TODO
|
||||||
"views/res_partner.xml",
|
"views/res_partner.xml",
|
||||||
|
|||||||
@@ -37,6 +37,21 @@ msgstr ""
|
|||||||
"Une extourne <a href=# data-oe-model=account.move data-oe-"
|
"Une extourne <a href=# data-oe-model=account.move data-oe-"
|
||||||
"id=%d>%s</a> a été générée."
|
"id=%d>%s</a> a été générée."
|
||||||
|
|
||||||
|
#. module: account_usability_akretion
|
||||||
|
#. odoo-python
|
||||||
|
#: code:addons/account_usability_akretion/wizard/account_move_reversal.py:0
|
||||||
|
#, python-format
|
||||||
|
msgid "%s reversed by %s"
|
||||||
|
msgstr "%s extourné par %s"
|
||||||
|
|
||||||
|
#. module: account_usability_akretion
|
||||||
|
#: model_terms:ir.ui.view,arch_db:account_usability_akretion.view_account_move_reversal
|
||||||
|
msgid ""
|
||||||
|
"You are about to reverse entries that have already been reversed or partially reversed (refund). Make sure it is intented.\n"
|
||||||
|
" Already reversed entries are the following :"
|
||||||
|
msgstr "Vous êtes sur le point d'extourner une pièce comptable déjà extournée, ou partiellement extournée (avoir). Vérifiez que c'est bien ce que vous souhaitez faire.\n"
|
||||||
|
" Les pièces comptables déjà extournées sont les suivantes :"
|
||||||
|
|
||||||
#. module: account_usability_akretion
|
#. module: account_usability_akretion
|
||||||
#: model:ir.model,name:account_usability_akretion.model_account_account
|
#: model:ir.model,name:account_usability_akretion.model_account_account
|
||||||
msgid "Account"
|
msgid "Account"
|
||||||
@@ -366,13 +381,6 @@ msgstr "Divers"
|
|||||||
msgid "Missing Attachment"
|
msgid "Missing Attachment"
|
||||||
msgstr "Pièce jointe manquante"
|
msgstr "Pièce jointe manquante"
|
||||||
|
|
||||||
#. module: account_usability_akretion
|
|
||||||
#. odoo-python
|
|
||||||
#: code:addons/account_usability_akretion/wizard/account_move_reversal.py:0
|
|
||||||
#, python-format
|
|
||||||
msgid "Journal entry '%s' has already been reversed by journal entry '%s'."
|
|
||||||
msgstr "La pièce comptable '%s' a déjà été extournée par la pièce comptable '%s'."
|
|
||||||
|
|
||||||
#. module: account_usability_akretion
|
#. module: account_usability_akretion
|
||||||
#: model:ir.model,name:account_usability_akretion.model_account_partial_reconcile
|
#: model:ir.model,name:account_usability_akretion.model_account_partial_reconcile
|
||||||
msgid "Partial Reconcile"
|
msgid "Partial Reconcile"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from odoo import api, models, _
|
from odoo import api, fields, models, _
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
from odoo.exceptions import UserError
|
from odoo.exceptions import UserError
|
||||||
|
|
||||||
@@ -10,6 +10,23 @@ from odoo.exceptions import UserError
|
|||||||
class AccountMoveReversal(models.TransientModel):
|
class AccountMoveReversal(models.TransientModel):
|
||||||
_inherit = 'account.move.reversal'
|
_inherit = 'account.move.reversal'
|
||||||
|
|
||||||
|
already_reversed_warning = fields.Text(compute="_compute_already_reversed_warning")
|
||||||
|
|
||||||
|
@api.depends("move_ids")
|
||||||
|
def _compute_already_reversed_warning(self):
|
||||||
|
for wizard in self:
|
||||||
|
moves = wizard.move_ids or self.env["account.move"].browse(self._context['active_ids'])
|
||||||
|
reversed_moves = self.env["account.move"].search([('reversed_entry_id', 'in', moves.ids)])
|
||||||
|
warning = ""
|
||||||
|
for already_reversed_move in reversed_moves.reversed_entry_id:
|
||||||
|
if warning:
|
||||||
|
warning += "\n"
|
||||||
|
reversed_by = " ; ".join(already_reversed_move.reversal_move_id.mapped("display_name"))
|
||||||
|
move_detail = _("%s reversed by %s") % (already_reversed_move.display_name, reversed_by)
|
||||||
|
warning += move_detail
|
||||||
|
wizard.already_reversed_warning = warning or False
|
||||||
|
|
||||||
|
|
||||||
# Set default reversal date to original move + 1 day
|
# Set default reversal date to original move + 1 day
|
||||||
# and raise error if original move has already been reversed
|
# and raise error if original move has already been reversed
|
||||||
@api.model
|
@api.model
|
||||||
@@ -20,10 +37,4 @@ class AccountMoveReversal(models.TransientModel):
|
|||||||
moves = amo.browse(self._context['active_ids'])
|
moves = amo.browse(self._context['active_ids'])
|
||||||
if len(moves) == 1:
|
if len(moves) == 1:
|
||||||
res['date'] = moves.date + relativedelta(days=1)
|
res['date'] = moves.date + relativedelta(days=1)
|
||||||
reversed_move = amo.search([('reversed_entry_id', 'in', moves.ids)], limit=1)
|
|
||||||
if reversed_move:
|
|
||||||
raise UserError(_(
|
|
||||||
"Journal entry '%s' has already been reversed by journal entry '%s'.") % (
|
|
||||||
reversed_move.reversed_entry_id.display_name,
|
|
||||||
reversed_move.display_name))
|
|
||||||
return res
|
return res
|
||||||
|
|||||||
24
account_usability_akretion/wizard/account_move_reversal.xml
Normal file
24
account_usability_akretion/wizard/account_move_reversal.xml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<record id="view_account_move_reversal" model="ir.ui.view">
|
||||||
|
<field name="model">account.move.reversal</field>
|
||||||
|
<field name="inherit_id" ref="account.view_account_move_reversal"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="residual" position="before">
|
||||||
|
<div
|
||||||
|
class="alert alert-warning"
|
||||||
|
role="alert"
|
||||||
|
attrs="{'invisible': [('already_reversed_warning', '=', False)]}"
|
||||||
|
>
|
||||||
|
You are about to reverse entries that have already been reversed or partially reversed (refund). Make sure it is intented.
|
||||||
|
Already reversed entries are the following :
|
||||||
|
<field
|
||||||
|
name="already_reversed_warning"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
Reference in New Issue
Block a user