diff --git a/account_usability_akretion/__manifest__.py b/account_usability_akretion/__manifest__.py
index 9a25fdc..14e528a 100644
--- a/account_usability_akretion/__manifest__.py
+++ b/account_usability_akretion/__manifest__.py
@@ -30,6 +30,7 @@
'wizard/account_invoice_mark_sent_view.xml',
'wizard/account_group_generate_view.xml',
'wizard/account_payment_register_views.xml',
+ 'wizard/account_move_reversal.xml',
'security/ir.model.access.csv',
# 'report/invoice_report.xml', # TODO
"views/res_partner.xml",
diff --git a/account_usability_akretion/i18n/fr.po b/account_usability_akretion/i18n/fr.po
index f9594a2..f6bd7c4 100644
--- a/account_usability_akretion/i18n/fr.po
+++ b/account_usability_akretion/i18n/fr.po
@@ -37,6 +37,21 @@ msgstr ""
"Une extourne %s 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
#: model:ir.model,name:account_usability_akretion.model_account_account
msgid "Account"
@@ -366,13 +381,6 @@ msgstr "Divers"
msgid "Missing Attachment"
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
#: model:ir.model,name:account_usability_akretion.model_account_partial_reconcile
msgid "Partial Reconcile"
diff --git a/account_usability_akretion/wizard/account_move_reversal.py b/account_usability_akretion/wizard/account_move_reversal.py
index 16ee85e..86cefc9 100644
--- a/account_usability_akretion/wizard/account_move_reversal.py
+++ b/account_usability_akretion/wizard/account_move_reversal.py
@@ -2,7 +2,7 @@
# @author: Alexis de Lattre
# 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 odoo.exceptions import UserError
@@ -10,6 +10,23 @@ from odoo.exceptions import UserError
class AccountMoveReversal(models.TransientModel):
_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
# and raise error if original move has already been reversed
@api.model
@@ -20,10 +37,4 @@ class AccountMoveReversal(models.TransientModel):
moves = amo.browse(self._context['active_ids'])
if len(moves) == 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
diff --git a/account_usability_akretion/wizard/account_move_reversal.xml b/account_usability_akretion/wizard/account_move_reversal.xml
new file mode 100644
index 0000000..fae29e6
--- /dev/null
+++ b/account_usability_akretion/wizard/account_move_reversal.xml
@@ -0,0 +1,24 @@
+
+
+
+
+ account.move.reversal
+
+
+
+
+ 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 :
+
+