improvement : account config wizard

bzr revid: hmo@tinyerp.com-20080918162218-kwk0el0464u0vyrx
This commit is contained in:
Harshad Modi 2008-09-18 21:52:18 +05:30
parent 9b7fb1feb0
commit 211d988054
3 changed files with 76 additions and 121 deletions

View File

@ -1476,55 +1476,8 @@ class account_subscription_line(osv.osv):
account_subscription_line()
class account_config_fiscalyear(osv.osv_memory):
_name = 'account.config.fiscalyear'
_columns = {
'name':fields.char('Name', required=True,size=64),
'code':fields.char('Code', required=True,size=64),
'date1': fields.date('Starting Date', required=True),
'date2': fields.date('Ending Date', required=True),
}
_defaults = {
'code': lambda *a: time.strftime('%Y'),
'date1': lambda *a: time.strftime('%Y-01-01'),
'date2': lambda *a: time.strftime('%Y-12-31'),
}
def action_cancel(self,cr,uid,ids,conect=None):
return {
'view_type': 'form',
"view_mode": 'form',
'res_model': 'ir.module.module.configuration.wizard',
'type': 'ir.actions.act_window',
'target':'new',
}
def action_create(self, cr, uid,ids, context=None):
res=self.read(cr,uid,ids)[0]
if 'date1' in res and 'date2' in res:
res_obj = self.pool.get('account.fiscalyear')
start_date=res['date1']
end_date=res['date2']
name=res['name']#DateTime.strptime(start_date, '%Y-%m-%d').strftime('%m.%Y') + '-' + DateTime.strptime(end_date, '%Y-%m-%d').strftime('%m.%Y')
vals={
'name':name,
'code':name,
'date_start':start_date,
'date_stop':end_date,
}
new_id=res_obj.create(cr, uid, vals, context=context)
res_obj.create_period(cr,uid,[new_id])
return {
'view_type': 'form',
"view_mode": 'form',
'res_model': 'ir.module.module.configuration.wizard',
'type': 'ir.actions.act_window',
'target':'new',
}
account_config_fiscalyear()
class account_config_charts(osv.osv_memory):
_name = 'account.config.charts'
class account_config_wizard(osv.osv_memory):
_name = 'account.config.wizard'
def _get_charts(self, cr, uid, context):
module_obj=self.pool.get('ir.module.module')
ids=module_obj.search(cr, uid, [('category_id', '=', 'Account charts'), ('state', '<>', 'installed')])
@ -1532,11 +1485,20 @@ class account_config_charts(osv.osv_memory):
res.append((-1, 'None'))
res.sort(lambda x,y: cmp(x[1],y[1]))
return res
_columns = {
'charts' : fields.selection(_get_charts, 'Charts of Account',required=True)
}
'name':fields.char('Name', required=True,size=64),
'code':fields.char('Code', required=True,size=64),
'date1': fields.date('Starting Date', required=True),
'date2': fields.date('Ending Date', required=True),
'period':fields.selection([('month','Month'),('3months','3 Months')], 'Periods', required=True),
'charts' : fields.selection(_get_charts, 'Charts of Account',required=True)
}
_defaults = {
'code': lambda *a: time.strftime('%Y'),
'date1': lambda *a: time.strftime('%Y-01-01'),
'date2': lambda *a: time.strftime('%Y-12-31'),
'period':lambda *a:'month'
}
def action_cancel(self,cr,uid,ids,conect=None):
return {
'view_type': 'form',
@ -1545,28 +1507,48 @@ class account_config_charts(osv.osv_memory):
'type': 'ir.actions.act_window',
'target':'new',
}
def action_create(self, cr, uid,ids, context=None):
res=self.read(cr,uid,ids)[0]
id = res['charts']
def install(id):
mod_obj = self.pool.get('ir.module.module')
mod_obj.write(cr , uid, [id] ,{'state' : 'to install'})
mod_obj.download(cr, uid, [id], context=context)
cr.commit()
cr.execute("select m.id as id from ir_module_module_dependency d inner join ir_module_module m on (m.name=d.name) where d.module_id=%d and m.state='uninstalled'",(id,))
ret = cr.fetchall()
if len(ret):
for r in ret:
install(r[0])
else:
def install_account_chart(self, cr, uid,ids, context=None):
for res in self.read(cr,uid,ids):
id = res['charts']
def install(id):
mod_obj = self.pool.get('ir.module.module')
mod_obj.write(cr , uid, [id] ,{'state' : 'to install'})
mod_obj.download(cr, uid, [id], context=context)
cr.commit()
install(id)
cr.execute("select m.id as id from ir_module_module_dependency d inner join ir_module_module m on (m.name=d.name) where d.module_id=%d and m.state='uninstalled'",(id,))
ret = cr.fetchall()
if len(ret):
for r in ret:
install(r[0])
else:
mod_obj.write(cr , uid, [id] ,{'state' : 'to install'})
mod_obj.download(cr, uid, [id], context=context)
cr.commit()
if id>0:
install(id)
cr.commit()
db, pool = pooler.restart_pool(cr.dbname, update_module=True)
def action_create(self, cr, uid,ids, context=None):
for res in self.read(cr,uid,ids):
if 'date1' in res and 'date2' in res:
res_obj = self.pool.get('account.fiscalyear')
start_date=res['date1']
end_date=res['date2']
name=res['name']#DateTime.strptime(start_date, '%Y-%m-%d').strftime('%m.%Y') + '-' + DateTime.strptime(end_date, '%Y-%m-%d').strftime('%m.%Y')
vals={
'name':name,
'code':name,
'date_start':start_date,
'date_stop':end_date,
}
new_id=res_obj.create(cr, uid, vals, context=context)
if res['period']=='month':
res_obj.create_period(cr,uid,[new_id])
elif res['period']=='3months':
res_obj.create_period3(cr,uid,[new_id])
self.install_account_chart(cr,uid,ids)
return {
'view_type': 'form',
"view_mode": 'form',
@ -1575,7 +1557,10 @@ class account_config_charts(osv.osv_memory):
'target':'new',
}
account_config_charts()
account_config_wizard()
# ---------------------------------------------------------------
# Account Templates : Account, Tax, Tax Code and chart. + Wizard

