[ADD] account,account_followup : Tooltips added for the wizards
[odoo/odoo.git] / addons / account / wizard / account_open_closed_fiscalyear.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
22 from osv import fields, osv
23 from tools.translate import _
24
25 class account_open_closed_fiscalyear(osv.osv_memory):
26     _name = "account.open.closed.fiscalyear"
27     _description = "Choose Fiscal Year"
28     _columns = {
29        'fyear_id': fields.many2one('account.fiscalyear', \
30                                  'Fiscal Year to Open', required=True, help='Select Fiscal Year which you want to remove entries for its End of year entries journal'),
31     }
32
33     def remove_entries(self, cr, uid, ids, context={}):
34         fy_obj = self.pool.get('account.fiscalyear')
35         move_obj = self.pool.get('account.move')
36
37         data = self.read(cr, uid, ids, [])[0]
38         data_fyear = fy_obj.browse(cr, uid, data['fyear_id'])
39         if not data_fyear.end_journal_period_id:
40             raise osv.except_osv(_('Error'), _('No journal for ending writing has been defined for the fiscal year'))
41         period_journal = data_fyear.end_journal_period_id
42         ids_move = move_obj.search(cr, uid, [('journal_id','=',period_journal.journal_id.id),('period_id','=',period_journal.period_id.id)])
43         if ids_move:
44             cr.execute('delete from account_move where id IN %s', (tuple(ids_move),))
45         return {}
46
47 account_open_closed_fiscalyear()
48
49 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: