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 @@