1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
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.
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.
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/>.
20 ##############################################################################
22 from openerp.osv import fields, osv
23 from openerp.tools.translate import _
25 class account_open_closed_fiscalyear(osv.osv_memory):
26 _name = "account.open.closed.fiscalyear"
27 _description = "Choose Fiscal Year"
29 'fyear_id': fields.many2one('account.fiscalyear', \
30 'Fiscal Year', required=True, help='Select Fiscal Year which you want to remove entries for its End of year entries journal'),
33 def remove_entries(self, cr, uid, ids, context=None):
34 move_obj = self.pool.get('account.move')
36 data = self.browse(cr, uid, ids, context=context)[0]
37 period_journal = data.fyear_id.end_journal_period_id or False
38 if not period_journal:
39 raise osv.except_osv(_('Error!'), _("You have to set the 'End of Year Entries Journal' for this Fiscal Year which is set after generating opening entries from 'Generate Opening Entries'."))
41 ids_move = move_obj.search(cr, uid, [('journal_id','=',period_journal.journal_id.id),('period_id','=',period_journal.period_id.id)])
43 cr.execute('delete from account_move where id IN %s', (tuple(ids_move),))
44 return {'type': 'ir.actions.act_window_close'}
46 account_open_closed_fiscalyear()
48 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: