From d92cb527ae8699d201b6af36d27c24dd25d01bdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 21 Jan 2010 12:07:25 +0100 Subject: [PATCH] Use get_id of ir.model.data --- trytond/ir/module/module.py | 23 ++++++----------------- trytond/res/user.py | 11 +++-------- 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/trytond/ir/module/module.py b/trytond/ir/module/module.py index 9c5e78560f..a014b2a58a 100644 --- a/trytond/ir/module/module.py +++ b/trytond/ir/module/module.py @@ -701,14 +701,9 @@ class ModuleInstallUpgrade(Wizard): def _menu(self, cursor, user, data, context=None): model_data_obj = self.pool.get('ir.model.data') act_window_obj = self.pool.get('ir.action.act_window') - model_data_ids = model_data_obj.search(cursor, user, [ - ('fs_id', '=', 'act_menu_tree'), - ('module', '=', 'ir'), - ('inherit', '=', False), - ], limit=1, context=context) - model_data = model_data_obj.browse(cursor, user, model_data_ids[0], - context=context) - res = act_window_obj.read(cursor, user, model_data.db_id, context=context) + act_window_id = model_data_obj.get_id(cursor, user, 'ir', + 'act_menu_tree', context=context) + res = act_window_obj.read(cursor, user, act_window_id, context=context) return res def _config(self, cursor, user, data, context=None): @@ -736,15 +731,9 @@ class ModuleConfig(Wizard): def _action_open(self, cursor, user, datas, context=None): model_data_obj = self.pool.get('ir.model.data') act_window_obj = self.pool.get('ir.action.act_window') - - model_data_ids = model_data_obj.search(cursor, user, [ - ('fs_id', '=', 'act_module_form'), - ('module', '=', 'ir'), - ('inherit', '=', False), - ], limit=1, context=context) - model_data = model_data_obj.browse(cursor, user, model_data_ids[0], - context=context) - res = act_window_obj.read(cursor, user, model_data.db_id, context=context) + act_window_id = model_data_obj.get_id(cursor, user, 'ir', + 'act_module_form', context=context) + res = act_window_obj.read(cursor, user, act_window_id, context=context) return res ModuleConfig() diff --git a/trytond/res/user.py b/trytond/res/user.py index 4927bf42db..f448e732d5 100644 --- a/trytond/res/user.py +++ b/trytond/res/user.py @@ -310,14 +310,9 @@ class User(ModelSQL, ModelView): if context is None: context = {} - model_data_ids = model_data_obj.search(cursor, user, [ - ('fs_id', '=', 'user_view_form_preferences'), - ('module', '=', 'res'), - ('inherit', '=', False), - ], limit=1, context=context) - model_data = model_data_obj.browse(cursor, user, model_data_ids[0], - context=context) - res = self.fields_view_get(cursor, user, view_id=model_data.db_id, + view_id = model_data_obj.get_id(cursor, user, 'res', + 'user_view_form_preferences') + res = self.fields_view_get(cursor, user, view_id=view_id, context=context) res = copy.deepcopy(res) for field in res['fields']: