From 867f2fc8774b0a33a37cfe758ca57f59a9cb910f Mon Sep 17 00:00:00 2001 From: ced <> Date: Fri, 25 May 2007 13:54:46 +0000 Subject: [PATCH] CLIENT,SERVER: switch default act_window to tree,form bzr revid: ced-d0688044d73f6ed9754497b0497d0f4a1aaf77db --- bin/addons/base/ir/ir_actions.py | 12 +++++++++++- bin/tools/convert.py | 10 ++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/bin/addons/base/ir/ir_actions.py b/bin/addons/base/ir/ir_actions.py index 1299bff09cf..db1c461d604 100644 --- a/bin/addons/base/ir/ir_actions.py +++ b/bin/addons/base/ir/ir_actions.py @@ -111,6 +111,16 @@ class act_window(osv.osv): res={} for act in self.browse(cr, uid, ids): res[act.id]=[(view.view_id.id, view.view_mode) for view in act.view_ids] + if (not act.view_ids) and act.view_id.id: + modes = act.view_mode.split(',') + if act.view_id.type <> modes[0]: + res[act.id].append((act.view_id.id, act.view_id.type)) + find = False + for t in modes: + if t == act.view_id.type and not find: + find = True + continue + res[act.id].append((False, t)) return res _columns = { @@ -130,7 +140,7 @@ class act_window(osv.osv): _defaults = { 'type': lambda *a: 'ir.actions.act_window', 'view_type': lambda *a: 'form', - 'view_mode': lambda *a: 'form,tree', + 'view_mode': lambda *a: 'tree,form', 'context': lambda *a: '{}' } act_window() diff --git a/bin/tools/convert.py b/bin/tools/convert.py index 0b6e08b4f73..d5453d401f4 100644 --- a/bin/tools/convert.py +++ b/bin/tools/convert.py @@ -251,8 +251,14 @@ class xml_import(object): values['icon'] = icons.get(a_type,'STOCK_NEW') if a_type=='act_window': a_id = self.id_get(cr, 'ir.actions.%s'% a_type, a_action) - cr.execute('select view_type,view_mode,name from ir_act_window where id=%d', (int(a_id),)) - action_type,action_mode,action_name = cr.fetchone() + cr.execute('select view_type,view_mode,name,view_id from ir_act_window where id=%d', (int(a_id),)) + action_type,action_mode,action_name,view_id = cr.fetchone() + if view_id: + cr.execute('SELECT type FROM ir_ui_view WHERE id=%d', (int(view_id),)) + action_mode, = cr.fetchone() + cr.execute('SELECT view_mode FROM ir_act_window_view WHERE view_id=%d ORDER BY sequence LIMIT 1', (int(a_id),)) + if cr.rowcount: + action_mode, = cr.fetchone() if action_type=='tree': values['icon'] = 'STOCK_INDENT' elif action_mode and action_mode.startswith('tree'):