[MERGE]: l10n_multilang: Merged improvement in default_get of loading COA template for getting default language
bzr revid: rpa@tinyerp.com-20110722104904-y0fp3lc5j4a97t6n
This commit is contained in:
commit
cfb3e17512
|
@ -19,9 +19,8 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
|
||||
from osv import fields, osv
|
||||
|
||||
import os
|
||||
|
||||
class wizard_multi_charts_accounts(osv.osv_memory):
|
||||
"""
|
||||
|
@ -33,6 +32,36 @@ class wizard_multi_charts_accounts(osv.osv_memory):
|
|||
"""
|
||||
_inherit = 'wizard.multi.charts.accounts'
|
||||
|
||||
def onchange_chart_template_id(self, cr, uid, ids, chart_template_id=False, context=None):
|
||||
res = super(wizard_multi_charts_accounts, self).onchange_chart_template_id(cr, uid, ids, chart_template_id, context=context)
|
||||
installed_lang = self.get_lang(cr, uid, chart_template_id, context=context)
|
||||
res['value'].update({'lang_ids': installed_lang})
|
||||
return res
|
||||
|
||||
def get_lang(self, cr, uid, template_id=False, context=None):
|
||||
installed_lang = []
|
||||
if template_id:
|
||||
cr.execute("SELECT module from ir_model_data where model='account.chart.template' and res_id=%s" % (template_id))
|
||||
modulename = cr.fetchone()
|
||||
modulename = modulename and modulename[0] or False
|
||||
if modulename:
|
||||
module_obj = self.pool.get('ir.module.module')
|
||||
module_id = module_obj.search(cr, uid, [('name', '=', modulename)], context=context)
|
||||
module = module_obj.browse(cr, uid, module_id, context=context)[0]
|
||||
dirpath = module_obj._translations_subdir(module)
|
||||
if dirpath:
|
||||
for po in os.listdir(dirpath):
|
||||
lang_id = self.pool.get('res.lang').search(cr, uid, [('code', 'ilike', '%s' % (po.split('.')[0])), ('translatable', '=', True)], context=context)
|
||||
if lang_id:
|
||||
installed_lang.append(lang_id[0])
|
||||
return installed_lang
|
||||
|
||||
def default_get(self, cr, uid, fields, context=None):
|
||||
res = super(wizard_multi_charts_accounts, self).default_get(cr, uid, fields, context=context)
|
||||
installed_lang = self.get_lang(cr, uid, res.get('chart_template_id'), context=context)
|
||||
res.update({'lang_ids': installed_lang, 'bank_accounts_id': []})
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'lang_ids': fields.many2many('res.lang', 'res_lang_type_rel', 'wizard_id', 'lang_id', 'Language'),
|
||||
'bank_from_template': fields.boolean('Banks/Cash from Template',
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="multi_chart_configuration" model="ir.actions.todo">
|
||||
<field name="action_id" ref="account.action_wizard_multi_chart"/>
|
||||
<field name="sequence">25</field>
|
||||
<field name="restart">onskip</field>
|
||||
</record>
|
||||
<!-- Wizard for Multi Charts of Accounts -->
|
||||
<record id="view_wizard_multi_chart_belgian_coa" model="ir.ui.view">
|
||||
<field name="name">view.wizard.multi.chart</field>
|
||||
|
@ -14,7 +9,7 @@
|
|||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<field name="bank_accounts_id" position="before">
|
||||
<field name="bank_from_template" />
|
||||
<field name="bank_from_template" on_change="onchange_bank_from_template(bank_from_template)" />
|
||||
</field>
|
||||
<field name="bank_accounts_id" position="before">
|
||||
<separator string="Languages" colspan="4"/>
|
||||
|
|
Loading…
Reference in New Issue