From e884489c9b15960e1dd8cdc6b6d340276e17d6cd Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 28 Nov 2019 17:08:09 +0100 Subject: [PATCH] Add mass backtodraft wizard on account.move --- account_usability/__manifest__.py | 1 + account_usability/wizard/__init__.py | 1 + .../wizard/account_move_backtodraft.py | 23 +++++++++++++++ .../wizard/account_move_backtodraft_view.xml | 29 +++++++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 account_usability/wizard/account_move_backtodraft.py create mode 100644 account_usability/wizard/account_move_backtodraft_view.xml diff --git a/account_usability/__manifest__.py b/account_usability/__manifest__.py index 2764262..1cdb902 100644 --- a/account_usability/__manifest__.py +++ b/account_usability/__manifest__.py @@ -42,6 +42,7 @@ This module has been written by Alexis de Lattre from Akretion +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models, _ +from odoo.exceptions import UserError + + +class AccountMoveBacktodraft(models.TransientModel): + _name = 'account.move.backtodraft' + _description = 'Account Move Unpost' + + def backtodraft(self): + assert self._context.get('active_model') == 'account.move' + amo = self.env['account.move'] + moves = amo.browse(self._context.get('active_ids')) + moves_backtodraft = moves.filtered(lambda x: x.state == 'posted') + if not moves_backtodraft: + raise UserError(_( + 'There is no journal items in posted state to unpost.')) + moves_backtodraft.button_cancel() + return True diff --git a/account_usability/wizard/account_move_backtodraft_view.xml b/account_usability/wizard/account_move_backtodraft_view.xml new file mode 100644 index 0000000..1b56fc3 --- /dev/null +++ b/account_usability/wizard/account_move_backtodraft_view.xml @@ -0,0 +1,29 @@ + + + + + + Unpost Journal Entries + account.move.backtodraft + +
+
+
+ + + + +