diff --git a/helpdesk_mgmt_rating/README.rst b/helpdesk_mgmt_rating/README.rst index 2795632e18..09913ac7dd 100644 --- a/helpdesk_mgmt_rating/README.rst +++ b/helpdesk_mgmt_rating/README.rst @@ -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 @@ -91,6 +91,7 @@ Contributors * `Tecnativa `_: * Víctor Martínez + * Carolina Fernandez Maintainers ~~~~~~~~~~~ diff --git a/helpdesk_mgmt_rating/migrations/16.0.1.0.0/noupdate_changes.xml b/helpdesk_mgmt_rating/migrations/16.0.1.0.0/noupdate_changes.xml index 701bf8939b..daafaa391f 100644 --- a/helpdesk_mgmt_rating/migrations/16.0.1.0.0/noupdate_changes.xml +++ b/helpdesk_mgmt_rating/migrations/16.0.1.0.0/noupdate_changes.xml @@ -1,17 +1,11 @@ - Helpdesk Ticket: Rating Request - {{object._rating_get_operator().email_formatted}} {{object._rating_get_partner().email_formatted}} - Satisfaction Survey of the ticket {{object.number}} - {{object.name}} {{object._rating_get_partner().id}} -
diff --git a/helpdesk_mgmt_rating/migrations/16.0.1.0.0/post-migration.py b/helpdesk_mgmt_rating/migrations/16.0.1.0.0/post-migration.py index b9077177c1..ec08221110 100644 --- a/helpdesk_mgmt_rating/migrations/16.0.1.0.0/post-migration.py +++ b/helpdesk_mgmt_rating/migrations/16.0.1.0.0/post-migration.py @@ -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, diff --git a/helpdesk_mgmt_rating/models/helpdesk_ticket.py b/helpdesk_mgmt_rating/models/helpdesk_ticket.py index ccf6b732cb..bc0a485e90 100644 --- a/helpdesk_mgmt_rating/models/helpdesk_ticket.py +++ b/helpdesk_mgmt_rating/models/helpdesk_ticket.py @@ -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): diff --git a/helpdesk_mgmt_rating/readme/CONTRIBUTORS.rst b/helpdesk_mgmt_rating/readme/CONTRIBUTORS.rst index e20f551958..2d0e93e5ff 100644 --- a/helpdesk_mgmt_rating/readme/CONTRIBUTORS.rst +++ b/helpdesk_mgmt_rating/readme/CONTRIBUTORS.rst @@ -9,3 +9,4 @@ * `Tecnativa `_: * Víctor Martínez + * Carolina Fernandez diff --git a/helpdesk_mgmt_rating/static/description/index.html b/helpdesk_mgmt_rating/static/description/index.html index 41cb3abc0e..fc3d9d2741 100644 --- a/helpdesk_mgmt_rating/static/description/index.html +++ b/helpdesk_mgmt_rating/static/description/index.html @@ -367,7 +367,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 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/helpdesk Translate me on Weblate Try me on Runboat

This module adds the possibility to rate the assistance received through helpdesk @@ -445,6 +445,7 @@

Contributors

  • Tecnativa:
    • Víctor Martínez
    • +
    • Carolina Fernandez
  • diff --git a/helpdesk_mgmt_rating/tests/__init__.py b/helpdesk_mgmt_rating/tests/__init__.py index 3567d8d8e3..6977055fb8 100644 --- a/helpdesk_mgmt_rating/tests/__init__.py +++ b/helpdesk_mgmt_rating/tests/__init__.py @@ -1 +1,2 @@ from . import test_helpdesk_mgmt_rating +from . import test_helpdesk_portal diff --git a/helpdesk_mgmt_rating/tests/test_helpdesk_mgmt_rating.py b/helpdesk_mgmt_rating/tests/test_helpdesk_mgmt_rating.py index 6f3656e466..4934fa0e59 100644 --- a/helpdesk_mgmt_rating/tests/test_helpdesk_mgmt_rating.py +++ b/helpdesk_mgmt_rating/tests/test_helpdesk_mgmt_rating.py @@ -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": "test@email.com"} ) - 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( @@ -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, + ) diff --git a/helpdesk_mgmt_rating/tests/test_helpdesk_portal.py b/helpdesk_mgmt_rating/tests/test_helpdesk_portal.py new file mode 100644 index 0000000000..8e69eaeea8 --- /dev/null +++ b/helpdesk_mgmt_rating/tests/test_helpdesk_portal.py @@ -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": "test@email.com"} + ) + 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)