[FIX] account: fixed an error when using custom chart of accounts, could lead to...
authorThibault Delavallée <tde@openerp.com>
Fri, 13 Sep 2013 08:25:16 +0000 (10:25 +0200)
committerThibault Delavallée <tde@openerp.com>
Fri, 13 Sep 2013 08:25:16 +0000 (10:25 +0200)
bzr revid: tde@openerp.com-20130913082516-bv8lvmgmyay4o86s

addons/account/account.py

index 0bf8a6e..8cdd37c 100644 (file)
@@ -3122,8 +3122,9 @@ class wizard_multi_charts_accounts(osv.osv_memory):
                 #in order to set default chart which was last created set max of ids.
                 chart_id = max(ids)
                 if context.get("default_charts"):
-                    data_id = data_obj.search(cr, uid, [('model', '=', 'account.chart.template'), ('module', '=', context.get("default_charts"))], context=context)
-                    chart_id = data_obj.browse(cr, uid, data_id[0], context=context).res_id
+                    data_ids = data_obj.search(cr, uid, [('model', '=', 'account.chart.template'), ('module', '=', context.get("default_charts"))], limit=1, context=context)
+                    if data_ids:
+                        chart_id = data_obj.browse(cr, uid, data_ids[0], context=context).res_id
                 res.update({'only_one_chart_template': len(ids) == 1, 'chart_template_id': chart_id})
             if 'sale_tax' in fields:
                 sale_tax_ids = tax_templ_obj.search(cr, uid, [("chart_template_id"