2010-04-15 04:50:02 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# OpenERP, Open Source Management Solution
|
|
|
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
|
|
|
#
|
|
|
|
# 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 <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
##############################################################################
|
2012-12-06 14:56:32 +00:00
|
|
|
from openerp.osv import fields, osv
|
|
|
|
from openerp.tools.translate import _
|
2010-04-15 04:50:02 +00:00
|
|
|
|
|
|
|
class validate_account_move(osv.osv_memory):
|
|
|
|
_name = "validate.account.move"
|
|
|
|
_description = "Validate Account Move"
|
|
|
|
_columns = {
|
2013-02-07 09:48:45 +00:00
|
|
|
'journal_ids': fields.many2many('account.journal', 'wizard_validate_account_move_journal', 'wizard_id', 'journal_id', 'Journal', required=True),
|
|
|
|
'period_ids': fields.many2many('account.period', 'wizard_validate_account_move_period', 'wizard_id', 'period_id', 'Period', required=True, domain=[('state','<>','done')]),
|
2010-08-19 11:51:57 +00:00
|
|
|
}
|
2010-04-15 04:50:02 +00:00
|
|
|
|
|
|
|
def validate_move(self, cr, uid, ids, context=None):
|
|
|
|
obj_move = self.pool.get('account.move')
|
|
|
|
if context is None:
|
|
|
|
context = {}
|
2013-02-06 22:30:10 +00:00
|
|
|
data = self.read(cr, uid, ids[0], context=context)
|
2013-02-07 14:26:27 +00:00
|
|
|
ids_move = obj_move.search(cr, uid, [('state','=','draft'),('journal_id','in',tuple(data['journal_ids'])),('period_id','in',tuple(data['period_ids']))])
|
2010-04-15 04:50:02 +00:00
|
|
|
if not ids_move:
|
2013-02-07 08:19:54 +00:00
|
|
|
raise osv.except_osv(_('Warning!'), _('Specified journals do not have any account move entries in draft state for the specified periods.'))
|
2010-12-13 06:43:09 +00:00
|
|
|
obj_move.button_validate(cr, uid, ids_move, context=context)
|
2010-12-28 10:44:45 +00:00
|
|
|
return {'type': 'ir.actions.act_window_close'}
|
2010-04-15 04:50:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
class validate_account_move_lines(osv.osv_memory):
|
|
|
|
_name = "validate.account.move.lines"
|
|
|
|
_description = "Validate Account Move Lines"
|
|
|
|
|
|
|
|
def validate_move_lines(self, cr, uid, ids, context=None):
|
|
|
|
obj_move_line = self.pool.get('account.move.line')
|
|
|
|
obj_move = self.pool.get('account.move')
|
|
|
|
move_ids = []
|
|
|
|
if context is None:
|
|
|
|
context = {}
|
|
|
|
data_line = obj_move_line.browse(cr, uid, context['active_ids'], context)
|
|
|
|
for line in data_line:
|
|
|
|
if line.move_id.state=='draft':
|
|
|
|
move_ids.append(line.move_id.id)
|
|
|
|
move_ids = list(set(move_ids))
|
|
|
|
if not move_ids:
|
2013-02-07 08:19:54 +00:00
|
|
|
raise osv.except_osv(_('Warning!'), _('Selected Entry Lines does not have any account move entries in draft state.'))
|
2010-04-15 04:50:02 +00:00
|
|
|
obj_move.button_validate(cr, uid, move_ids, context)
|
2010-12-28 10:44:45 +00:00
|
|
|
return {'type': 'ir.actions.act_window_close'}
|
2010-04-15 04:50:02 +00:00
|
|
|
|
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
|
|
|