+ self.assertTrue(resp.headers["Location"].endswith(f"/my/ticket/{ticket.id}"))
+ return resp
+
@odoo.tests.tagged("post_install", "-at_install")
class TestHelpdeskPortal(TestHelpdeskPortalBase):
@@ -93,3 +113,24 @@ def test_submit_ticket_02(self):
"" + "
".join(self.new_ticket_desc_lines) + "
",
tickets.mapped("description"),
)
+
+ def test_close_ticket(self):
+ """Close a ticket from the portal."""
+ self.assertFalse(self.portal_ticket.closed)
+ self.authenticate("test-portal", "test-portal")
+ resp = self.url_open(f"/my/ticket/{self.portal_ticket.id}")
+ self.assertEqual(self._count_close_buttons(resp), 2) # 2 close stages in data/
+ stage = self.env.ref("helpdesk_mgmt.helpdesk_ticket_stage_done")
+ self._call_close_ticket(self.portal_ticket, stage)
+ self.assertTrue(self.portal_ticket.closed)
+ self.assertEqual(self.portal_ticket.stage_id, stage)
+ resp = self.url_open(f"/my/ticket/{self.portal_ticket.id}")
+ self.assertEqual(self._count_close_buttons(resp), 0) # no close buttons now
+
+ def test_close_ticket_invalid_stage(self):
+ """Attempt to close a ticket from the portal with an invalid target stage."""
+ self.authenticate("test-portal", "test-portal")
+ stage = self.env.ref("helpdesk_mgmt.helpdesk_ticket_stage_awaiting")
+ self._call_close_ticket(self.portal_ticket, stage)
+ self.assertFalse(self.portal_ticket.closed)
+ self.assertNotEqual(self.portal_ticket.stage_id, stage)
diff --git a/helpdesk_mgmt/views/helpdesk_ticket_stage_views.xml b/helpdesk_mgmt/views/helpdesk_ticket_stage_views.xml
index aee2ae90ac..b71e9fe981 100644
--- a/helpdesk_mgmt/views/helpdesk_ticket_stage_views.xml
+++ b/helpdesk_mgmt/views/helpdesk_ticket_stage_views.xml
@@ -49,6 +49,10 @@
+