diff --git a/helpdesk_mgmt_template/README.rst b/helpdesk_mgmt_template/README.rst new file mode 100644 index 0000000000..257890ff0a --- /dev/null +++ b/helpdesk_mgmt_template/README.rst @@ -0,0 +1,102 @@ +============================ +Helpdesk Management Template +============================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:d785e09cb190bfcdbafe4d42b6fd30f3bf16f06d6febdb41038241735e093008 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |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 + :target: https://github.com/OCA/helpdesk/tree/16.0/helpdesk_mgmt_template + :alt: OCA/helpdesk +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/helpdesk-16-0/helpdesk-16-0-helpdesk_mgmt_template + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/helpdesk&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +The module adds the following features: + +- Pre-configure ticket description template based on it's category + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +**To Configure Ticket's Description Template:** + +- Go to Helpdesk -> Configuration -> Categories +- Create a New Category or select an existing record +- In the Template field pre-define the ticket's description that will be triggered based on the category selected + +Usage +===== + +**Go to Helpdesk module:** + +- Select a Team +- Open a Ticket +- Create a new Ticket +- Select Category +- Add a description or modify category description template (if configured) + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +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 +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Cetmix OÜ + +Contributors +~~~~~~~~~~~~ + +* `Cetmix OÜ `_: + + * Ivan Sokolov + * Mikhail Lapin + * Dessan Hemrayev + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/helpdesk `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/helpdesk_mgmt_template/__init__.py b/helpdesk_mgmt_template/__init__.py new file mode 100644 index 0000000000..bf8e144111 --- /dev/null +++ b/helpdesk_mgmt_template/__init__.py @@ -0,0 +1,4 @@ +# Copyright (C) 2024 Cetmix OÜ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models diff --git a/helpdesk_mgmt_template/__manifest__.py b/helpdesk_mgmt_template/__manifest__.py new file mode 100644 index 0000000000..173b1d70ec --- /dev/null +++ b/helpdesk_mgmt_template/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright (C) 2024 Cetmix OÜ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Helpdesk Management Template", + "summary": "Create Helpdesk Ticket Template", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "author": "Cetmix OÜ, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/helpdesk", + "depends": ["helpdesk_mgmt"], + "data": [ + "views/helpdesk_ticket_views.xml", + "views/helpdesk_ticket_category_views.xml", + ], + "application": False, +} diff --git a/helpdesk_mgmt_template/models/__init__.py b/helpdesk_mgmt_template/models/__init__.py new file mode 100644 index 0000000000..34fbc5efa7 --- /dev/null +++ b/helpdesk_mgmt_template/models/__init__.py @@ -0,0 +1,5 @@ +# Copyright (C) 2024 Cetmix OÜ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import helpdesk_ticket_category +from . import helpdesk_ticket diff --git a/helpdesk_mgmt_template/models/helpdesk_ticket.py b/helpdesk_mgmt_template/models/helpdesk_ticket.py new file mode 100644 index 0000000000..787614b626 --- /dev/null +++ b/helpdesk_mgmt_template/models/helpdesk_ticket.py @@ -0,0 +1,37 @@ +# Copyright (C) 2024 Cetmix OÜ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +from odoo import api, fields, models + + +class HelpdeskTicket(models.Model): + _inherit = "helpdesk.ticket" + + description = fields.Html(store=True, compute="_compute_description") + helpdesk_ticket_category_ids = fields.Many2many( + "helpdesk.ticket.category", compute="_compute_helpdesk_ticket_category" + ) + + @api.depends("team_id") + def _compute_helpdesk_ticket_category(self): + for rec in self: + rec.helpdesk_ticket_category_ids = rec.team_id.category_ids.ids + + @api.depends("category_id") + def _compute_description(self): + for record in self: + if record.category_id.template_description: + record.description = record.category_id.template_description + elif record.description: + record.description = record.description + else: + record.description = "

" + + def copy(self, default=None): + self.ensure_one() + if default is None: + default = {} + if "description" not in default: + default["description"] = "

