From f9db5ca5d5222d611af24a1fff4a5df53cc12fa8 Mon Sep 17 00:00:00 2001 From: Felipe Paloschi Date: Mon, 30 Nov 2020 19:20:32 -0300 Subject: [PATCH] Add email notification when assigning a new ticket to a new team --- helpdesk_mgmt/data/helpdesk_data.xml | 14 ++++++++++++++ helpdesk_mgmt/models/helpdesk_ticket.py | 11 +++++++++++ 2 files changed, 25 insertions(+) diff --git a/helpdesk_mgmt/data/helpdesk_data.xml b/helpdesk_mgmt/data/helpdesk_data.xml index 44d381eba3..8cd50bbbc2 100644 --- a/helpdesk_mgmt/data/helpdesk_data.xml +++ b/helpdesk_mgmt/data/helpdesk_data.xml @@ -27,6 +27,20 @@

The ticket ${object.number} has been assigned to you.

+ + Team Ticket Assignment + + ${object.company_id.partner_id.email} + ${object.company_id.name} Team Ticket Assignment (Ref ${object.number or 'n/a' }) + + ${object.partner_id.lang} + +

Hello

+

The ticket ${object.number} has been assigned to your team.

+
+
Helpdesk Closed Ticket Notification Email diff --git a/helpdesk_mgmt/models/helpdesk_ticket.py b/helpdesk_mgmt/models/helpdesk_ticket.py index fc809c1da6..a420276db6 100644 --- a/helpdesk_mgmt/models/helpdesk_ticket.py +++ b/helpdesk_mgmt/models/helpdesk_ticket.py @@ -104,6 +104,13 @@ def _get_new_eid(self): def send_user_mail(self): self.env.ref("helpdesk_mgmt.assignment_email_template").send_mail(self.id) + def send_team_mail(self): + email_values = { + 'recipient_ids': [(4, partner.id) for partner in self.team_id.user_ids.mapped("partner_id")], + 'notification': True, + } + self.env.ref("helpdesk_mgmt.team_assignment_email_template").send_mail(self.id, email_values=email_values) + def assign_to_me(self): self.write({"user_id": self.env.user.id}) @@ -139,6 +146,8 @@ def create(self, vals): # Check if mail to the user has to be sent if vals.get("user_id") and res: res.send_user_mail() + if vals.get("team_id") and res: + res.send_team_mail() return res def copy(self, default=None): @@ -174,6 +183,8 @@ def write(self, vals): for ticket in self: if vals.get("user_id"): ticket.send_user_mail() + if vals.get("team_id"): + ticket.send_team_mail() return res def action_duplicate_tickets(self):