[fix] account: migrate to res.config-based initial configuration

bzr revid: xmo@tinyerp.com-20091214154108-qy7ms9h83jxu2wnr
This commit is contained in:
Xavier Morel 2009-12-14 16:41:08 +01:00
parent 0ca489257a
commit 0c4142b546
4 changed files with 58 additions and 101 deletions

View File

@ -1708,6 +1708,7 @@ account_subscription_line()
class account_config_wizard(osv.osv_memory):
_name = 'account.config.wizard'
_inherit = 'res.config'
def _get_charts(self, cr, uid, context):
module_obj=self.pool.get('ir.module.module')
@ -1732,15 +1733,6 @@ class account_config_wizard(osv.osv_memory):
'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',
"view_mode": 'form',
'res_model': 'ir.actions.configuration.wizard',
'type': 'ir.actions.act_window',
'target':'new',
}
def install_account_chart(self, cr, uid, ids, context=None):
for res in self.read(cr,uid,ids):
chart_id = res['charts']
@ -1750,7 +1742,7 @@ class account_config_wizard(osv.osv_memory):
cr.commit()
db, pool = pooler.restart_pool(cr.dbname, update_module=True)
def action_create(self, cr, uid,ids, context=None):
def execute(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')
@ -1769,16 +1761,6 @@ class account_config_wizard(osv.osv_memory):
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',
'res_model': 'ir.actions.configuration.wizard',
'type': 'ir.actions.act_window',
'target':'new',
}
account_config_wizard()
@ -2117,6 +2099,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
* generates all accounting properties and assigns them correctly
"""
_name='wizard.multi.charts.accounts'
_inherit = 'res.config'
_columns = {
'company_id':fields.many2one('res.company','Company',required=True),
@ -2137,7 +2120,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
'code_digits': lambda *a:6,
}
def action_create(self, cr, uid, ids, context=None):
def execute(self, cr, uid, ids, context=None):
obj_multi = self.browse(cr,uid,ids[0])
obj_acc = self.pool.get('account.account')
obj_acc_tax = self.pool.get('account.tax')
@ -2400,24 +2383,6 @@ class wizard_multi_charts_accounts(osv.osv_memory):
'position_id' : new_fp,
}
obj_ac_fp.create(cr, uid, vals_acc)
return {
'view_type': 'form',
"view_mode": 'form',
'res_model': 'ir.actions.configuration.wizard',
'type': 'ir.actions.act_window',
'target':'new',
}
def action_cancel(self,cr,uid,ids,conect=None):
return {
'view_type': 'form',
"view_mode": 'form',
'res_model': 'ir.actions.configuration.wizard',
'type': 'ir.actions.act_window',
'target':'new',
}
wizard_multi_charts_accounts()
class account_bank_accounts_wizard(osv.osv_memory):

View File

@ -1447,8 +1447,13 @@
<field name="name">Account Configure wizard</field>
<field name="model">account.config.wizard</field>
<field name="type">form</field>
<field name="inherit_id" ref="base.res_config_view_base"/>
<field name="arch" type="xml">
<form string="Account Configure">
<data>
<form position="attributes"><attribute name="string">
Account Configure
</attribute></form>
<group string="res_config_contents" position="replace">
<separator col="4" colspan="4" string="Create a Fiscal Year"/>
<field name="name"/>
<field name="code"/>
@ -1457,13 +1462,8 @@
<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="Skip" name="action_cancel" type="object"/>
<button icon="gtk-ok" name="action_create" string="Continue" type="object"/>
</group>
</form>
</group>
</data>
</field>
</record>
@ -1471,6 +1471,7 @@
<field name="name">Account Configure Wizard </field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.config.wizard</field>
<field name="view_id" ref="view_account_config_wizard_form"/>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
@ -1478,8 +1479,6 @@
<!-- register configuration wizard -->
<record id="config_fiscalyear" model="ir.actions.todo">
<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"/>
</record>
@ -1728,31 +1727,37 @@
<field name="name">Generate Chart of Accounts from a Chart Template</field>
<field name="model">wizard.multi.charts.accounts</field>
<field name="type">form</field>
<field name="inherit_id" ref="base.res_config_view_base"/>
<field name="arch" type="xml">
<form string="Generate Chart of Accounts from a Chart Template">
<separator col="4" colspan="4" string="Generate Chart of Accounts from a Chart Template"/>
<label align="0.0" string="This will automatically configure your chart of accounts, bank accounts, taxes and journals according to the selected template" colspan="4"/>
<field name="company_id" widget="selection" groups="base.group_multi_company"/>
<field name ="code_digits" />
<field name="chart_template_id"/>
<field name ="seq_journal" />
<field colspan="4" mode="tree" name="bank_accounts_id" nolabel="1" widget="one2many_list">
<form string="Bank Information">
<field name="acc_no"/>
<field name="currency_id"/>
</form>
<tree editable="bottom" string="Bank Information">
<field name="acc_no"/>
<field name="currency_id"/>
</tree>
</field>
<separator string="" colspan="4"/>
<label string="" colspan="2"/>
<group col="2" colspan="2">
<button icon="gtk-cancel" special="cancel" type="object" name="action_cancel" string="Cancel"/>
<button icon="gtk-ok" name="action_create" string="Create" type="object"/>
</group>
</form>
<data>
<form position="attributes"><attribute name="string">
Generate Chart of Accounts from a Chart Template
</attribute></form>
<group string="res_config_contents" position="replace">
<separator col="4" colspan="4" string="
Generate Chart of Accounts from a Chart Template"/>
<label align="0.0" colspan="4" string="
This will automatically configure your chart of accounts,
bank accounts, taxes and journals according to the selected
template"/>
<field name="company_id" widget="selection"
groups="base.group_multi_company"/>
<field name ="code_digits" />
<field name="chart_template_id"/>
<field name ="seq_journal" />
<field colspan="4" mode="tree" name="bank_accounts_id"
nolabel="1" widget="one2many_list">
<form string="Bank Information">
<field name="acc_no"/>
<field name="currency_id"/>
</form>
<tree editable="bottom" string="Bank Information">
<field name="acc_no"/>
<field name="currency_id"/>
</tree>
</field>
</group>
</data>
</field>
</record>
@ -1760,6 +1765,7 @@
<field name="name">Generate Chart of Accounts from a Chart Template</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">wizard.multi.charts.accounts</field>
<field name="view_id" ref="view_wizard_multi_chart"/>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>

View File

@ -42,6 +42,7 @@ class company_setup(osv.osv_memory):
* Insert a suitable message for Overdue Payment Report.
"""
_name='wizard.company.setup'
_inherit = 'res.config'
_columns = {
'company_id':fields.many2one('res.company','Company',required=True),
@ -72,27 +73,9 @@ class company_setup(osv.osv_memory):
return {'value': res }
def action_create(self, cr, uid, ids, context=None):
def execute(self, cr, uid, ids, context=None):
content_wiz = self.pool.get('wizard.company.setup').read(cr,uid,ids,['company_id','overdue_msg'])
if content_wiz:
wiz_data = content_wiz[0]
self.pool.get('res.company').write(cr, uid, [wiz_data['company_id']], {'overdue_msg':wiz_data['overdue_msg']})
return {
'view_type': 'form',
"view_mode": 'form',
'res_model': 'ir.actions.configuration.wizard',
'type': 'ir.actions.act_window',
'target':'new',
}
def action_cancel(self,cr,uid,ids,conect=None):
return {
'view_type': 'form',
"view_mode": 'form',
'res_model': 'ir.actions.configuration.wizard',
'type': 'ir.actions.act_window',
'target':'new',
}
company_setup()

View File

@ -22,17 +22,21 @@
<field name="name">wizard.company.setup.form</field>
<field name="model">wizard.company.setup</field>
<field name="type">form</field>
<field name="inherit_id" ref="base.res_config_view_base"/>
<field name="arch" type="xml">
<form string="Overdue Payment Report Message">
<field name="company_id" select="1" on_change="onchange_company_id(company_id)" groups="base.group_multi_company"/>
<data>
<form position="attributes"><attribute name="string">
Overdue Payment Report Message
</attribute></form>
<group string="res_config_contents" position="replace">
<field name="company_id" select="1"
on_change="onchange_company_id(company_id)"
groups="base.group_multi_company"/>
<field name="partner_id" select="1" readonly="1"/>
<separator string="Message" colspan="4"/>
<field name="overdue_msg" nolabel="1" colspan="4"/>
<group col="2" colspan="4">
<button icon="gtk-cancel" special="cancel" type="object" name="action_cancel" string="Cancel"/>
<button icon="gtk-ok" name="action_create" string="Create" type="object"/>
</group>
</form>
</group>
</data>
</field>
</record>
@ -40,6 +44,7 @@
<field name="name">Overdue Payment Report Message</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">wizard.company.setup</field>
<field name="view_id" ref="wizard_company_setup_form"/>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
@ -48,8 +53,6 @@
<!-- register configuration wizard -->
<record id="config_wizard_account_base_setup_form" model="ir.actions.todo">
<field name="name">Overdue Payment Report Message</field>
<field name="note">Specify The Message for the Overdue Payment Report.</field>
<field name="action_id" ref="action_wizard_company_setup_form"/>
</record>
</data>