diff options
| author | Jigar Amin - OpenERP <jam@tinyerp.com> | 2011-11-30 16:38:52 +0530 |
|---|---|---|
| committer | Jigar Amin - OpenERP <jam@tinyerp.com> | 2011-11-30 16:38:52 +0530 |
| commit | b839539b83dcc7f2eee9f4885186a64f6fe4e056 (patch) | |
| tree | b78b5fbb183aa0bed33bec294777123799d48532 /addons/project/project.py | |
| parent | 784fed5e4dd4077ed009109aecccf6f2857451a8 (diff) | |
[FIX] ActiveId Ref on New Task When from Project>Tasks act_window and Query Code refectoring
bzr revid: jam@tinyerp.com-20111130110852-ox1y0dfnvvmc44yx
Diffstat (limited to 'addons/project/project.py')
| -rw-r--r-- | addons/project/project.py | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/addons/project/project.py b/addons/project/project.py index 9b588e88659..466c937ac6f 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -109,20 +109,18 @@ class project(osv.osv): parents = self._get_parents(cr, uid, [child[0]], parents,context) return parents + def _get_project(self,cr, ids): + cr.execute('''SELECT project_id, sum(planned_hours), sum(total_hours), sum(effective_hours), SUM(remaining_hours) + FROM project_task WHERE project_id in %s AND state<>'cancelled' + GROUP BY project_id''', (tuple(ids),)) + return cr + def _progress_rate(self, cr, uid, ids, names, arg, context=None): res = {}.fromkeys(ids, 0.0) if not ids: return res parents = self._get_parents(cr, uid, ids, ids,context) - cr.execute('''SELECT - project_id, sum(planned_hours), sum(total_hours), sum(effective_hours), SUM(remaining_hours) - FROM - project_task - WHERE - project_id in %s AND - state<>'cancelled' - GROUP BY - project_id''', (tuple(ids),)) + cr = self._get_project(cr,ids) progress = dict(map(lambda x: (x[0], (x[1] or 0.0 ,x[2] or 0.0 ,x[3] or 0.0 ,x[4] or 0.0)), cr.fetchall())) for project in self.browse(cr, uid, parents, context=context): childs = [] @@ -136,15 +134,7 @@ class project(osv.osv): } if childs: - cr.execute('''SELECT - project_id, sum(planned_hours), sum(total_hours), sum(effective_hours), SUM(remaining_hours) - FROM - project_task - WHERE - project_id in %s AND - state<>'cancelled' - GROUP BY - project_id''', (tuple(childs),)) + cr = self._get_project(cr, childs) child_progress = dict(map(lambda x: (x[0], (x[1] or 0.0 ,x[2] or 0.0 ,x[3] or 0.0 ,x[4] or 0.0)), cr.fetchall())) planned_hours, effective_hours, total_hours, rnd= 0.0, 0.0,0.0, 0.0 for child in childs: @@ -588,8 +578,8 @@ class task(osv.osv): def _default_project(self, cr, uid, context=None): if context is None: context = {} - if 'project_id' in context and context['project_id']: - return int(context['project_id']) + if 'default_project_id' in context and context['default_project_id']: + return int(context['default_project_id']) return False def duplicate_task(self, cr, uid, map_ids, context=None): |
