Skip to content

Commit

Permalink
[MIG] helpdesk_mgmt_rating: Continue migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinafernandez-tecnativa committed Apr 1, 2024
1 parent 5c3b561 commit 66cdb73
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 20 deletions.
3 changes: 2 additions & 1 deletion helpdesk_mgmt_rating/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Helpdesk Management Rating
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:47af3639d9e2335c965d3aaed97d98ec6fec4321d12cf0b9c9ee5c4021bf8672
!! source digest: sha256:f8976a3fbf7845e3e2c6756782481e841b327654e3a45076e41c7862751b45d2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down Expand Up @@ -91,6 +91,7 @@ Contributors
* `Tecnativa <https://www.tecnativa.com>`_:

* Víctor Martínez
* Carolina Fernandez

Maintainers
~~~~~~~~~~~
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
<?xml version='1.0' encoding='utf-8' ?>
<odoo>
<record id="rating_ticket_email_template" model="mail.template">
<field name="name">Helpdesk Ticket: Rating Request</field>
<field name="model_id" ref="helpdesk_mgmt.model_helpdesk_ticket" />
<field
name="email_from"
>{{object._rating_get_operator().email_formatted}}</field>
<field name="email_to">{{object._rating_get_partner().email_formatted}}</field>
<field
name="subject"
>Satisfaction Survey of the ticket {{object.number}} - {{object.name}}</field>
<field name="partner_to">{{object._rating_get_partner().id}}</field>
<field name="auto_delete" eval="True" />
<field name="body_html" type="html">
<div>
<t t-set="access_token" t-value="object._rating_get_access_token()" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@openupgrade.migrate()
def migrate(env, version):
openupgrade.load_data(
env.cr, "helpdesk_mgmt_rating", "migrations/15.0.1.0.0/noupdate_changes.xml"
env.cr, "helpdesk_mgmt_rating", "migrations/16.0.1.0.0/noupdate_changes.xml"
)
openupgrade.delete_record_translations(
env.cr,
Expand Down
12 changes: 11 additions & 1 deletion helpdesk_mgmt_rating/models/helpdesk_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,22 @@ def _send_ticket_rating_mail(self, force_send=False):
force_send=force_send,
)

def rating_apply(self, rate, token=None, feedback=None, subtype_xmlid=None):
def rating_apply(
self,
rate,
token=None,
rating=None,
feedback=None,
subtype_xmlid=None,
notify_delay_send=False,
):
return super().rating_apply(
rate,
token=token,
rating=rating,
feedback=feedback,
subtype_xmlid="helpdesk_mgmt_rating.mt_ticket_rating",
notify_delay_send=notify_delay_send,
)

def _rating_get_partner(self):
Expand Down
1 change: 1 addition & 0 deletions helpdesk_mgmt_rating/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
* `Tecnativa <https://www.tecnativa.com>`_:

* Víctor Martínez
* Carolina Fernandez
3 changes: 2 additions & 1 deletion helpdesk_mgmt_rating/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Helpdesk Management Rating</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:47af3639d9e2335c965d3aaed97d98ec6fec4321d12cf0b9c9ee5c4021bf8672
!! source digest: sha256:f8976a3fbf7845e3e2c6756782481e841b327654e3a45076e41c7862751b45d2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.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/16.0/helpdesk_mgmt_rating"><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-16-0/helpdesk-16-0-helpdesk_mgmt_rating"><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=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module adds the possibility to rate the assistance received through helpdesk
Expand Down Expand Up @@ -445,6 +445,7 @@ <h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
</li>
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
<li>Víctor Martínez</li>
<li>Carolina Fernandez</li>
</ul>
</li>
</ul>
Expand Down
1 change: 1 addition & 0 deletions helpdesk_mgmt_rating/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import test_helpdesk_mgmt_rating
from . import test_helpdesk_portal
23 changes: 13 additions & 10 deletions helpdesk_mgmt_rating/tests/test_helpdesk_mgmt_rating.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
# Copyright 2022 Tecnativa - Víctor Martínez
# Copyright 2024 Tecnativa - Carolina Fernandez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.tests import common, new_test_user
from odoo.tests.common import users
from odoo.tests.common import new_test_user, users

from odoo.addons.base.tests.common import BaseCommon

class TestHelpdeskMgmtRating(common.TransactionCase):

class TestHelpdeskMgmtRating(BaseCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.partner = cls.env["res.partner"].create(
{"name": "Test partner", "email": "[email protected]"}
)
ctx = {
"mail_create_nolog": True,
"mail_create_nosubscribe": True,
"mail_notrack": True,
"no_reset_password": True,
}
new_test_user(
cls.env,
login="test-helpdesk-user",
groups="helpdesk_mgmt.group_helpdesk_user",
context=ctx,
)
cls.stage_done = cls.env.ref("helpdesk_mgmt.helpdesk_ticket_stage_done")
cls.stage_done.rating_mail_template_id = cls.env.ref(
Expand All @@ -46,3 +41,11 @@ def test_ticket_stage_done(self):
rating = ticket.rating_ids.filtered(lambda x: x.partner_id == self.partner)
rating.write({"rating": 5, "consumed": True})
self.assertEqual(ticket.positive_rate_percentage, 100)
# Check action view ticket rating
action = ticket.action_view_ticket_rating()
self.assertEqual(action.get("type"), "ir.actions.act_window")
self.assertEqual(action.get("name"), "Ticket Rating")
self.assertEqual(
action.get("id"),
self.env.ref("helpdesk_mgmt_rating.helpdesk_ticket_rating_action").id,
)
48 changes: 48 additions & 0 deletions helpdesk_mgmt_rating/tests/test_helpdesk_portal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 2024 Tecnativa - Carolina Fernandez
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from odoo.addons.base.tests.common import HttpCaseWithUserPortal


class TestHelpdeskPortalBase(HttpCaseWithUserPortal):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.partner = cls.env["res.partner"].create(
{"name": "Test partner", "email": "[email protected]"}
)
cls.stage_done = cls.env.ref("helpdesk_mgmt.helpdesk_ticket_stage_done")
cls.stage_done.rating_mail_template_id = cls.env.ref(
"helpdesk_mgmt_rating.rating_ticket_email_template"
)
cls.ticket = cls.env["helpdesk.ticket"].create(
{
"name": "Test 1",
"description": "Ticket test",
"partner_id": cls.partner.id,
"stage_id": cls.stage_done.id,
}
)

def test_rating_satisfied_ticket(self):
"""Rate satisfied ticket from the portal."""
self.authenticate("portal", "portal")
portal_access_token = self.ticket._rating_get_access_token()
resp = self.url_open(f"/rate/{portal_access_token}/5")
self.assertEqual(resp.status_code, 200)
self.assertEqual(self.ticket.positive_rate_percentage, 100)

def test_rating_not_satisfied_ticket(self):
"""Rate not satisfied ticket from the portal."""
self.authenticate("portal", "portal")
portal_access_token = self.ticket._rating_get_access_token()
resp = self.url_open(f"/rate/{portal_access_token}/3")
self.assertEqual(resp.status_code, 200)
self.assertEqual(self.ticket.positive_rate_percentage, 0)

def test_rating_dissatisfied_ticket(self):
"""Rate highly dissatisfied ticket from the portal."""
self.authenticate("portal", "portal")
portal_access_token = self.ticket._rating_get_access_token()
resp = self.url_open(f"/rate/{portal_access_token}/1")
self.assertEqual(resp.status_code, 200)
self.assertEqual(self.ticket.positive_rate_percentage, 0)

0 comments on commit 66cdb73

Please sign in to comment.