From b709e22fa2911b7a2ffd8efda7e00845a887a03d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Fri, 18 May 2018 10:49:07 +0200 Subject: [PATCH] [FIX] project: reintroduce subtask_project_id field The subtask_project_id field was removed by task #38498, amongst many other changes. This change makes some workflows much more difficult: for example, using a different project with its own columns is kind of awkward. It requires many more clicks and custom filters to achieve the same result as previously. With this commit, we simply reintroduce the field and use it to set the default project_id of a subtask. --- addons/project/models/project.py | 6 ++++++ addons/project/views/project_views.xml | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/project/models/project.py b/addons/project/models/project.py index e02dcf8fac5..642fb37e62c 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -223,6 +223,9 @@ class Project(models.Model): doc_count = fields.Integer(compute='_compute_attached_docs_count', string="Number of documents attached") date_start = fields.Date(string='Start Date') date = fields.Date(string='Expiration Date', index=True, track_visibility='onchange') + subtask_project_id = fields.Many2one('project.project', string='Sub-task Project', ondelete="restrict", + help="Choosing a sub-tasks project will both enable sub-tasks and set their default project (possibly the project itself)") + # rating fields percentage_satisfaction_task = fields.Integer( compute='_compute_percentage_satisfaction_task', string="Happy % on Task", store=True, default=-1) @@ -299,6 +302,8 @@ class Project(models.Model): # Prevent double project creation self = self.with_context(mail_create_nosubscribe=True) project = super(Project, self).create(vals) + if not vals.get('subtask_project_id'): + project.subtask_project_id = project.id if project.privacy_visibility == 'portal' and project.partner_id: project.message_subscribe(project.partner_id.ids) return project @@ -528,6 +533,7 @@ class Task(models.Model): legend_normal = fields.Char(related='stage_id.legend_normal', string='Kanban Ongoing Explanation', readonly=True, related_sudo=False) parent_id = fields.Many2one('project.task', string='Parent Task', index=True) child_ids = fields.One2many('project.task', 'parent_id', string="Sub-tasks", context={'active_test': False}) + subtask_project_id = fields.Many2one('project.project', related="project_id.subtask_project_id", string='Sub-task Project', readonly=True) subtask_count = fields.Integer("Sub-task count", compute='_compute_subtask_count') email_from = fields.Char(string='Email', help="These people will receive email.", index=True) email_cc = fields.Char(string='Watchers Emails', help="""These email addresses will be added to the CC field of all inbound diff --git a/addons/project/views/project_views.xml b/addons/project/views/project_views.xml index 41dad0fef65..bdc686a873e 100644 --- a/addons/project/views/project_views.xml +++ b/addons/project/views/project_views.xml @@ -140,6 +140,7 @@ + @@ -418,7 +419,7 @@