diff --git a/addons/account/__terp__.py b/addons/account/__terp__.py index 1fe6bd355bd..bd39518d5c1 100644 --- a/addons/account/__terp__.py +++ b/addons/account/__terp__.py @@ -54,6 +54,7 @@ module named account_voucherss 'wizard/account_move_line_reconcile_select_view.xml', 'wizard/account_move_journal_view.xml', 'account_wizard.xml', + 'wizard/account_open_closed_fiscalyear_view.xml', 'wizard/account_move_line_unreconcile_select_view.xml', 'wizard/account_subscription_generate_view.xml', 'project/wizard/project_account_analytic_line_view.xml', diff --git a/addons/account/account_wizard.xml b/addons/account/account_wizard.xml index 1597ec8898e..5ee4643e12e 100644 --- a/addons/account/account_wizard.xml +++ b/addons/account/account_wizard.xml @@ -32,26 +32,6 @@ --> - - - diff --git a/addons/account/wizard/__init__.py b/addons/account/wizard/__init__.py index f3a05ebe184..ffd08dae608 100644 --- a/addons/account/wizard/__init__.py +++ b/addons/account/wizard/__init__.py @@ -38,8 +38,7 @@ import wizard_partner_balance_report import account_period_close import wizard_fiscalyear_close import account_fiscalyear_close_state -import wizard_open_closed_fiscalyear - +import account_open_closed_fiscalyear import wizard_vat import wizard_compare_account_balance_report import wizard_invoice_state diff --git a/addons/account/wizard/account_open_closed_fiscalyear.py b/addons/account/wizard/account_open_closed_fiscalyear.py new file mode 100644 index 00000000000..b4f0f12b4b8 --- /dev/null +++ b/addons/account/wizard/account_open_closed_fiscalyear.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## + +from osv import fields, osv +from tools.translate import _ + +class account_open_closed_fiscalyear(osv.osv_memory): + + _name = "account.open.closed.fiscalyear" + _description = "Choose Fiscal Year" + _columns = { + 'fyear_id': fields.many2one('account.fiscalyear', \ + 'Fiscal Year to Open', required=True, help='Select Fiscal Year which you want to remove entries for its End of year entries journal'), + } + + def remove_entries(self, cr, uid, ids, context={}): + data = self.read(cr, uid, ids, [])[0] + data_fyear = self.pool.get('account.fiscalyear').browse(cr, uid, data['fyear_id']) + if not data_fyear.end_journal_period_id: + raise osv.except_osv(_('Error'), _('No journal for ending writing has been defined for the fiscal year')) + period_journal = data_fyear.end_journal_period_id + ids_move = self.pool.get('account.move').search(cr,uid,[('journal_id','=',period_journal.journal_id.id),('period_id','=',period_journal.period_id.id)]) + if ids_move: + cr.execute('delete from account_move where id =ANY(%s)',(ids_move,)) + #cr.execute('UPDATE account_journal_period ' \ + # 'SET state = %s ' \ + # 'WHERE period_id IN (SELECT id FROM account_period WHERE fiscalyear_id = %s)', + # ('draft',data_fyear)) + #cr.execute('UPDATE account_period SET state = %s ' \ + # 'WHERE fiscalyear_id = %s', ('draft',data_fyear)) + #cr.execute('UPDATE account_fiscalyear ' \ + # 'SET state = %s, end_journal_period_id = null '\ + # 'WHERE id = %s', ('draft',data_fyear)) + return {} + +account_open_closed_fiscalyear() +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_open_closed_fiscalyear_view.xml b/addons/account/wizard/account_open_closed_fiscalyear_view.xml new file mode 100644 index 00000000000..c5269939e0c --- /dev/null +++ b/addons/account/wizard/account_open_closed_fiscalyear_view.xml @@ -0,0 +1,37 @@ + + + + + account.open.closed.fiscalyear.form + account.open.closed.fiscalyear + form + +
+ + + + + +