[FIX] Raise a detailed exception if the record does not exist in the ir_model_data object
bzr revid: ach@tinyerp.com-20100511115355-9kdfpqaupsb718jj
This commit is contained in:
parent
2d69e871a3
commit
d05d9bccc4
|
@ -455,7 +455,7 @@ class ir_model_data(osv.osv):
|
||||||
def _get_id(self, cr, uid, module, xml_id):
|
def _get_id(self, cr, uid, module, xml_id):
|
||||||
ids = self.search(cr, uid, [('module','=',module),('name','=', xml_id)])
|
ids = self.search(cr, uid, [('module','=',module),('name','=', xml_id)])
|
||||||
if not ids:
|
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
|
# the sql constraints ensure us we have only one result
|
||||||
return ids[0]
|
return ids[0]
|
||||||
|
|
||||||
|
|
|
@ -786,12 +786,12 @@ class orm_template(object):
|
||||||
module, xml_id = line[i].rsplit('.', 1)
|
module, xml_id = line[i].rsplit('.', 1)
|
||||||
else:
|
else:
|
||||||
module, xml_id = current_module, line[i]
|
module, xml_id = current_module, line[i]
|
||||||
id = ir_model_data_obj._get_id(cr, uid, module, xml_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'])
|
||||||
res_res_id = ir_model_data_obj.read(cr, uid, [id],
|
if ir_model_data:
|
||||||
['res_id'])
|
res_id = ir_model_data[0]['res_id']
|
||||||
if res_res_id:
|
else:
|
||||||
res_id = res_res_id[0]['res_id']
|
raise ValueError('No references to %s.%s' % (module, xml_id))
|
||||||
row[field[-1][:-3]] = res_id or False
|
row[field[-1][:-3]] = res_id or False
|
||||||
continue
|
continue
|
||||||
if (len(field) == len(prefix)+1) and \
|
if (len(field) == len(prefix)+1) and \
|
||||||
|
|
Loading…
Reference in New Issue