From b74960f57197061925eb2ada5f470372c53b74a7 Mon Sep 17 00:00:00 2001 From: William Braeckman Date: Mon, 30 Aug 2021 14:49:41 +0000 Subject: [PATCH] [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) --- addons/project/models/project.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/addons/project/models/project.py b/addons/project/models/project.py index 8cccd0a6a89..bfa20b1f942 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -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