[IMP] project: prevent sending of emails when duplicating project or task
After this commit: - When duplicating project or task, assignment notifications and emails on stages are not sent task-2849291 Part-of: odoo/odoo#91174
This commit is contained in:
@@ -610,7 +610,8 @@ class Project(models.Model):
|
||||
default = {}
|
||||
if not default.get('name'):
|
||||
default['name'] = _("%s (copy)") % (self.name)
|
||||
project = super(Project, self).copy(default)
|
||||
self_with_mail_context = self.with_context(mail_auto_subscribe_no_notify=True, mail_create_nosubscribe=True)
|
||||
project = super(Project, self_with_mail_context).copy(default)
|
||||
for follower in self.message_follower_ids:
|
||||
project.message_subscribe(partner_ids=follower.partner_id.ids, subtype_ids=follower.subtype_ids.ids)
|
||||
if 'tasks' not in default:
|
||||
@@ -1726,7 +1727,8 @@ class Task(models.Model):
|
||||
default['recurrence_id'] = self.recurrence_id.copy().id
|
||||
if self.allow_subtasks:
|
||||
default['child_ids'] = [child.copy({'name': child.name} if has_default_name else None).id for child in self.child_ids]
|
||||
task_copy = super(Task, self).copy(default)
|
||||
self_with_mail_context = self.with_context(mail_auto_subscribe_no_notify=True, mail_create_nosubscribe=True)
|
||||
task_copy = super(Task, self_with_mail_context).copy(default)
|
||||
if self.allow_task_dependencies:
|
||||
task_mapping = self.env.context.get('task_mapping')
|
||||
task_mapping[self.id] = task_copy.id
|
||||
@@ -2207,6 +2209,8 @@ class Task(models.Model):
|
||||
|
||||
@api.model
|
||||
def _task_message_auto_subscribe_notify(self, users_per_task):
|
||||
if self.env.context.get('mail_auto_subscribe_no_notify'):
|
||||
return
|
||||
# Utility method to send assignation notification upon writing/creation.
|
||||
template_id = self.env['ir.model.data']._xmlid_to_res_id('project.project_message_user_assigned', raise_if_not_found=False)
|
||||
if not template_id:
|
||||
|
||||
Reference in New Issue
Block a user