[IMP] Improved typo in Warning
[odoo/odoo.git] / addons / account / wizard / account_validate_account_move.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6 #
7 #    This program is free software: you can redistribute it and/or modify
8 #    it under the terms of the GNU Affero General Public License as
9 #    published by the Free Software Foundation, either version 3 of the
10 #    License, or (at your option) any later version.
11 #
12 #    This program is distributed in the hope that it will be useful,
13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #    GNU Affero General Public License for more details.
16 #
17 #    You should have received a copy of the GNU Affero General Public License
18 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 #
20 ##############################################################################
21 from openerp.osv import fields, osv
22 from openerp.tools.translate import _
23
24 class validate_account_move(osv.osv_memory):
25     _name = "validate.account.move"
26     _description = "Validate Account Move"
27     _columns = {
28         'journal_id': fields.many2one('account.journal', 'Journal', required=True),
29         'period_id': fields.many2one('account.period', 'Period', required=True, domain=[('state','<>','done')]),
30     }
31
32     def validate_move(self, cr, uid, ids, context=None):
33         obj_move = self.pool.get('account.move')
34         if context is None:
35             context = {}
36         data = self.browse(cr, uid, ids, context=context)[0]
37         ids_move = obj_move.search(cr, uid, [('state','=','draft'),('journal_id','=',data.journal_id.id),('period_id','=',data.period_id.id)])
38         if not ids_move:
39             raise osv.except_osv(_('Warning!'), _('Specified journal does not have any account move entries in draft state for this period.'))
40         obj_move.button_validate(cr, uid, ids_move, context=context)
41         return {'type': 'ir.actions.act_window_close'}
42
43
44 class validate_account_move_lines(osv.osv_memory):
45     _name = "validate.account.move.lines"
46     _description = "Validate Account Move Lines"
47
48     def validate_move_lines(self, cr, uid, ids, context=None):
49         obj_move_line = self.pool.get('account.move.line')
50         obj_move = self.pool.get('account.move')
51         move_ids = []
52         if context is None:
53             context = {}
54         data_line = obj_move_line.browse(cr, uid, context['active_ids'], context)
55         for line in data_line:
56             if line.move_id.state=='draft':
57                 move_ids.append(line.move_id.id)
58         move_ids = list(set(move_ids))
59         if not move_ids:
60             raise osv.except_osv(_('Warning!'), _('Selected Entry Lines does not have any account move entries in draft state.'))
61         obj_move.button_validate(cr, uid, move_ids, context)
62         return {'type': 'ir.actions.act_window_close'}
63
64 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
65