[REF] account: clean code on installer.py
bzr revid: psi@tinyerp.co.in-20101020051353-2lnm99j3htjktqjt
This commit is contained in:
parent
c733ad0139
commit
3f9b1be31c
|
@ -42,7 +42,7 @@ class account_installer(osv.osv_memory):
|
|||
|
||||
def _get_charts(self, cr, uid, context=None):
|
||||
modules = self.pool.get('ir.module.module')
|
||||
ids = modules.search(cr, uid, [('category_id','=','Account Charts')])
|
||||
ids = modules.search(cr, uid, [('category_id', '=', 'Account Charts')], context=context)
|
||||
charts = list(
|
||||
sorted(((m.name, m.shortdesc)
|
||||
for m in modules.browse(cr, uid, ids)),
|
||||
|
@ -75,21 +75,21 @@ class account_installer(osv.osv_memory):
|
|||
def _get_default_charts(self, cr, uid, context=None):
|
||||
module_name = False
|
||||
company_id = self._default_company(cr, uid, context=context)
|
||||
company = self.pool.get('res.company').browse(cr, uid, company_id)
|
||||
company = self.pool.get('res.company').browse(cr, uid, company_id, context=context)
|
||||
address_id = self.pool.get('res.partner').address_get(cr, uid, [company.partner_id.id])
|
||||
if address_id['default']:
|
||||
address = self.pool.get('res.partner.address').browse(cr, uid, address_id['default'])
|
||||
address = self.pool.get('res.partner.address').browse(cr, uid, address_id['default'], context=context)
|
||||
code = address.country_id.code
|
||||
module_name = (code and 'l10n_' + code.lower()) or False
|
||||
if module_name:
|
||||
module_id = self.pool.get('ir.module.module').search(cr, uid, [('name', '=', module_name)])
|
||||
module_id = self.pool.get('ir.module.module').search(cr, uid, [('name', '=', module_name)], context=context)
|
||||
if module_id:
|
||||
return module_name
|
||||
return 'configurable'
|
||||
|
||||
_defaults = {
|
||||
'date_start': lambda *a: time.strftime('%Y-01-01'),
|
||||
'date_stop': lambda *a: time.strftime('%Y-12-31'),
|
||||
'date_start': time.strftime('%Y-01-01'),
|
||||
'date_stop': time.strftime('%Y-12-31'),
|
||||
'period': 'month',
|
||||
'sale_tax': 0.0,
|
||||
'purchase_tax': 0.0,
|
||||
|
@ -112,16 +112,19 @@ class account_installer(osv.osv_memory):
|
|||
obj_acc = self.pool.get('account.account')
|
||||
obj_acc_tax = self.pool.get('account.tax')
|
||||
obj_journal = self.pool.get('account.journal')
|
||||
obj_sequence = self.pool.get('ir.sequence')
|
||||
obj_acc_template = self.pool.get('account.account.template')
|
||||
obj_acc_tax_template = self.pool.get('account.tax.code.template')
|
||||
obj_fiscal_position_template = self.pool.get('account.fiscal.position.template')
|
||||
obj_fiscal_position = self.pool.get('account.fiscal.position')
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
analytic_journal_obj = self.pool.get('account.analytic.journal')
|
||||
obj_acc_chart_template = self.pool.get('account.chart.template')
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
obj_sequence = self.pool.get('ir.sequence')
|
||||
|
||||
|
||||
result = mod_obj._get_id(cr, uid, 'account', 'configurable_chart_template')
|
||||
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
|
||||
obj_multi = self.pool.get('account.chart.template').browse(cr, uid, id)
|
||||
id = mod_obj.read(cr, uid, [result], ['res_id'], context=context)[0]['res_id']
|
||||
obj_multi = obj_acc_chart_template.browse(cr, uid, id, context=context)
|
||||
|
||||
record = self.browse(cr, uid, ids, context=context)[0]
|
||||
|
||||
|
@ -141,9 +144,9 @@ class account_installer(osv.osv_memory):
|
|||
todo_dict = {}
|
||||
|
||||
#create all the tax code
|
||||
children_tax_code_template = self.pool.get('account.tax.code.template').search(cr, uid, [('parent_id','child_of',[tax_code_root_id])], order='id')
|
||||
children_tax_code_template = obj_acc_tax_template.search(cr, uid, [('parent_id', 'child_of', [tax_code_root_id])], order='id')
|
||||
children_tax_code_template.sort()
|
||||
for tax_code_template in self.pool.get('account.tax.code.template').browse(cr, uid, children_tax_code_template):
|
||||
for tax_code_template in obj_acc_tax_template.browse(cr, uid, children_tax_code_template):
|
||||
vals={
|
||||
'name': (tax_code_root_id == tax_code_template.id) and company_id.name or tax_code_template.name,
|
||||
'code': tax_code_template.code,
|
||||
|
|
Loading…
Reference in New Issue