[ADD] Account: osv memory : open close fiscal year
bzr revid: tiny@tiny-desktop-20100406070748-hv2pdkkui4pqj38c
This commit is contained in:
parent
1a2b32f5c9
commit
34a6157058
|
@ -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',
|
||||
|
|
|
@ -32,26 +32,6 @@
|
|||
<menuitem action="wizard_fiscalyear_close_state" id="menu_wizard_fy_close_state" parent="menu_account_end_year_treatments" type="wizard"/>
|
||||
-->
|
||||
|
||||
<wizard
|
||||
id="wizard_open_closed_fiscalyear"
|
||||
menu="False"
|
||||
model="account.fiscalyear"
|
||||
name="account.open_closed_fiscalyear"
|
||||
string="Cancel Opening Entries"/>
|
||||
<menuitem
|
||||
action="wizard_open_closed_fiscalyear"
|
||||
id="menu_wizard_open_closed_fy"
|
||||
sequence="2"
|
||||
parent="account.menu_account_end_year_treatments" type="wizard"/>
|
||||
<!-- period close
|
||||
|
||||
|
||||
<wizard id="wizard_period_close" model="account.period" name="account.period.close" string="Close a Period"/>
|
||||
|
||||
<wizard id="action_account_period_close" model="account.period" name="account.period.close" string="Close a Period"/>
|
||||
|
||||
|
||||
-->
|
||||
<!-- automatic reconcile -->
|
||||
<wizard id="wizard_automatic_reconcile" menu="False" model="account.account" name="account.automatic.reconcile" string="Automatic reconciliation"/>
|
||||
<menuitem id="next_id_20" name="Reconciliation" parent="menu_finance_periodical_processing"/>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
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:
|
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_account_open_closed_fiscalyear" model="ir.ui.view">
|
||||
<field name="name">account.open.closed.fiscalyear.form</field>
|
||||
<field name="model">account.open.closed.fiscalyear</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Choose Fiscal Year ">
|
||||
<group colspan="4" >
|
||||
<field name="fyear_id" domain = "[('state','=','draft')]"/>
|
||||
</group>
|
||||
<separator string="" colspan="4" />
|
||||
<group colspan="4" col="6">
|
||||
<label string ="" colspan="2"/>
|
||||
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
|
||||
<button icon="gtk-open" string="Open" name="remove_entries" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_account_open_closed_fiscalyear" model="ir.actions.act_window">
|
||||
<field name="name">Cancel Opening Entries</field>
|
||||
<field name="res_model">account.open.closed.fiscalyear</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_account_open_closed_fiscalyear"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<menuitem action="action_account_open_closed_fiscalyear"
|
||||
id="menu_wizard_open_closed_fy" sequence="2"
|
||||
parent="account.menu_account_end_year_treatments" />
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,81 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import wizard
|
||||
import netsvc
|
||||
import pooler
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
|
||||
form = """<?xml version="1.0"?>
|
||||
<form string="Choose Fiscal Year">
|
||||
<field name="fyear_id" domain="[('state','=','draft')]"/>
|
||||
</form>
|
||||
"""
|
||||
|
||||
fields = {
|
||||
'fyear_id': {'string': 'Fiscal Year to Open', 'type': 'many2one', 'relation': 'account.fiscalyear', 'required': True},
|
||||
}
|
||||
|
||||
def _remove_entries(self, cr, uid, data, context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
data_fyear = pool.get('account.fiscalyear').browse(cr,uid,data['form']['fyear_id'])
|
||||
if not data_fyear.end_journal_period_id:
|
||||
raise wizard.except_wizard(_('Error'), _('No journal for ending writing has been defined for the fiscal year'))
|
||||
period_journal = data_fyear.end_journal_period_id
|
||||
ids_move = 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 {}
|
||||
|
||||
class open_closed_fiscal(wizard.interface):
|
||||
states = {
|
||||
'init' : {
|
||||
'actions' : [],
|
||||
'result': {
|
||||
'type': 'form',
|
||||
'arch': form,
|
||||
'fields': fields,
|
||||
'state':[('end','Cancel', 'gtk-cancel'),('open','Open', 'gtk-ok')]
|
||||
}
|
||||
},
|
||||
'open': {
|
||||
'actions': [],
|
||||
'result': {
|
||||
'type':'action',
|
||||
'action':_remove_entries,
|
||||
'state':'end'
|
||||
},
|
||||
},
|
||||
}
|
||||
open_closed_fiscal("account.open_closed_fiscalyear")
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
Loading…
Reference in New Issue