Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add email notification when assigning a new ticket to a new team #1

Open
wants to merge 1 commit into
base: 13.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions helpdesk_mgmt/data/helpdesk_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@
<p>The ticket ${object.number} has been assigned to you.</p>
</field>
</record>
<record id="team_assignment_email_template" model="mail.template">
<field name="name">Team Ticket Assignment</field>
<field name="model_id" ref="model_helpdesk_ticket" />
<field name="email_from">${object.company_id.partner_id.email}</field>
<field
name="subject"
>${object.company_id.name} Team Ticket Assignment (Ref ${object.number or 'n/a' })</field>
<field name="auto_delete" eval="True" />
<field name="lang">${object.partner_id.lang}</field>
<field name="body_html" type="xml">
<p>Hello</p>
<p>The ticket ${object.number} has been assigned to your team.</p>
</field>
</record>
<record id="closed_ticket_template" model="mail.template">
<field name="name">Helpdesk Closed Ticket Notification Email</field>
<field name="model_id" ref="helpdesk_mgmt.model_helpdesk_ticket" />
Expand Down
11 changes: 11 additions & 0 deletions helpdesk_mgmt/models/helpdesk_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down