[IMP] project: hide dependency change subtype if option is disabled

A recent commit allows mail subtypes to be hidden depending on the
record fields. This allows us to hide the dependency changed subtype if
the option is disabled.

Closes odoo/odoo#75749

Task-2628818

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
William Braeckman
2021-08-31 12:43:54 +00:00
parent 014446f84b
commit b74960f571
+18
View File
@@ -558,6 +558,14 @@ class Project(models.Model):
return self.env.ref('project.mt_project_stage_change')
return super()._track_subtype(init_values)
def _mail_get_message_subtypes(self):
res = super()._mail_get_message_subtypes()
if len(self) == 1:
dependency_subtype = self.env.ref('project.mt_project_task_dependency_change')
if not self.allow_task_dependencies and dependency_subtype in res:
res -= dependency_subtype
return res
# ---------------------------------------------------
# Actions
# ---------------------------------------------------
@@ -1644,6 +1652,16 @@ class Task(models.Model):
return self.env.ref('project.mt_task_stage')
return super(Task, self)._track_subtype(init_values)
def _mail_get_message_subtypes(self):
res = super()._mail_get_message_subtypes()
if len(self) == 1:
dependency_subtype = self.env.ref('project.mt_task_dependency_change')
if ((self.project_id and not self.project_id.allow_task_dependencies)\
or (not self.project_id and not self.user_has_groups('project.group_project_task_dependencies')))\
and dependency_subtype in res:
res -= dependency_subtype
return res
def _notify_get_groups(self, msg_vals=None):
""" Handle project users and managers recipients that can assign
tasks and create new one directly from notification emails. Also give