[FIX]crm: several calls to _get_id for external id 'categ_phone2' which were not...
authorDenis Ledoux <dle@openerp.com>
Thu, 14 Nov 2013 09:57:21 +0000 (10:57 +0100)
committerDenis Ledoux <dle@openerp.com>
Thu, 14 Nov 2013 09:57:21 +0000 (10:57 +0100)
bzr revid: dle@openerp.com-20131114095721-v22dl5yc8bzhvevf

addons/crm/crm_lead.py
addons/crm/crm_phonecall.py
addons/crm/wizard/crm_opportunity_to_phonecall.py
addons/crm/wizard/crm_phonecall_to_phonecall.py

index 6999666..6ca72fe 100644 (file)
@@ -836,9 +836,11 @@ class crm_lead(base_stage, format_address, osv.osv):
         model_data = self.pool.get('ir.model.data')
         phonecall_dict = {}
         if not categ_id:
-            res_id = model_data._get_id(cr, uid, 'crm', 'categ_phone2')
-            if res_id:
+            try:
+                res_id = model_data._get_id(cr, uid, 'crm', 'categ_phone2')
                 categ_id = model_data.browse(cr, uid, res_id, context=context).res_id
+            except ValueError:
+                pass
         for lead in self.browse(cr, uid, ids, context=context):
             if not section_id:
                 section_id = lead.section_id and lead.section_id.id or False
index 0d7004e..22582f3 100644 (file)
@@ -111,9 +111,11 @@ class crm_phonecall(base_state, osv.osv):
         model_data = self.pool.get('ir.model.data')
         phonecall_dict = {}
         if not categ_id:
-            res_id = model_data._get_id(cr, uid, 'crm', 'categ_phone2')
-            if res_id:
+            try:
+                res_id = model_data._get_id(cr, uid, 'crm', 'categ_phone2')
                 categ_id = model_data.browse(cr, uid, res_id, context=context).res_id
+            except ValueError:
+                pass
         for call in self.browse(cr, uid, ids, context=context):
             if not section_id:
                 section_id = call.section_id and call.section_id.id or False
index ee7ed1f..ec1dfbb 100644 (file)
@@ -34,9 +34,11 @@ class crm_opportunity2phonecall(osv.osv_memory):
         opp_obj = self.pool.get('crm.lead')
         categ_id = False
         data_obj = self.pool.get('ir.model.data')
-        res_id = data_obj._get_id(cr, uid, 'crm', 'categ_phone2')
-        if res_id:
+        try:
+            res_id = data_obj._get_id(cr, uid, 'crm', 'categ_phone2')
             categ_id = data_obj.browse(cr, uid, res_id, context=context).res_id
+        except ValueError:
+            pass
 
         record_ids = context and context.get('active_ids', []) or []
         res = {}
index d0bcd12..c7cdfc3 100644 (file)
@@ -78,9 +78,11 @@ class crm_phonecall2phonecall(osv.osv_memory):
 
             categ_id = False
             data_obj = self.pool.get('ir.model.data')
-            res_id = data_obj._get_id(cr, uid, 'crm', 'categ_phone2')
-            if res_id:
+            try:
+                res_id = data_obj._get_id(cr, uid, 'crm', 'categ_phone2')
                 categ_id = data_obj.browse(cr, uid, res_id, context=context).res_id
+            except ValueError:
+                pass
 
             if 'name' in fields:
                 res.update({'name': phonecall.name})