[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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -140,6 +140,7 @@
|
||||
</div>
|
||||
<field name="rating_status_period" class="oe_inline" attrs="{'required': [('rating_status','=','periodic')], 'invisible': [('rating_status','!=','periodic')]}" groups="project.group_project_rating"/>
|
||||
<field name="portal_show_rating" attrs="{'invisible': [('rating_status','==','no')]}" groups="project.group_project_rating"/>
|
||||
<field name="subtask_project_id" groups="project.group_subtask_project"/>
|
||||
</group>
|
||||
<group name="misc">
|
||||
<group string="Configuration" groups="base.group_no_one">
|
||||
@@ -418,7 +419,7 @@
|
||||
<button class="oe_stat_button" icon="fa-tasks" type="object" name="action_open_parent_task" string="Parent Task" attrs="{'invisible' : [('parent_id', '=', False)]}" groups="project.group_subtask_project"/>
|
||||
<button name="action_subtask" type="object" class="oe_stat_button" icon="fa-tasks"
|
||||
attrs="{'invisible' : [('parent_id', '!=', False)]}"
|
||||
context="{'project_id': project_id, 'name': name, 'parent_id': id}" groups="project.group_subtask_project">
|
||||
context="{'project_id': subtask_project_id, 'name': name, 'partner_id': partner_id}" groups="project.group_subtask_project">
|
||||
<field string="Sub-tasks" name="subtask_count" widget="statinfo"/>
|
||||
</button>
|
||||
<button name="%(rating_rating_action_task)d" type="action" attrs="{'invisible': [('rating_count', '=', 0)]}" class="oe_stat_button" icon="fa-smile-o" groups="project.group_project_rating">
|
||||
@@ -466,6 +467,7 @@
|
||||
<field name="email_cc" groups="base.group_no_one"/>
|
||||
<field name="parent_id" attrs="{'invisible' : [('subtask_count', '>', 0)]}" groups="project.group_subtask_project"/>
|
||||
<field name="child_ids" invisible="1" />
|
||||
<field name="subtask_project_id" invisible="1" />
|
||||
<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>
|
||||
<field name="displayed_image_id" groups="base.group_no_one"/>
|
||||
</group>
|
||||
|
||||
Reference in New Issue
Block a user