[IMP]optimized code for name_get method
authorJitendra Prajapati (OpenERP) <jpr@tinyerp.com>
Thu, 3 Apr 2014 11:14:45 +0000 (16:44 +0530)
committerJitendra Prajapati (OpenERP) <jpr@tinyerp.com>
Thu, 3 Apr 2014 11:14:45 +0000 (16:44 +0530)
bzr revid: jpr@tinyerp.com-20140403111445-lej57pocr2d0qokm

openerp/addons/base/ir/ir_actions.py
openerp/addons/base/ir/ir_config_parameter.py
openerp/addons/base/ir/ir_ui_view.py
openerp/addons/base/res/ir_property.py
openerp/addons/base/workflow/workflow.py

index 41d076a..e71496d 100644 (file)
@@ -1051,7 +1051,9 @@ Launch Manually Once: after having been launched manually, it sets automatically
     _order="sequence,id"
 
     def name_get(self, cr, uid, ids, context=None):
-        return [(action["id"], "%s" % (action['action_id'][1])) for action in self.read(cr, uid, ids, ['action_id'], context=context)]
+        if not ids:
+            return []
+        return [(rec.id, rec.action_id.name) for rec in self.browse(cr, uid, ids, context=context)]
 
     def action_launch(self, cr, uid, ids, context=None):
         """ Launch Action of Wizard"""
index 6c7eb53..dd6b972 100644 (file)
@@ -53,7 +53,7 @@ class ir_config_parameter(osv.osv):
     ]
 
     def name_get(self, cr, uid, ids, context=None):
-        return [(sys_para["id"], "%s" % (sys_para['key'])) for sys_para in self.read(cr, uid, ids, ['key'], context=context)]
+        return [(sys_para.id, "%s" % (sys_para.key)) for sys_para in self.browse(cr, uid, ids, context=context)]
 
     def init(self, cr, force=False):
         """
index 360c5e3..3795fa9 100644 (file)
@@ -64,6 +64,11 @@ class view_custom(osv.osv):
         'arch': fields.text('View Architecture', required=True),
     }
 
+    def name_get(self, cr, uid, ids, context=None):
+        if not ids:
+            return []
+        return [(rec.id, rec.user_id.name) for rec in self.browse(cr, uid, ids, context=context)]
+
     def _auto_init(self, cr, context=None):
         super(view_custom, self)._auto_init(cr, context)
         cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'ir_ui_view_custom_user_id_ref_id\'')
index fd41a74..6d7c611 100644 (file)
@@ -114,7 +114,9 @@ class ir_property(osv.osv):
         return values
 
     def name_get(self, cr, uid, ids, context=None):
-        return [(ir_property["id"], "%s" % (ir_property['name'] or ir_property['fields_id'][1])) for ir_property in self.read(cr, uid, ids, ['fields_id','name'], context=context)]
+        if not ids:
+            return []
+        return [(rec.id, rec.name or rec.fields_id.field_description) for rec in self.browse(cr, uid, ids, context=context)]
 
     def write(self, cr, uid, ids, values, context=None):
         return super(ir_property, self).write(cr, uid, ids, self._update_values(cr, uid, ids, values), context=context)
index ba25921..eb50fe5 100644 (file)
@@ -127,8 +127,7 @@ class wkf_transition(osv.osv):
     def name_get(self, cr, uid, ids, context=None):
         if not ids:
             return []
-        line = self.browse(cr, uid, ids, context=context)
-        return [(line.id, (line.act_from.name) + '+' + (line.act_to.name)) if line.signal == False else (line.id, line.signal) for line in line]
+        return [(line.id, (line.act_from.name) + '+' + (line.act_to.name)) if line.signal == False else (line.id, line.signal) for line in self.browse(cr, uid, ids, context=context)]
 
 wkf_transition()