summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2018-05-18 10:49:07 +0200
committerGéry Debongnie <ged@odoo.com>2018-05-22 09:39:41 +0200
commitb709e22fa2911b7a2ffd8efda7e00845a887a03d (patch)
tree93eef049d1d0d2925343a655d96153703485c5fe /addons
parentb658aeb3b70c1047737294bfaf0c0ac60729f0c0 (diff)
[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.
Diffstat (limited to 'addons')
-rw-r--r--addons/project/models/project.py6
-rw-r--r--addons/project/views/project_views.xml4
2 files changed, 9 insertions, 1 deletions
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 @@
</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>