From d05d9bccc4b17053cb0cca927817a9d3364cd8df Mon Sep 17 00:00:00 2001 From: "Anup (OpenERP)" Date: Tue, 11 May 2010 17:23:55 +0530 Subject: [PATCH] [FIX] Raise a detailed exception if the record does not exist in the ir_model_data object bzr revid: ach@tinyerp.com-20100511115355-9kdfpqaupsb718jj --- bin/addons/base/ir/ir_model.py | 2 +- bin/osv/orm.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bin/addons/base/ir/ir_model.py b/bin/addons/base/ir/ir_model.py index ffb2d31b909..c52635e3424 100644 --- a/bin/addons/base/ir/ir_model.py +++ b/bin/addons/base/ir/ir_model.py @@ -455,7 +455,7 @@ class ir_model_data(osv.osv): def _get_id(self, cr, uid, module, xml_id): ids = self.search(cr, uid, [('module','=',module),('name','=', xml_id)]) if not ids: - raise Exception('No references to %s.%s' % (module, xml_id)) + raise ValueError('No references to %s.%s' % (module, xml_id)) # the sql constraints ensure us we have only one result return ids[0] diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 76bca677224..e05f366adc0 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -786,12 +786,12 @@ class orm_template(object): module, xml_id = line[i].rsplit('.', 1) else: module, xml_id = current_module, line[i] - id = ir_model_data_obj._get_id(cr, uid, module, xml_id) - - res_res_id = ir_model_data_obj.read(cr, uid, [id], - ['res_id']) - if res_res_id: - res_id = res_res_id[0]['res_id'] + record_id = ir_model_data_obj._get_id(cr, uid, module, xml_id) + ir_model_data = ir_model_data_obj.read(cr, uid, [record_id], ['res_id']) + if ir_model_data: + res_id = ir_model_data[0]['res_id'] + else: + raise ValueError('No references to %s.%s' % (module, xml_id)) row[field[-1][:-3]] = res_id or False continue if (len(field) == len(prefix)+1) and \