View File

@ -1323,81 +1323,52 @@
<!-- configuration wizard view -->
<record id="view_config_fiscalyear_form" model="ir.ui.view">
<field name="name">Configure Fiscal Year</field>
<field name="model">account.config.fiscalyear</field>
<record id="view_account_config_wizard_form" model="ir.ui.view">
<field name="name">Account Configure wizard</field>
<field name="model">account.config.wizard</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Configure Your Fiscal Year">
<separator col="4" colspan="4" string="Configure Your Fiscal Year"/>
<form string="Account Configure">
<separator col="4" colspan="4" string="Create a Fiscal Year"/>
<field name="name"/>
<field name="code"/>
<field name="date1"/>
<field name="date2"/>
<field name="period" colspan="4"/>
<separator col="4" colspan="4" string="Select Chart of Accounts"/>
<field name="charts"/>
<separator string="" colspan="4"/>
<label string="" colspan="2"/>
<group col="2" colspan="2">
<button icon="gtk-cancel" special="cancel" string="Don't Create" name="action_cancel" type="object"/>
<button icon="gtk-ok" name="action_create" string="Create" type="object"/>
<button icon="gtk-cancel" special="cancel" string="Don't Continue" name="action_cancel" type="object"/>
<button icon="gtk-ok" name="action_create" string="Continue" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_config_fiscalyear_form" model="ir.actions.act_window">
<field name="name">Configure Fiscal Year</field>
<record id="action_account_config_wizard_form" model="ir.actions.act_window">
<field name="name">Account Configure Wizard </field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.config.fiscalyear</field>
<field name="res_model">account.config.wizard</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</record>
<record id="view_config_charts_form" model="ir.ui.view">
<field name="name">Select Charts of Account</field>
<field name="model">account.config.charts</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Select Charts of Account">
<separator colspan="2" string="Install Charts of Account"/>
<newline/>
<field name="charts"/>
<newline/>
<separator string="" colspan="2"/>
<newline/>
<group col="2" colspan="2">
<button icon="gtk-cancel" special="cancel" string="Skip Step" name="action_cancel" type="object"/>
<button icon="gtk-ok" name="action_create" string="Install" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_config_charts_form" model="ir.actions.act_window">
<field name="name">Install Charts of Account</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.config.charts</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<!-- register configuration wizard -->
<record id="config_fiscalyear" model="ir.module.module.configuration.step">
<field name="name">Define Fiscal Years</field>
<field name="note">Define Fiscal Years</field>
<field name="action_id" ref="action_config_fiscalyear_form"/>
<field name="name">Account Configure Wizard</field>
<field name="note">Define Fiscal Years and Select Charts of Account</field>
<field name="action_id" ref="action_account_config_wizard_form"/>
<field name="state">open</field>
</record>
</record>
<record id="config_charts" model="ir.module.module.configuration.step">
<field name="name">Select Charts of Account</field>
<field name="note">There are much more charts of accounts available on the OpenERP website.If you don't select one now, you'll be able to install another one through the Administration menu.</field>
<field name="action_id" ref="action_config_charts_form"/>
<field name="state">open</field>
</record>
<!-- Account Templates -->

View File

@ -17,7 +17,6 @@
"access_account_model_line","account.model.line","model_account_model_line","account.group_account_user",1,1,1,1
"access_account_subscription","account.subscription","model_account_subscription","account.group_account_user",1,1,1,1
"access_account_subscription_line","account.subscription.line","model_account_subscription_line","account.group_account_user",1,1,1,1
"access_account_config_fiscalyear","account.config.fiscalyear","model_account_config_fiscalyear","account.group_account_manager",1,1,1,1
"access_account_tax_template","account.tax.template","model_account_tax_template","account.group_account_manager",1,1,1,1
"access_account_account_template","account.account.template","model_account_account_template","account.group_account_manager",1,1,1,1
"access_account_tax_code_template","account.tax.code.template","model_account_tax_code_template","account.group_account_manager",1,1,1,1

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
17 access_account_model_line account.model.line model_account_model_line account.group_account_user 1 1 1 1
18 access_account_subscription account.subscription model_account_subscription account.group_account_user 1 1 1 1
19 access_account_subscription_line account.subscription.line model_account_subscription_line account.group_account_user 1 1 1 1
access_account_config_fiscalyear account.config.fiscalyear model_account_config_fiscalyear account.group_account_manager 1 1 1 1
20 access_account_tax_template account.tax.template model_account_tax_template account.group_account_manager 1 1 1 1
21 access_account_account_template account.account.template model_account_account_template account.group_account_manager 1 1 1 1
22 access_account_tax_code_template account.tax.code.template model_account_tax_code_template account.group_account_manager 1 1 1 1