From 9a726504ca557f1c2ed6775a1d99ff8255383ce2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 21 Jan 2010 12:08:03 +0100 Subject: [PATCH] Use get_id of ir.model.data --- account.py | 32 ++++++++------------------------ move.py | 34 +++++++++------------------------- tax.py | 25 ++++++------------------- 3 files changed, 23 insertions(+), 68 deletions(-) diff --git a/account.py b/account.py index 418f36743d..0b0f94d326 100644 --- a/account.py +++ b/account.py @@ -1125,15 +1125,9 @@ class OpenChartAccount(Wizard): def _action_open_chart(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_account_tree2'), - ('module', '=', 'account'), - ('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, 'account', + 'act_account_tree2', context=context) + res = act_window_obj.read(cursor, user, act_window_id, context=context) res['pyson_context'] = PYSONEncoder().encode({ 'fiscalyear': data['form']['fiscalyear'], 'posted': data['form']['posted'], @@ -1598,14 +1592,9 @@ class OpenBalanceSheet(Wizard): date = lang_obj.strftime(datas['form']['date'], lang.code, lang.date) - model_data_ids = model_data_obj.search(cursor, user, [ - ('fs_id', '=', 'act_account_balance_sheet_tree'), - ('module', '=', 'account'), - ('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, 'account', + 'act_account_balance_sheet_tree', context=context) + res = act_window_obj.read(cursor, user, act_window_id, context=context) res['pyson_context'] = PYSONEncoder().encode({ 'date': Date(datas['form']['date'].year, datas['form']['date'].month, @@ -1728,13 +1717,8 @@ class OpenIncomeStatement(Wizard): end_period_ids = list(set(end_period_ids).difference( set(start_period_ids))) - model_data_ids = model_data_obj.search(cursor, user, [ - ('fs_id', '=', 'act_account_income_statement_tree'), - ('module', '=', 'account'), - ('inherit', '=', False), - ], limit=1, context=context) - model_data = model_data_obj.browse(cursor, user, model_data_ids[0], - context=context) + act_window_id = model_data_obj.get_id(cursor, user, 'account', + 'act_account_income_statement_tree', context=context) res = act_window_obj.read(cursor, user, model_data.db_id, context=context) res['pyson_context'] = PYSONEncoder().encode({ 'periods': end_period_ids, diff --git a/move.py b/move.py index cc8cb7de12..3612429491 100644 --- a/move.py +++ b/move.py @@ -1451,14 +1451,9 @@ class OpenJournal(Wizard): 'period': period.id, }, context=context) - model_data_ids = model_data_obj.search(cursor, user, [ - ('fs_id', '=', 'act_move_line_form'), - ('module', '=', 'account'), - ('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, 'account', + 'act_move_line_form', context=context) + res = act_window_obj.read(cursor, user, act_window_id, context=context) # Remove name to use the one from view_header_get del res['name'] res['pyson_domain'] = PYSONEncoder().encode([ @@ -1507,14 +1502,9 @@ class OpenAccount(Wizard): for period in fiscalyear.periods: period_ids.append(period.id) - model_data_ids = model_data_obj.search(cursor, user, [ - ('fs_id', '=', 'act_move_line_form'), - ('module', '=', 'account'), - ('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, 'account', + 'act_move_line_form', context=context) + res = act_window_obj.read(cursor, user, act_window_id, context=context) res['pyson_domain'] = [ ('period', 'in', period_ids), ('account', '=', data['id']), @@ -1692,15 +1682,9 @@ class OpenReconcileLines(Wizard): def _action_open_reconcile_lines(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_move_line_form'), - ('module', '=', 'account'), - ('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, 'account', + 'act_move_line_form', context=context) + res = act_window_obj.read(cursor, user, act_window_id, context=context) res['pyson_domain'] = PYSONEncoder().encode([ ('account', '=', data['form']['account']), ('reconciliation', '=', False), diff --git a/tax.py b/tax.py index ecd3a33e56..9a0922e2b2 100644 --- a/tax.py +++ b/tax.py @@ -366,16 +366,9 @@ class OpenChartCode(Wizard): def _action_open_chart(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_tax_code_tree2'), - ('module', '=', 'account'), - ('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, 'account', + 'act_tax_code_tree2', context=context) + res = act_window_obj.read(cursor, user, act_window_id, context=context) if data['form']['method'] == 'fiscalyear': res['pyson_context'] = PYSONEncoder().encode({ 'fiscalyear': data['form']['fiscalyear'], @@ -1399,15 +1392,9 @@ class OpenCode(Wizard): else: period_ids = context['periods'] - model_data_ids = model_data_obj.search(cursor, user, [ - ('fs_id', '=', 'act_tax_line_form'), - ('module', '=', 'account'), - ('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, 'account', + 'act_tax_line_form', context=context) + res = act_window_obj.read(cursor, user, act_window_id, context=context) res['pyson_domain'] = PYSONEncoder().encode([ ('move_line.period', 'in', period_ids), ('code', '=', data['id']),