diff --git a/addons/project/project.py b/addons/project/project.py index 79f9c712b04..9173318366e 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -44,10 +44,6 @@ class project_task_type(osv.osv): 'fold': fields.boolean('Folded in Kanban View', help='This stage is folded in the kanban view when' 'there are no records in that stage to display.'), - 'closed': fields.boolean('Closing Stage', - help='Indicates whether this field is the end of' - 'the maangement process. This is for example a' - 'stage considering the record as done or canceled.'), } _defaults = { @@ -271,7 +267,7 @@ class project(osv.osv): '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.closed', '=', False)]), + domain=[('stage_id.fold', '=', False)]), 'color': fields.integer('Color Index'), 'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="restrict", required=True, help="Internal email associated with this project. Incoming emails are automatically synchronized" @@ -563,8 +559,9 @@ class task(osv.osv): _mail_post_access = 'read' _track = { 'stage_id': { - 'project.mt_task_new': lambda self, cr, uid, obj, ctx=None: obj.stage_id and obj.stage_id.sequence == 1, - 'project.mt_task_stage': lambda self, cr, uid, obj, ctx=None: obj.stage_id.sequence != 1, + # this is only an heuristics; depending on your particular stage configuration it may not match all 'new' stages + 'project.mt_task_new': lambda self, cr, uid, obj, ctx=None: obj.stage_id and obj.stage_id.sequence <= 1, + 'project.mt_task_stage': lambda self, cr, uid, obj, ctx=None: obj.stage_id.sequence > 1, }, 'user_id': { 'project.mt_task_assigned': lambda self, cr, uid, obj, ctx=None: obj.user_id and obj.user_id.id, @@ -589,7 +586,7 @@ class task(osv.osv): def _get_default_stage_id(self, cr, uid, context=None): """ Gives default stage_id """ project_id = self._get_default_project_id(cr, uid, context=context) - return self.stage_find(cr, uid, [], project_id, [('sequence', '=', '1')], context=context) + return self.stage_find(cr, uid, [], project_id, [('fold', '=', False)], context=context) def _resolve_project_id_from_context(self, cr, uid, context=None): """ Returns ID of project based on the value of 'default_project_id' @@ -1001,7 +998,7 @@ class task(osv.osv): def set_remaining_time(self, cr, uid, ids, remaining_time=1.0, context=None): for task in self.browse(cr, uid, ids, context=context): - if (task.stage_id and task.stage_id.sequence == 1) or (task.planned_hours == 0.0): + if (task.stage_id and task.stage_id.sequence <= 1) or (task.planned_hours == 0.0): self.write(cr, uid, [task.id], {'planned_hours': remaining_time}, context=context) self.write(cr, uid, ids, {'remaining_hours': remaining_time}, context=context) return True diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index eef2701105b..d5e6a216149 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -19,7 +19,7 @@ - + @@ -687,11 +687,10 @@ - + - diff --git a/addons/project/report/project_report.py b/addons/project/report/project_report.py index 15b26507ff3..62dea81ac56 100644 --- a/addons/project/report/project_report.py +++ b/addons/project/report/project_report.py @@ -75,7 +75,7 @@ class report_project_task_user(osv.osv): date_trunc('day',t.date_last_stage_update) as date_last_stage_update, to_date(to_char(t.date_deadline, 'dd-MM-YYYY'),'dd-MM-YYYY') as date_deadline, -- sum(cast(to_char(date_trunc('day',t.date_end) - date_trunc('day',t.date_start),'DD') as int)) as no_of_days, - abs((extract('epoch' from (t.date_end-t.date_start)))/(3600*24)) as no_of_days, + abs((extract('epoch' from (t.write_date-t.date_start)))/(3600*24)) as no_of_days, t.user_id, progress as progress, t.project_id, @@ -89,9 +89,9 @@ class report_project_task_user(osv.osv): total_hours as total_hours, t.delay_hours as hours_delay, planned_hours as hours_planned, - (extract('epoch' from (t.date_end-t.create_date)))/(3600*24) as closing_days, + (extract('epoch' from (t.write_date-t.create_date)))/(3600*24) as closing_days, (extract('epoch' from (t.date_start-t.create_date)))/(3600*24) as opening_days, - abs((extract('epoch' from (t.date_deadline-t.date_end)))/(3600*24)) as delay_endings_days + abs((extract('epoch' from (t.date_deadline-t.write_date)))/(3600*24)) as delay_endings_days FROM project_task t WHERE t.active = 'true' GROUP BY diff --git a/addons/project/report/project_report.xml b/addons/project/report/project_report.xml index 59d0fd28220..4ff7e852620 100644 --- a/addons/project/report/project_report.xml +++ b/addons/project/report/project_report.xml @@ -17,7 +17,6 @@ - diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index 1cbecbac93c..25bd35ccdb7 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -586,7 +586,7 @@ class project(osv.Model): '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_ids': fields.one2many('project.issue', 'project_id', - domain=[('stage_id.closed', '=', False)]) + domain=[('stage_id.fold', '=', False)]) } def _check_escalation(self, cr, uid, ids, context=None): diff --git a/addons/project_mrp/project_mrp.py b/addons/project_mrp/project_mrp.py index fbbba711b4c..d7880ba90cd 100644 --- a/addons/project_mrp/project_mrp.py +++ b/addons/project_mrp/project_mrp.py @@ -23,6 +23,22 @@ from openerp.osv import fields, osv from openerp import netsvc +class ProjectTaskStageMrp(osv.Model): + """ Override project.task.type model to add a 'closed' boolean field allowing + to know that tasks in this stage are considered as closed. Indeed since + OpenERP 8.0 status is not present on tasks anymore, only stage_id. """ + _name = 'project.task.type' + _inherit = 'project.task.type' + + _columns = { + 'closed': fields.boolean('Close', help="Tasks in this stage are considered as closed."), + } + + _defaults = { + 'closed': False, + } + + class project_task(osv.osv): _name = "project.task" _inherit = "project.task"