[FIX] account.config.settings: rename wizard, and remove inappropriate code
bzr revid: rco@openerp.com-20120328090510-wra2jmfzgfv0ccz1
This commit is contained in:
parent
aad2bcfaae
commit
aa298f6d9a
|
@ -30,7 +30,7 @@ from osv import osv, fields
|
|||
import tools
|
||||
|
||||
class account_configuration(osv.osv_memory):
|
||||
_name = 'account.installer'
|
||||
_name = 'account.config.settings'
|
||||
_inherit = 'res.config.settings'
|
||||
|
||||
def _get_charts(self, cr, uid, context=None):
|
||||
|
@ -221,35 +221,6 @@ class account_configuration(osv.osv_memory):
|
|||
res.update({'sale_tax_rate': 15.0, 'purchase_tax_rate': 15.0})
|
||||
return res
|
||||
|
||||
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
||||
ir_values_obj = self.pool.get('ir.values')
|
||||
res = super(account_configuration, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu)
|
||||
cmp_select = []
|
||||
# display in the widget selection only the companies that haven't been configured yet
|
||||
unconfigured_cmp = self.get_unconfigured_cmp(cr, uid, context=context)
|
||||
for field in res['fields']:
|
||||
if field == 'company_id':
|
||||
res['fields'][field]['domain'] = [('id','in',unconfigured_cmp)]
|
||||
res['fields'][field]['selection'] = [('', '')]
|
||||
if unconfigured_cmp:
|
||||
cmp_select = [(line.id, line.name) for line in self.pool.get('res.company').browse(cr, uid, unconfigured_cmp)]
|
||||
res['fields'][field]['selection'] = cmp_select
|
||||
return res
|
||||
|
||||
def get_unconfigured_cmp(self, cr, uid, context=None):
|
||||
""" get the list of companies that have not been configured yet
|
||||
but don't care about the demo chart of accounts """
|
||||
cmp_select = []
|
||||
company_ids = self.pool.get('res.company').search(cr, uid, [], context=context)
|
||||
cr.execute("SELECT company_id FROM account_account WHERE active = 't' AND account_account.parent_id IS NULL AND name != %s", ("Chart For Automated Tests",))
|
||||
configured_cmp = [r[0] for r in cr.fetchall()]
|
||||
return list(set(company_ids)-set(configured_cmp))
|
||||
|
||||
def check_unconfigured_cmp(self, cr, uid, context=None):
|
||||
""" check if there are still unconfigured companies """
|
||||
if not self.get_unconfigured_cmp(cr, uid, context=context):
|
||||
raise osv.except_osv(_('No unconfigured company !'), _("There are currently no company without chart of account. The wizard will therefore not be executed."))
|
||||
|
||||
def on_change_start_date(self, cr, uid, id, start_date=False):
|
||||
if start_date:
|
||||
start_date = datetime.datetime.strptime(start_date, "%Y-%m-%d")
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
<record id="view_account_config_settings" model="ir.ui.view">
|
||||
<field name="name">account settings</field>
|
||||
<field name="model">account.installer</field>
|
||||
<field name="model">account.config.settings</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Configure Accounting">
|
||||
|
@ -111,7 +111,7 @@
|
|||
<record id="action_account_config" model="ir.actions.act_window">
|
||||
<field name="name">Configure Accounting</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">account.installer</field>
|
||||
<field name="res_model">account.config.settings</field>
|
||||
<field name="view_mode">form</field>
|
||||
</record>
|
||||
|
||||
|
|
Loading…
Reference in New Issue