" + return super().copy(default) diff --git a/helpdesk_mgmt_template/models/helpdesk_ticket_category.py b/helpdesk_mgmt_template/models/helpdesk_ticket_category.py new file mode 100644 index 0000000000..726eff4aa5 --- /dev/null +++ b/helpdesk_mgmt_template/models/helpdesk_ticket_category.py @@ -0,0 +1,10 @@ +# Copyright (C) 2024 Cetmix OÜ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class HelpdeskCategory(models.Model): + _inherit = "helpdesk.ticket.category" + + template_description = fields.Html(sanitize_style=True) diff --git a/helpdesk_mgmt_template/readme/CONFIGURE.rst b/helpdesk_mgmt_template/readme/CONFIGURE.rst new file mode 100644 index 0000000000..8d424bbd23 --- /dev/null +++ b/helpdesk_mgmt_template/readme/CONFIGURE.rst @@ -0,0 +1,5 @@ +**To Configure Ticket's Description Template:** + +- Go to Helpdesk -> Configuration -> Categories +- Create a New Category or select an existing record +- In the Template field pre-define the ticket's description that will be triggered based on the category selected \ No newline at end of file diff --git a/helpdesk_mgmt_template/readme/CONTRIBUTORS.rst b/helpdesk_mgmt_template/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..278ed5b1c1 --- /dev/null +++ b/helpdesk_mgmt_template/readme/CONTRIBUTORS.rst @@ -0,0 +1,5 @@ +* `Cetmix OÜ `_: + + * Ivan Sokolov + * Mikhail Lapin + * Dessan Hemrayev diff --git a/helpdesk_mgmt_template/readme/DESCRIPTION.rst b/helpdesk_mgmt_template/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..9527ae31bb --- /dev/null +++ b/helpdesk_mgmt_template/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +The module adds the following features: + +- Pre-configure ticket description template based on it's category \ No newline at end of file diff --git a/helpdesk_mgmt_template/readme/USAGE.rst b/helpdesk_mgmt_template/readme/USAGE.rst new file mode 100644 index 0000000000..a45c55422b --- /dev/null +++ b/helpdesk_mgmt_template/readme/USAGE.rst @@ -0,0 +1,7 @@ +**Go to Helpdesk module:** + +- Select a Team +- Open a Ticket +- Create a new Ticket +- Select Category +- Add a description or modify category description template (if configured) diff --git a/helpdesk_mgmt_template/static/description/icon.png b/helpdesk_mgmt_template/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/helpdesk_mgmt_template/static/description/icon.png differ diff --git a/helpdesk_mgmt_template/static/description/index.html b/helpdesk_mgmt_template/static/description/index.html new file mode 100644 index 0000000000..9e42126b14 --- /dev/null +++ b/helpdesk_mgmt_template/static/description/index.html @@ -0,0 +1,453 @@ + + + + + +Helpdesk Management Template + + + +
+

Helpdesk Management Template

+ + +

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

+

The module adds the following features:

+
    +
  • Pre-configure ticket description template based on it’s category
  • +
+

Table of contents

+ +
+

Configuration

+

To Configure Ticket’s Description Template:

+
    +
  • Go to Helpdesk -> Configuration -> Categories
  • +
  • Create a New Category or select an existing record
  • +
  • In the Template field pre-define the ticket’s description that will be triggered based on the category selected
  • +
+
+
+

Usage

+

Go to Helpdesk module:

+
    +
  • Select a Team
  • +
  • Open a Ticket
  • +
  • Create a new Ticket
  • +
  • Select Category
  • +
  • Add a description or modify category description template (if configured)
  • +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +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 +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Cetmix OÜ
  • +
+
+
+

Contributors

+
    +
  • Cetmix OÜ:
      +
    • Ivan Sokolov
    • +
    • Mikhail Lapin
    • +
    • Dessan Hemrayev
    • +
    +
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/helpdesk project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/helpdesk_mgmt_template/tests/__init__.py b/helpdesk_mgmt_template/tests/__init__.py new file mode 100644 index 0000000000..c49ed31723 --- /dev/null +++ b/helpdesk_mgmt_template/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright (C) 2024 Cetmix OÜ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_helpdesk_ticket diff --git a/helpdesk_mgmt_template/tests/test_helpdesk_ticket.py b/helpdesk_mgmt_template/tests/test_helpdesk_ticket.py new file mode 100644 index 0000000000..b6a4949713 --- /dev/null +++ b/helpdesk_mgmt_template/tests/test_helpdesk_ticket.py @@ -0,0 +1,129 @@ +# Copyright (C) 2024 Cetmix OÜ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests.common import tagged + +from odoo.addons.helpdesk_mgmt.tests.common import TestHelpdeskTicketBase + + +@tagged("post_install", "-at_install") +class TestHelpdeskTicket(TestHelpdeskTicketBase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + helpdesk_ticket_category_obj = cls.env["helpdesk.ticket.category"] + cls.category_1 = helpdesk_ticket_category_obj.create( + {"name": "Category 1", "template_description": "

Description 1

"} + ) + cls.category_2 = helpdesk_ticket_category_obj.create( + {"name": "Category 2", "template_description": "

Description 2

"} + ) + cls.category_3 = helpdesk_ticket_category_obj.create( + {"name": "Category 3", "template_description": "

Description 3

