[FIX] Raise a detailed exception if the record does not exist in the ir_model_data...
authorStephane Wirtel <stephane@openerp.com>
Thu, 15 Apr 2010 10:09:21 +0000 (12:09 +0200)
committerStephane Wirtel <stephane@openerp.com>
Thu, 15 Apr 2010 10:09:21 +0000 (12:09 +0200)
lp bug: https://launchpad.net/bugs/552457 fixed

bzr revid: stephane@openerp.com-20100415100921-11bojr0wf3j9327d

bin/addons/base/ir/ir_model.py
bin/osv/orm.py

index c4021b1..97d167c 100644 (file)
@@ -444,7 +444,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]
 
index e42cb21..571ac9e 100644 (file)
@@ -681,9 +681,14 @@ 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_id = ir_model_data_obj.read(cr, uid, [id],
-                                    ['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 \