From fbb5eea4ba6278b8910f73e20dff2922ff40d236 Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Thu, 20 Mar 2014 15:16:14 +0530 Subject: [PATCH] [IMP] convert button into stat button for project bzr revid: rajmyt@gmail.com-20140320094614-53ix0c0fdgrzbmsc --- addons/project/project.py | 35 +++++++++++-------- addons/project/project_view.xml | 11 ++++-- addons/project_issue/project_issue.py | 27 ++++++++------ addons/project_issue/project_issue_view.xml | 5 ++- .../project_long_term_view.xml | 7 ++-- .../project_timesheet_view.xml | 5 ++- 6 files changed, 56 insertions(+), 34 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index e5dcf5de2cf..ee6390e4b87 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -187,19 +187,23 @@ class project(osv.osv): res[id] = (project_attachments or 0) + (task_attachments or 0) return res - def _task_count(self, cr, uid, ids, field_name, arg, context=None): - """ :deprecated: this method will be removed with OpenERP v8. Use task_ids - fields instead. """ - if context is None: - context = {} - res = dict.fromkeys(ids, 0) - ctx = context.copy() - ctx['active_test'] = False - task_ids = self.pool.get('project.task').search(cr, uid, [('project_id', 'in', ids)], context=ctx) - for task in self.pool.get('project.task').browse(cr, uid, task_ids, context): - res[task.project_id.id] += 1 +# def _task_count(self, cr, uid, ids, field_name, arg, context=None): +# """ :deprecated: this method will be removed with OpenERP v8. Use task_ids +# fields instead. """ +# if context is None: +# context = {} +# res = dict.fromkeys(ids, 0) +# ctx = context.copy() +# ctx['active_test'] = False +# task_ids = self.pool.get('project.task').search(cr, uid, [('project_id', 'in', ids)], context=ctx) +# for task in self.pool.get('project.task').browse(cr, uid, task_ids, context): +# res[task.project_id.id] += 1 +# return res + def _total_task_count(self, cr, uid, ids, field_name, arg, context=None): + res={} + for tasks in self.browse(cr, uid, ids, context): + res[tasks.id] = len(tasks.task_ids) return res - def _get_alias_models(self, cr, uid, context=None): """ Overriden in project_issue to offer more options """ return [('project.task', "Tasks")] @@ -265,8 +269,8 @@ class project(osv.osv): }), 'resource_calendar_id': fields.many2one('resource.calendar', 'Working Time', help="Timetable working hours to adjust the gantt diagram report", states={'close':[('readonly',True)]} ), 'type_ids': fields.many2many('project.task.type', 'project_task_type_rel', 'project_id', 'type_id', 'Tasks Stages', states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}), - 'task_count': fields.function(_task_count, type='integer', string="Open Tasks", - deprecated="This field will be removed in OpenERP v8. Use task_ids one2many field instead."), +# 'task_count': fields.function(_task_count, type='integer', string="Open Tasks", +# deprecated="This field will be removed in OpenERP v8. Use task_ids one2many field instead."), 'task_ids': fields.one2many('project.task', 'project_id', domain=[('stage_id.fold', '=', False)]), 'color': fields.integer('Color Index'), @@ -287,7 +291,8 @@ class project(osv.osv): "- Followers Only: employees see only the followed tasks or issues; if portal\n" " is activated, portal users see the followed tasks or issues."), 'state': fields.selection([('template', 'Template'),('draft','New'),('open','In Progress'), ('cancelled', 'Cancelled'),('pending','Pending'),('close','Closed')], 'Status', required=True,), - 'doc_count':fields.function(_get_attached_docs, string="Number of documents attached", type='int') + 'doc_count':fields.function(_get_attached_docs, string="Number of documents attached", type='int'), + 'total_task_count': fields.function(_total_task_count, string="Task", type='integer'), } def _get_type_common(self, cr, uid, context): diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index 08738227f5a..45fe175f515 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -93,8 +93,13 @@
- - +
@@ -238,7 +243,7 @@ - + diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index 6f072f5abd1..69ceb7839ca 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -490,22 +490,27 @@ class project(osv.Model): def _get_alias_models(self, cr, uid, context=None): return [('project.task', "Tasks"), ("project.issue", "Issues")] - def _issue_count(self, cr, uid, ids, field_name, arg, context=None): - """ :deprecated: this method will be removed with OpenERP v8. Use issue_ids - fields instead. """ - res = dict.fromkeys(ids, 0) - issue_ids = self.pool.get('project.issue').search(cr, uid, [('project_id', 'in', ids)]) - for issue in self.pool.get('project.issue').browse(cr, uid, issue_ids, context): - if issue.stage_id and not issue.stage_id.fold: - res[issue.project_id.id] += 1 +# def _issue_count(self, cr, uid, ids, field_name, arg, context=None): +# """ :deprecated: this method will be removed with OpenERP v8. Use issue_ids +# fields instead. """ +# res = dict.fromkeys(ids, 0) +# issue_ids = self.pool.get('project.issue').search(cr, uid, [('project_id', 'in', ids)]) +# for issue in self.pool.get('project.issue').browse(cr, uid, issue_ids, context): +# if issue.stage_id and not issue.stage_id.fold: +# res[issue.project_id.id] += 1 +# return res + def _total_issue_count(self, cr, uid, ids, field_name, arg, context=None): + res={} + for issues in self.browse(cr, uid, ids, context): + res[issues.id] = len(issues.issue_ids) return res - _columns = { 'project_escalation_id': fields.many2one('project.project', 'Project Escalation', help='If any issue is escalated from the current Project, it will be listed under the project selected here.', states={'close': [('readonly', True)], 'cancelled': [('readonly', True)]}), - 'issue_count': fields.function(_issue_count, type='integer', string="Unclosed Issues", - deprecated="This field will be removed in OpenERP v8. Use issue_ids one2many field instead."), +# 'issue_count': fields.function(_issue_count, type='integer', string="Unclosed Issues", +# deprecated="This field will be removed in OpenERP v8. Use issue_ids one2many field instead."), + 'total_issue_count': fields.function(_total_issue_count, string="Issue", type='integer'), 'issue_ids': fields.one2many('project.issue', 'project_id', domain=[('stage_id.fold', '=', False)]) } diff --git a/addons/project_issue/project_issue_view.xml b/addons/project_issue/project_issue_view.xml index 3af9ee608d6..2b2c48519f9 100644 --- a/addons/project_issue/project_issue_view.xml +++ b/addons/project_issue/project_issue_view.xml @@ -306,7 +306,10 @@ diff --git a/addons/project_timesheet/project_timesheet_view.xml b/addons/project_timesheet/project_timesheet_view.xml index 548264eb07b..a51c7976602 100644 --- a/addons/project_timesheet/project_timesheet_view.xml +++ b/addons/project_timesheet/project_timesheet_view.xml @@ -30,7 +30,10 @@