Add mass backtodraft wizard on account.move
This commit is contained in:
@@ -42,6 +42,7 @@ This module has been written by Alexis de Lattre from Akretion <alexis.delattre@
|
||||
'partner_view.xml',
|
||||
'product_view.xml',
|
||||
'wizard/account_invoice_mark_sent_view.xml',
|
||||
'wizard/account_move_backtodraft_view.xml',
|
||||
],
|
||||
'installable': True,
|
||||
}
|
||||
|
||||
@@ -2,3 +2,4 @@
|
||||
|
||||
from . import account_invoice_mark_sent
|
||||
from . import account_move_reversal
|
||||
from . import account_move_backtodraft
|
||||
|
||||
23
account_usability/wizard/account_move_backtodraft.py
Normal file
23
account_usability/wizard/account_move_backtodraft.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2019 Akretion France (http://www.akretion.com/)
|
||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# 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
|
||||
29
account_usability/wizard/account_move_backtodraft_view.xml
Normal file
29
account_usability/wizard/account_move_backtodraft_view.xml
Normal file
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
|
||||
<record id="account_move_backtodraft_form" model="ir.ui.view">
|
||||
<field name="name">Unpost Journal Entries</field>
|
||||
<field name="model">account.move.backtodraft</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Unpost Journal Entries">
|
||||
<label string="All selected journal entries will be unposted (if allowed by the journal configuration)."/>
|
||||
<footer>
|
||||
<button string="Unpost Journal Entries" name="backtodraft" type="object" class="btn-primary"/>
|
||||
<button string="Cancel" class="btn-default" special="cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<act_window id="account_move_backtodraft_action"
|
||||
multi="True"
|
||||
key2="client_action_multi"
|
||||
name="Unpost Journal Entries"
|
||||
res_model="account.move.backtodraft"
|
||||
src_model="account.move"
|
||||
view_mode="form"
|
||||
target="new" />
|
||||
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user