~tempo-openerp/+junk/loewert-report-name

« back to all changes in this revision

Viewing changes to addons/account/wizard/account_open_closed_fiscalyear.py

  • Committer: jbe at tempo-consulting
  • Date: 2013-08-21 08:48:11 UTC
  • Revision ID: jbe@tempo-consulting.fr-20130821084811-913uo4l7b5ayxq8m
[NEW] Création de la branche trunk Loewert

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 openerp.osv import fields, osv
 
23
from openerp.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', 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=None):
 
34
        move_obj = self.pool.get('account.move')
 
35
 
 
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'."))
 
40
 
 
41
        ids_move = move_obj.search(cr, uid, [('journal_id','=',period_journal.journal_id.id),('period_id','=',period_journal.period_id.id)])
 
42
        if ids_move:
 
43
            cr.execute('delete from account_move where id IN %s', (tuple(ids_move),))
 
44
        return {'type': 'ir.actions.act_window_close'}
 
45
 
 
46
account_open_closed_fiscalyear()
 
47
 
 
48
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: