Skip to content
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
16 changes: 11 additions & 5 deletions helpdesk_mgmt/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

===================
Helpdesk Management
===================
Expand All @@ -17,7 +13,7 @@ Helpdesk Management
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
:target: https://odoo-community.org/page/development-status
:alt: Production/Stable
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fhelpdesk-lightgray.png?logo=github
Expand Down Expand Up @@ -129,6 +125,16 @@ permissions set in Helpdesk.
not assigned to any team nor user.
3. *User*: User is able to see all the tickets.

Customer notifications
----------------------

If you want portal users to receive an email when a ticket is created:

1. Enable debug mode
2. Open the "Ticket Created" subtype in Settings > Technical > Discuss >
Subtypes
3. Enable the ``Default`` flag

.. |image1| image:: https://raw.githubusercontent.com/OCA/helpdesk/18.0/helpdesk_mgmt/static/description/Channels.PNG
.. |image2| image:: https://raw.githubusercontent.com/OCA/helpdesk/18.0/helpdesk_mgmt/static/description/Categories.PNG
.. |image3| image:: https://raw.githubusercontent.com/OCA/helpdesk/18.0/helpdesk_mgmt/static/description/Stages.PNG
Expand Down
10 changes: 6 additions & 4 deletions helpdesk_mgmt/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,17 @@ def _prepare_submit_ticket_vals(self, **kw):
)
)
vals["team_id"] = team.id
# Need to set stage_id so that the _track_template() method is called
# and the mail is sent automatically if applicable
vals["stage_id"] = team._get_applicable_stages()[:1].id
return vals

@http.route("/submitted/ticket", type="http", auth="user", website=True, csrf=True)
def submit_ticket(self, **kw):
vals = self._prepare_submit_ticket_vals(**kw)
new_ticket = request.env["helpdesk.ticket"].sudo().create(vals)
new_ticket = (
request.env["helpdesk.ticket"]
.sudo()
.with_context(mail_notify_author=True)
.create(vals)
)
new_ticket.message_subscribe(partner_ids=request.env.user.partner_id.ids)
if kw.get("attachment"):
for c_file in request.httprequest.files.getlist("attachment"):
Expand Down
2 changes: 0 additions & 2 deletions helpdesk_mgmt/models/helpdesk_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,6 @@ def _track_template(self, tracking):
res["stage_id"] = (
ticket.stage_id.mail_template_id,
{
# Need to set mass_mail so that the email will always be sent
"composition_mode": "mass_mail",
"auto_delete_keep_log": False,
"subtype_id": self.env["ir.model.data"]._xmlid_to_res_id(
"mail.mt_note"
Expand Down
8 changes: 8 additions & 0 deletions helpdesk_mgmt/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,11 @@ permissions set in Helpdesk.
assigned to the teams to which he/she belongs or the tickets that
are not assigned to any team nor user.
3. *User*: User is able to see all the tickets.

## Customer notifications

If you want portal users to receive an email when a ticket is created:

1. Enable debug mode
2. Open the "Ticket Created" subtype in Settings > Technical > Discuss > Subtypes
3. Enable the `Default` flag
67 changes: 36 additions & 31 deletions helpdesk_mgmt/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>README.rst</title>
<title>Helpdesk Management</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,21 +360,16 @@
</style>
</head>
<body>
<div class="document">
<div class="document" id="helpdesk-management">
<h1 class="title">Helpdesk Management</h1>


<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="helpdesk-management">
<h1>Helpdesk Management</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:e62e41c1f2fa575842e2524da5e5207ee21572149b6a6e1171b23fdbb9f80bb8
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/helpdesk/tree/18.0/helpdesk_mgmt"><img alt="OCA/helpdesk" src="https://img.shields.io/badge/github-OCA%2Fhelpdesk-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/helpdesk-18-0/helpdesk-18-0-helpdesk_mgmt"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/helpdesk&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/helpdesk/tree/18.0/helpdesk_mgmt"><img alt="OCA/helpdesk" src="https://img.shields.io/badge/github-OCA%2Fhelpdesk-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/helpdesk-18-0/helpdesk-18-0-helpdesk_mgmt"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/helpdesk&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module adds Helpdesk functionality in Odoo.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
Expand All @@ -386,21 +381,22 @@ <h1>Helpdesk Management</h1>
<li><a class="reference internal" href="#teams" id="toc-entry-5">Teams</a></li>
<li><a class="reference internal" href="#tags" id="toc-entry-6">Tags</a></li>
<li><a class="reference internal" href="#permissions" id="toc-entry-7">Permissions</a></li>
<li><a class="reference internal" href="#customer-notifications" id="toc-entry-8">Customer notifications</a></li>
</ul>
</li>
<li><a class="reference internal" href="#usage" id="toc-entry-8">Usage</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-9">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-10">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-11">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-12">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-13">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-14">Maintainers</a></li>
<li><a class="reference internal" href="#usage" id="toc-entry-9">Usage</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-10">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-11">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-12">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-13">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-14">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-15">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="configuration">
<h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<p>To configure this module, you need to:</p>
<ol class="arabic simple">
<li>Edit or create new channels.</li>
Expand All @@ -410,7 +406,7 @@ <h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
<li>Edit or create new tags.</li>
</ol>
<div class="section" id="channels">
<h3><a class="toc-backref" href="#toc-entry-2">Channels</a></h3>
<h2><a class="toc-backref" href="#toc-entry-2">Channels</a></h2>
<ol class="arabic simple">
<li>Go to <em>Helpdesk &gt; Configuration &gt; Channels</em> to edit or create new
channels.</li>
Expand All @@ -421,7 +417,7 @@ <h3><a class="toc-backref" href="#toc-entry-2">Channels</a></h3>
<p><img alt="image1" src="https://raw.githubusercontent.com/OCA/helpdesk/18.0/helpdesk_mgmt/static/description/Channels.PNG" /></p>
</div>
<div class="section" id="categories">
<h3><a class="toc-backref" href="#toc-entry-3">Categories</a></h3>
<h2><a class="toc-backref" href="#toc-entry-3">Categories</a></h2>
<ol class="arabic simple">
<li>Go to <em>Helpdesk &gt; Configuration &gt; Categories</em> to edit or create new
categories.</li>
Expand All @@ -432,7 +428,7 @@ <h3><a class="toc-backref" href="#toc-entry-3">Categories</a></h3>
<p><img alt="image2" src="https://raw.githubusercontent.com/OCA/helpdesk/18.0/helpdesk_mgmt/static/description/Categories.PNG" /></p>
</div>
<div class="section" id="stages">
<h3><a class="toc-backref" href="#toc-entry-4">Stages</a></h3>
<h2><a class="toc-backref" href="#toc-entry-4">Stages</a></h2>
<ol class="arabic simple">
<li>Go to <em>Helpdesk &gt; Configuration &gt; Stages</em> to edit or create new
stages.</li>
Expand All @@ -451,7 +447,7 @@ <h3><a class="toc-backref" href="#toc-entry-4">Stages</a></h3>
in the list view.</p>
</div>
<div class="section" id="teams">
<h3><a class="toc-backref" href="#toc-entry-5">Teams</a></h3>
<h2><a class="toc-backref" href="#toc-entry-5">Teams</a></h2>
<ol class="arabic simple">
<li>Go to <em>Helpdesk &gt; Configuration &gt; Teams</em> to edit or create new teams.</li>
<li>Edit or create a new team.</li>
Expand All @@ -462,7 +458,7 @@ <h3><a class="toc-backref" href="#toc-entry-5">Teams</a></h3>
<p><img alt="image4" src="https://raw.githubusercontent.com/OCA/helpdesk/18.0/helpdesk_mgmt/static/description/Teams.PNG" /></p>
</div>
<div class="section" id="tags">
<h3><a class="toc-backref" href="#toc-entry-6">Tags</a></h3>
<h2><a class="toc-backref" href="#toc-entry-6">Tags</a></h2>
<ol class="arabic simple">
<li>Go to <em>Helpdesk &gt; Configuration &gt; Ticket Tags</em> to edit or create new
tags.</li>
Expand All @@ -474,7 +470,7 @@ <h3><a class="toc-backref" href="#toc-entry-6">Tags</a></h3>
<p><img alt="image5" src="https://raw.githubusercontent.com/OCA/helpdesk/18.0/helpdesk_mgmt/static/description/Tags.PNG" /></p>
</div>
<div class="section" id="permissions">
<h3><a class="toc-backref" href="#toc-entry-7">Permissions</a></h3>
<h2><a class="toc-backref" href="#toc-entry-7">Permissions</a></h2>
<p>There are restrictions to read tickets according to the user’s
permissions set in Helpdesk.</p>
<ol class="arabic simple">
Expand All @@ -487,9 +483,19 @@ <h3><a class="toc-backref" href="#toc-entry-7">Permissions</a></h3>
<li><em>User</em>: User is able to see all the tickets.</li>
</ol>
</div>
<div class="section" id="customer-notifications">
<h2><a class="toc-backref" href="#toc-entry-8">Customer notifications</a></h2>
<p>If you want portal users to receive an email when a ticket is created:</p>
<ol class="arabic simple">
<li>Enable debug mode</li>
<li>Open the “Ticket Created” subtype in Settings &gt; Technical &gt; Discuss &gt;
Subtypes</li>
<li>Enable the <tt class="docutils literal">Default</tt> flag</li>
</ol>
</div>
</div>
<div class="section" id="usage">
<h2><a class="toc-backref" href="#toc-entry-8">Usage</a></h2>
<h1><a class="toc-backref" href="#toc-entry-9">Usage</a></h1>
<ol class="arabic simple">
<li>Go to <em>Helpdesk</em> or <em>Helpdesk &gt; Dashboard</em> to see the tickets
dashboard</li>
Expand All @@ -513,7 +519,7 @@ <h2><a class="toc-backref" href="#toc-entry-8">Usage</a></h2>
<p><img alt="Tickets01" src="https://raw.githubusercontent.com/OCA/helpdesk/18.0/helpdesk_mgmt/static/description/Tickets01.PNG" /> <img alt="Tickets02" src="https://raw.githubusercontent.com/OCA/helpdesk/18.0/helpdesk_mgmt/static/description/Tickets02.PNG" /></p>
</div>
<div class="section" id="known-issues-roadmap">
<h2><a class="toc-backref" href="#toc-entry-9">Known issues / Roadmap</a></h2>
<h1><a class="toc-backref" href="#toc-entry-10">Known issues / Roadmap</a></h1>
<ul class="simple">
<li>Add a tour feature similar to what the <tt class="docutils literal">project</tt> module defines to
discover projects / tasks.</li>
Expand All @@ -523,17 +529,17 @@ <h2><a class="toc-backref" href="#toc-entry-9">Known issues / Roadmap</a></h2>
</ul>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#toc-entry-10">Bug Tracker</a></h2>
<h1><a class="toc-backref" href="#toc-entry-11">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/helpdesk/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/helpdesk/issues/new?body=module:%20helpdesk_mgmt%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h2><a class="toc-backref" href="#toc-entry-11">Credits</a></h2>
<h1><a class="toc-backref" href="#toc-entry-12">Credits</a></h1>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#toc-entry-12">Authors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-13">Authors</a></h2>
<ul class="simple">
<li>AdaptiveCity</li>
<li>Tecnativa</li>
Expand All @@ -545,7 +551,7 @@ <h3><a class="toc-backref" href="#toc-entry-12">Authors</a></h3>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#toc-entry-13">Contributors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-14">Contributors</a></h2>
<ul class="simple">
<li><a class="reference external" href="https://www.domatix.com">Domatix</a>:<ul>
<li>Carlos Martínez</li>
Expand Down Expand Up @@ -605,7 +611,7 @@ <h3><a class="toc-backref" href="#toc-entry-13">Contributors</a></h3>
</ul>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#toc-entry-14">Maintainers</a></h3>
<h2><a class="toc-backref" href="#toc-entry-15">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand All @@ -618,6 +624,5 @@ <h3><a class="toc-backref" href="#toc-entry-14">Maintainers</a></h3>
</div>
</div>
</div>
</div>
</body>
</html>
78 changes: 77 additions & 1 deletion helpdesk_mgmt/tests/test_helpdesk_portal.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Copyright 2023 Tecnativa - Víctor Martínez
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
# import odoo.tests
from lxml import etree

from odoo import http
from odoo.tests.common import new_test_user, tagged
from odoo.tests.common import RecordCapturer, new_test_user, tagged
from odoo.tools import html2plaintext

from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT, HttpCaseWithUserPortal

Expand Down Expand Up @@ -204,3 +207,76 @@ def _call_close_ticket(self, ticket, stage):
self.assertTrue(resp.is_redirect) # http://127.0.0.1:8069/my/ticket/<ticket-id>
self.assertTrue(resp.headers["Location"].endswith(f"/my/ticket/{ticket.id}"))
return resp

def _assert_html_shows_ticket_link(self, html_content, ticket):
content_html = etree.fromstring(html_content, parser=etree.HTMLParser())
for link in content_html.xpath("//a"):
if ticket.access_token in link.get("href"):
ticket_link = link
break
else:
self.fail("Link for ticket not found")

# In some cases (no `record_name`) the link is there
# but it contains no visible text, so it is not shown in the email.
for text in ticket_link.itertext():
if html2plaintext(text):
# Could be "View Ticket", <ticket name> or similar
break
else:
self.fail("Link for ticket not shown")

def test_stage_changed_mail_link(self):
"""The stage changed email includes an access link to open the Ticket."""
# Arrange
template = self.env.ref("helpdesk_mgmt.changed_stage_template")
stage = self.env.ref("helpdesk_mgmt.helpdesk_ticket_stage_in_progress")
stage.mail_template_id = template
portal_user = self.user_portal
self.authenticate(portal_user.login, portal_user.login)
with (
RecordCapturer(self.env["helpdesk.ticket"], []) as ticket_catcher,
):
self._submit_ticket()
ticket = ticket_catcher.records

# Act
with RecordCapturer(self.env["mail.mail"], []) as emails_catcher:
ticket.with_context(
mail_notrack=False,
tracking_disable=False,
).stage_id = stage
# Emails are sent in a precommit hook,
# that in tests is usually not executed
self.env.cr.precommit.run()

# Assert
stage_changed_email = emails_catcher.records
self._assert_html_shows_ticket_link(stage_changed_email.body_html, ticket)

def test_create_notification(self):
"""
If the Ticket Creation subtype is Default,
the portal user receives an email on Ticket creation.
"""
# Arrange
creation_subtype = self.env.ref("helpdesk_mgmt.hlp_tck_created")
creation_subtype.default = True
portal_user = self.user_portal
self.authenticate(portal_user.login, portal_user.login)

# Act
with (
RecordCapturer(self.env["mail.mail"], []) as email_catcher,
RecordCapturer(self.env["helpdesk.ticket"], []) as ticket_catcher,
):
self._submit_ticket()

# Assert: The email is for the user that created the ticket
# and shows a link with access token that points to the ticket
ticket = ticket_catcher.records
creation_email = email_catcher.records.filtered(
lambda email, subtype=creation_subtype: email.subtype_id == subtype
)
self.assertIn(portal_user.partner_id, creation_email.recipient_ids)
self._assert_html_shows_ticket_link(creation_email.body_html, ticket)
Loading