[IMP] account: l10n_multilang: 1)Get Default language on Language field 2)onchange on Template at that time languages change accordingly
bzr revid: ron@tinyerp.com-20110722083414-8qzizw2fe1a8rxol
This commit is contained in:
@@ -33,6 +33,38 @@ 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:
|
||||
import os
|
||||
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:
|
||||
po_files = os.listdir(dirpath)
|
||||
for po in po_files:
|
||||
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',
|
||||
|
||||
@@ -14,7 +14,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"/>
|
||||
|
||||
Reference in New Issue
Block a user