From 2f44fa9c7035ea47084354a6baaebab80cab5dc3 Mon Sep 17 00:00:00 2001 From: Matthieu Dietrich Date: Mon, 13 Jan 2014 11:03:11 +0100 Subject: [PATCH] [ADD] added new module account_move_validation_improvement to validate moves in multiple journals/periods --- .../__init__.py | 22 +++++++ .../__openerp__.py | 35 +++++++++++ .../wizard/__init__.py | 22 +++++++ .../wizard/account_validate_move.py | 60 +++++++++++++++++++ .../wizard/account_validate_move_view.xml | 25 ++++++++ 5 files changed, 164 insertions(+) create mode 100644 account_move_validation_improvement/__init__.py create mode 100644 account_move_validation_improvement/__openerp__.py create mode 100644 account_move_validation_improvement/wizard/__init__.py create mode 100644 account_move_validation_improvement/wizard/account_validate_move.py create mode 100644 account_move_validation_improvement/wizard/account_validate_move_view.xml diff --git a/account_move_validation_improvement/__init__.py b/account_move_validation_improvement/__init__.py new file mode 100644 index 000000000..a8080f932 --- /dev/null +++ b/account_move_validation_improvement/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author Matthieu Dietrich. Copyright 2012 Camptocamp SA +# +# 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 . +# +############################################################################## + +from . import wizard +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/account_move_validation_improvement/__openerp__.py b/account_move_validation_improvement/__openerp__.py new file mode 100644 index 000000000..6ec36a5e6 --- /dev/null +++ b/account_move_validation_improvement/__openerp__.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author Vincent Renaville/Joel Grand-Guillaume. Copyright 2012 Camptocamp SA +# +# 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 . +############################################################################## +{ + "name" : "Wizard to validate multiple moves", + "version" : "1.0", + "depends" : ["base", "account", "account_constraints"], + "author" : "Camptocamp", + 'license': 'AGPL-3', + "description": """ +Re-defining a base wizard (validate all moves in a period for a journal), +but extending it to multiple periods and multiple journals. It replaces the +base one defined in addons/account/wizard. + """, + 'website': 'http://www.camptocamp.com', + 'data' : ['wizard/account_validate_move_view.xml'], + 'installable': True, + 'active': False, +} +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_move_validation_improvement/wizard/__init__.py b/account_move_validation_improvement/wizard/__init__.py new file mode 100644 index 000000000..11ac3221a --- /dev/null +++ b/account_move_validation_improvement/wizard/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author Matthieu Dietrich. Copyright 2012 Camptocamp SA +# +# 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 . +# +############################################################################## + +from . import account_validate_move +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/account_move_validation_improvement/wizard/account_validate_move.py b/account_move_validation_improvement/wizard/account_validate_move.py new file mode 100644 index 000000000..d02923773 --- /dev/null +++ b/account_move_validation_improvement/wizard/account_validate_move.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## +from openerp.osv import fields, orm, osv +from openerp.tools.translate import _ + + +class ValidateAccountMove(orm.TransientModel): + _name = "validate.account.move" + _inherit = "validate.account.move" + + _columns = { + 'journal_ids': fields.many2many('account.journal', string='Journals', + required=True), + 'period_ids': fields.many2many('account.period', string='Periods', + required=True, + domain=[('state', '<>', 'done')]), + # re-define existing fields as non-mandatory + 'journal_id': fields.many2one('account.journal', 'Journal', + required=False), + 'period_id': fields.many2one('account.period', 'Period', + required=False), + } + + def validate_move(self, cr, uid, ids, context=None): + obj_move = self.pool.get('account.move') + if context is None: + context = {} + data = self.browse(cr, uid, ids, context=context)[0] + journal_ids = [journal.id for journal in data.journal_ids] + period_ids = [period.id for period in data.period_ids] + ids_move = obj_move.search(cr, uid, [('state', '=', 'draft'), + ('journal_id', 'in', journal_ids), + ('period_id', '=', period_ids)], + context=context) + if not ids_move: + raise osv.except_osv(_('Warning!'), + ('Specified journal does not have any account move entries in draft state for this period.')) + obj_move.button_validate(cr, uid, ids_move, context=context) + return {'type': 'ir.actions.act_window_close'} + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/account_move_validation_improvement/wizard/account_validate_move_view.xml b/account_move_validation_improvement/wizard/account_validate_move_view.xml new file mode 100644 index 000000000..c0d3b2882 --- /dev/null +++ b/account_move_validation_improvement/wizard/account_validate_move_view.xml @@ -0,0 +1,25 @@ + + + + + + + Post Journal Entries + validate.account.move + +
+ + + + + +
+
+
+ +
+