"} + ) + helpdesk_ticket_team = cls.env["helpdesk.ticket.team"] + + cls.team_c = helpdesk_ticket_team.create( + { + "name": "Team C", + "user_ids": [(6, 0, [cls.user_team.id])], + "category_ids": [(6, 0, [cls.category_1.id, cls.category_3.id])], + } + ) + + def test_set_category(self): + """ + Test that setting a category on a ticket correctly sets the category_id and description. + """ + # Check that the category_id is initially empty + self.assertFalse( + self.ticket_a_user_own.category_id, + msg="Initially, the category_id should be empty", + ) + + # Set the category_id to the id of category_1 + self.ticket_a_user_own.category_id = self.category_1.id + + # Check that the category_id has been correctly set + self.assertEqual( + self.ticket_a_user_own.category_id.id, + self.category_1.id, + msg=f"The category ID #{self.category_1.id} was not correctly set", + ) + + # Check that the description has been correctly + # set to the template_description of category_1 + self.assertEqual( + self.ticket_a_user_own.description, + self.category_1.template_description, + msg=( + "The description was not correctly set" + " to the template_description of Category 1" + ), + ) + self.ticket_a_user_own.category_id = False + self.assertEqual( + self.ticket_a_user_own.description, + self.category_1.template_description, + msg=( + "The description was not correctly set" + " to the template_description of Category 1" + ), + ) + + def test_check_available_team_categories(self): + """ + Test the availability of team categories and + their correct linking to the team and ticket. + """ + # Check that initially, a team should not have categories attached to it. + self.assertFalse( + self.ticket_a_user_own.helpdesk_ticket_category_ids, + msg="A team should not have categories attached to it.", + ) + + # Assign a team to the ticket and check that the categories are linked to the team. + self.ticket_a_user_own.team_id = self.team_c.id + related_category_ids = [self.category_1.id, self.category_3.id] + self.assertEqual( + self.ticket_a_user_own.helpdesk_ticket_category_ids.ids, + related_category_ids, + msg="Categories should be linked to the team.", + ) + + # Set the category_id of the ticket to the first category in the linked categories. + self.ticket_a_user_own.category_id = ( + self.ticket_a_user_own.helpdesk_ticket_category_ids[0] + ) + + # Check that the category_id has been correctly set. + self.assertEqual( + self.ticket_a_user_own.category_id.id, + self.category_1.id, + msg=f"The category ID #{self.category_1.id} was not correctly set", + ) + + def test_create_ticket_with_category(self): + """ + Test the creation of a ticket with a specific category and + verify that the category is correctly set. + """ + # Create a ticket with a specific category + ticket = self.env["helpdesk.ticket"].create( + { + "name": f"Ticket {self.team_c.name} (test)", + "team_id": self.team_c.id, + "user_id": False, + "description": "Test", + "category_id": self.category_1.id, + "priority": "1", + } + ) + + # Check that the category_id has been correctly set + self.assertEqual( + ticket.category_id.id, + self.category_1.id, + msg=f"The category ID #{self.category_1.id} was not correctly set", + ) diff --git a/helpdesk_mgmt_template/views/helpdesk_ticket_category_views.xml b/helpdesk_mgmt_template/views/helpdesk_ticket_category_views.xml new file mode 100644 index 0000000000..2b136d9211 --- /dev/null +++ b/helpdesk_mgmt_template/views/helpdesk_ticket_category_views.xml @@ -0,0 +1,24 @@ + + + + view.helpdesk_category.tree + helpdesk.ticket.category + + 99 + + + + + + + + view.helpdesk_category.form + helpdesk.ticket.category + + + + + + + + diff --git a/helpdesk_mgmt_template/views/helpdesk_ticket_views.xml b/helpdesk_mgmt_template/views/helpdesk_ticket_views.xml new file mode 100644 index 0000000000..8695c6b956 --- /dev/null +++ b/helpdesk_mgmt_template/views/helpdesk_ticket_views.xml @@ -0,0 +1,19 @@ + + + + helpdesk.ticket.view.form + helpdesk.ticket + + 99 + + + + + + [('id', 'in', helpdesk_ticket_category_ids)] + + + + diff --git a/setup/helpdesk_mgmt_template/odoo/addons/helpdesk_mgmt_template b/setup/helpdesk_mgmt_template/odoo/addons/helpdesk_mgmt_template new file mode 120000 index 0000000000..b44caac21a --- /dev/null +++ b/setup/helpdesk_mgmt_template/odoo/addons/helpdesk_mgmt_template @@ -0,0 +1 @@ +../../../../helpdesk_mgmt_template \ No newline at end of file diff --git a/setup/helpdesk_mgmt_template/setup.py b/setup/helpdesk_mgmt_template/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/helpdesk_mgmt_template/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)