Sanjay Gohel (Open ERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-project-gallery-apa-method-improve-sgo 
into lp:~openerp-dev/openobject-addons/trunk-project-gallery-apa.

Requested reviews:
  Amit Patel (OpenERP) (apa-tiny)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-project-gallery-apa-method-improve-sgo/+merge/104883


Hello sir,

 I have change the code of count task,issue and phase and improve code



Thank you
SGO
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-project-gallery-apa-method-improve-sgo/+merge/104883
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-project-gallery-apa.
=== modified file 'project/project.py'
--- project/project.py	2012-05-07 07:20:49 +0000
+++ project/project.py	2012-05-07 10:11:19 +0000
@@ -156,12 +156,11 @@
         return super(project, self).unlink(cr, uid, ids, *args, **kwargs)
     
     def _task_count(self, cr, uid, ids, field_name, arg, context=None):
-        open_task={}
-        task_pool=self.pool.get('project.task')
-        for id in ids:
-            task_ids = task_pool.search(cr, uid, [('project_id', '=', id)])
-            open_task[id] = len(task_ids)
-        return open_task
+        res = dict.fromkeys(ids, 0)
+        task_ids = self.pool.get('project.task').search(cr, uid, [('project_id', 'in', ids)])
+        for task in self.pool.get('project.task').browse(cr, uid, task_ids, context):
+            res[task.project_id.id] += 1
+        return res
     
     _columns = {
         'complete_name': fields.function(_complete_name, string="Project Name", type='char', size=250),

=== modified file 'project_issue/project_issue.py'
--- project_issue/project_issue.py	2012-05-07 07:20:49 +0000
+++ project_issue/project_issue.py	2012-05-07 10:11:19 +0000
@@ -518,11 +518,11 @@
     _inherit = "project.project"
 
     def _issue_count(self, cr, uid, ids, field_name, arg, context=None):
-        res={}
-        issue_pool=self.pool.get('project.issue')
-        for project in self.browse(cr, uid, ids, context=context):
-            issues = issue_pool.search(cr, uid, [('project_id','=',project.id)])
-            res[project.id] = len(issues)
+        res = dict.fromkeys(ids, 0)
+        issue_pool = self.pool.get('project.issue')
+        issue_ids = issue_pool.search(cr, uid, [('project_id', 'in', ids)])
+        for issue in issue_pool.browse(cr, uid, issue_ids, context):
+            res[issue.project_id.id] += 1
         return res
 
     _columns = {

=== modified file 'project_long_term/project_long_term.py'
--- project_long_term/project_long_term.py	2012-05-07 07:20:49 +0000
+++ project_long_term/project_long_term.py	2012-05-07 10:11:19 +0000
@@ -218,12 +218,12 @@
     _inherit = "project.project"
     
     def _phase_count(self, cr, uid, ids, field_name, arg, context=None):
-        open_phase={}
-        phase_pool=self.pool.get('project.phase')
-        for id in ids:
-            phase_ids = phase_pool.search(cr, uid, [('project_id', '=', id)])
-            open_phase[id] = len(phase_ids)
-        return open_phase
+        res = dict.fromkeys(ids, 0)
+        phase_pool = self.pool.get('project.phase')
+        phase_ids = phase_pool.search(cr, uid, [('project_id', 'in', ids)])
+        for phase in phase_pool.browse(cr, uid, phase_ids, context):
+            res[phase.project_id.id] += 1
+        return res
      
     _columns = {
         'phase_ids': fields.one2many('project.phase', 'project_id', "Project Phases"),

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to