[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): class account_config_wizard(osv.osv_memory):
_name = 'account.config.wizard' _name = 'account.config.wizard'
_inherit = 'res.config'
def _get_charts(self, cr, uid, context): def _get_charts(self, cr, uid, context):
module_obj=self.pool.get('ir.module.module') 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'), 'date2': lambda *a: time.strftime('%Y-12-31'),
'period':lambda *a:'month', '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): def install_account_chart(self, cr, uid, ids, context=None):
for res in self.read(cr,uid,ids): for res in self.read(cr,uid,ids):
chart_id = res['charts'] chart_id = res['charts']
@ -1750,7 +1742,7 @@ class account_config_wizard(osv.osv_memory):
cr.commit() cr.commit()
db, pool = pooler.restart_pool(cr.dbname, update_module=True) 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): for res in self.read(cr,uid,ids):
if 'date1' in res and 'date2' in res: if 'date1' in res and 'date2' in res:
res_obj = self.pool.get('account.fiscalyear') res_obj = self.pool.get('account.fiscalyear')
@ -1769,16 +1761,6 @@ class account_config_wizard(osv.osv_memory):
elif res['period']=='3months': elif res['period']=='3months':
res_obj.create_period3(cr,uid,[new_id]) res_obj.create_period3(cr,uid,[new_id])
self.install_account_chart(cr,uid,ids) 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() account_config_wizard()
@ -2117,6 +2099,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
* generates all accounting properties and assigns them correctly * generates all accounting properties and assigns them correctly
""" """
_name='wizard.multi.charts.accounts' _name='wizard.multi.charts.accounts'
_inherit = 'res.config'
_columns = { _columns = {
'company_id':fields.many2one('res.company','Company',required=True), '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, '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_multi = self.browse(cr,uid,ids[0])
obj_acc = self.pool.get('account.account') obj_acc = self.pool.get('account.account')
obj_acc_tax = self.pool.get('account.tax') obj_acc_tax = self.pool.get('account.tax')
@ -2400,24 +2383,6 @@ class wizard_multi_charts_accounts(osv.osv_memory):
'position_id' : new_fp, 'position_id' : new_fp,
} }
obj_ac_fp.create(cr, uid, vals_acc) 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() wizard_multi_charts_accounts()
class account_bank_accounts_wizard(osv.osv_memory): class account_bank_accounts_wizard(osv.osv_memory):

View File

@ -1447,8 +1447,13 @@
<field name="name">Account Configure wizard</field> <field name="name">Account Configure wizard</field>
<field name="model">account.config.wizard</field> <field name="model">account.config.wizard</field>
<field name="type">form</field> <field name="type">form</field>
<field name="inherit_id" ref="base.res_config_view_base"/>
<field name="arch" type="xml"> <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"/> <separator col="4" colspan="4" string="Create a Fiscal Year"/>
<field name="name"/> <field name="name"/>
<field name="code"/> <field name="code"/>
@ -1457,13 +1462,8 @@
<field name="period" colspan="4"/> <field name="period" colspan="4"/>
<separator col="4" colspan="4" string="Select Chart of Accounts"/> <separator col="4" colspan="4" string="Select Chart of Accounts"/>
<field name="charts"/> <field name="charts"/>
<separator string="" colspan="4"/> </group>
<label string="" colspan="2"/> </data>
<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>
</field> </field>
</record> </record>
@ -1471,6 +1471,7 @@
<field name="name">Account Configure Wizard </field> <field name="name">Account Configure Wizard </field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name="res_model">account.config.wizard</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_type">form</field>
<field name="view_mode">form</field> <field name="view_mode">form</field>
<field name="target">new</field> <field name="target">new</field>
@ -1478,8 +1479,6 @@
<!-- register configuration wizard --> <!-- register configuration wizard -->
<record id="config_fiscalyear" model="ir.actions.todo"> <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"/> <field name="action_id" ref="action_account_config_wizard_form"/>
</record> </record>
@ -1728,31 +1727,37 @@
<field name="name">Generate Chart of Accounts from a Chart Template</field> <field name="name">Generate Chart of Accounts from a Chart Template</field>
<field name="model">wizard.multi.charts.accounts</field> <field name="model">wizard.multi.charts.accounts</field>
<field name="type">form</field> <field name="type">form</field>
<field name="inherit_id" ref="base.res_config_view_base"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Generate Chart of Accounts from a Chart Template"> <data>
<separator col="4" colspan="4" string="Generate Chart of Accounts from a Chart Template"/> <form position="attributes"><attribute name="string">
<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"/> Generate Chart of Accounts from a Chart Template
<field name="company_id" widget="selection" groups="base.group_multi_company"/> </attribute></form>
<field name ="code_digits" /> <group string="res_config_contents" position="replace">
<field name="chart_template_id"/> <separator col="4" colspan="4" string="
<field name ="seq_journal" /> Generate Chart of Accounts from a Chart Template"/>
<field colspan="4" mode="tree" name="bank_accounts_id" nolabel="1" widget="one2many_list"> <label align="0.0" colspan="4" string="
<form string="Bank Information"> This will automatically configure your chart of accounts,
<field name="acc_no"/> bank accounts, taxes and journals according to the selected
<field name="currency_id"/> template"/>
</form> <field name="company_id" widget="selection"
<tree editable="bottom" string="Bank Information"> groups="base.group_multi_company"/>
<field name="acc_no"/> <field name ="code_digits" />
<field name="currency_id"/> <field name="chart_template_id"/>
</tree> <field name ="seq_journal" />
</field> <field colspan="4" mode="tree" name="bank_accounts_id"
<separator string="" colspan="4"/> nolabel="1" widget="one2many_list">
<label string="" colspan="2"/> <form string="Bank Information">
<group col="2" colspan="2"> <field name="acc_no"/>
<button icon="gtk-cancel" special="cancel" type="object" name="action_cancel" string="Cancel"/> <field name="currency_id"/>
<button icon="gtk-ok" name="action_create" string="Create" type="object"/> </form>
</group> <tree editable="bottom" string="Bank Information">
</form> <field name="acc_no"/>
<field name="currency_id"/>
</tree>
</field>
</group>
</data>
</field> </field>
</record> </record>
@ -1760,6 +1765,7 @@
<field name="name">Generate Chart of Accounts from a Chart Template</field> <field name="name">Generate Chart of Accounts from a Chart Template</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name="res_model">wizard.multi.charts.accounts</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_type">form</field>
<field name="view_mode">form</field> <field name="view_mode">form</field>
<field name="target">new</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. * Insert a suitable message for Overdue Payment Report.
""" """
_name='wizard.company.setup' _name='wizard.company.setup'
_inherit = 'res.config'
_columns = { _columns = {
'company_id':fields.many2one('res.company','Company',required=True), 'company_id':fields.many2one('res.company','Company',required=True),
@ -72,27 +73,9 @@ class company_setup(osv.osv_memory):
return {'value': res } 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']) content_wiz = self.pool.get('wizard.company.setup').read(cr,uid,ids,['company_id','overdue_msg'])
if content_wiz: if content_wiz:
wiz_data = content_wiz[0] wiz_data = content_wiz[0]
self.pool.get('res.company').write(cr, uid, [wiz_data['company_id']], {'overdue_msg':wiz_data['overdue_msg']}) 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() company_setup()

View File

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