[IMP]improve count method of model improve code
bzr revid: sgo@tinyerp.com-20120507100742-gy5e5ur5b93h1zty
This commit is contained in:
@@ -156,12 +156,11 @@ class project(osv.osv):
|
||||
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),
|
||||
|
||||
@@ -518,11 +518,11 @@ class project(osv.osv):
|
||||
_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 = {
|
||||
|
||||
@@ -218,12 +218,12 @@ class project(osv.osv):
|
||||
_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"),
|
||||
|
||||
Reference in New Issue
Block a user