Skip to content

Commit

Permalink
[ADD] helpdesk_mgmt_activity: Module added
Browse files Browse the repository at this point in the history
  • Loading branch information
dessanhemrayev authored and geomer198 committed Oct 14, 2024
1 parent 8769c2c commit e7503f6
Show file tree
Hide file tree
Showing 21 changed files with 1,112 additions and 0 deletions.
123 changes: 123 additions & 0 deletions helpdesk_mgmt_activity/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
============================
Helpdesk Management Activity
============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:c77bb124906154be8648020f75af1b6c2dca2c419551445c18e60b86488fe429
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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_activity
: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_activity
: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:

- Refer a ticket to the Odoo model record
- Set the list of models available for a Helpdesk team
- Pre-configure ticket description template based on it's category
- Create an activity for the referring record right from the Ticket
- Change the Ticket's stage based on the activity state

**Table of contents**

.. contents::
:local:

Configuration
=============

**To Configure Available Odoo Models**
======================================

- Go to Helpdesk-->Configuration-->Settings
- In the Available Models field add models available for a Helpdesk

To Configure Ticket's Stage on Activity State**
===============================================

- Go to Helpdesk-->Configuration--Teams
- Create a "New" team or select an existing record
- Enable the "Set Activities" checkbox to enable the feature
- Select the "Done Activity Stage" to move the ticket when the activity is done

Usage
=====

**Go to Helpdesk module**
=========================

- Select a Team
- Open a Ticket
- Create a new Ticket
- In the "Assign Activity" group

- Select a related model and record in the Source field
- Select Activity type and due date

- Enter the Description
- Click the "Perform Action" button
- Ticket will be moved to the next preset state and activity will be created in the related model
- If an activity is Done, the Ticket moves to the pre-defined stage

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/helpdesk/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 <https://github.com/OCA/helpdesk/issues/new?body=module:%20helpdesk_mgmt_activity%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~

* Cetmix OÜ

Contributors
~~~~~~~~~~~~

* `Cetmix OÜ <https://cetmix.com>`_:

* Ivan Sokolov
* Mikhail Lapin
* Dessan Hemrayev
* Maksim Shurupov

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 <https://github.com/OCA/helpdesk/tree/16.0/helpdesk_mgmt_activity>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions helpdesk_mgmt_activity/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (C) 2024 Cetmix OÜ
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
18 changes: 18 additions & 0 deletions helpdesk_mgmt_activity/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (C) 2024 Cetmix OÜ
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Helpdesk Management Activity",
"summary": "Create Activities for Odoo records from the Helpdesk",
"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/res_config_settings_views.xml",
"views/helpdesk_ticket_view.xml",
"views/helpdesk_ticket_team_views.xml",
],
"application": False,
}
7 changes: 7 additions & 0 deletions helpdesk_mgmt_activity/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright (C) 2024 Cetmix OÜ
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import res_config_settings
from . import helpdesk_ticket
from . import helpdesk_ticket_team
from . import mail_activity
103 changes: 103 additions & 0 deletions helpdesk_mgmt_activity/models/helpdesk_ticket.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Copyright (C) 2024 Cetmix OÜ
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import ast

from odoo import _, api, fields, models


class HelpdeskTicket(models.Model):
_inherit = "helpdesk.ticket"

can_create_activity = fields.Boolean(related="team_id.is_set_activity")
res_model = fields.Char(string="Source Document Model", index=True)
res_id = fields.Integer(string="Source Document", index=True)

record_ref = fields.Reference(
selection="_referenceable_models",
compute="_compute_record_ref",
inverse="_inverse_record_ref",
string="Source Record",
)
source_activity_type_id = fields.Many2one(comodel_name="mail.activity.type")
date_deadline = fields.Date(string="Due Date", default=fields.Date.context_today)

@api.model
def _referenceable_models(self):
"""Select target model for source document"""
model_ids_str = (
self.env["ir.config_parameter"]
.sudo()
.get_param("helpdesk_mgmt_activity.helpdesk_available_model_ids", "[]")
)
model_ids = ast.literal_eval(model_ids_str)
if not model_ids:
return []
IrModelAccess = self.env["ir.model.access"].with_user(self.env.user.id)
available_models = self.env["ir.model"].search_read(
[("id", "in", model_ids)], fields=["model", "name"]
)
return [
(model.get("model"), model.get("name"))
for model in available_models
if IrModelAccess.check(model.get("model"), "read", False)
]

@api.depends("res_model", "res_id")
def _compute_record_ref(self):
"""Compute Source Document Reference"""
for rec in self:
if rec.res_model and rec.res_id:
try:
self.env[rec.res_model].browse(rec.res_id).check_access_rule("read")
rec.record_ref = "%s,%s" % (

Check warning on line 53 in helpdesk_mgmt_activity/models/helpdesk_ticket.py

View check run for this annotation

Codecov / codecov/patch

helpdesk_mgmt_activity/models/helpdesk_ticket.py#L51-L53

Added lines #L51 - L53 were not covered by tests
rec.res_model,
rec.res_id,
)
except Exception:
rec.record_ref = None

Check warning on line 58 in helpdesk_mgmt_activity/models/helpdesk_ticket.py

View check run for this annotation

Codecov / codecov/patch

helpdesk_mgmt_activity/models/helpdesk_ticket.py#L57-L58

Added lines #L57 - L58 were not covered by tests
else:
rec.record_ref = None

def _inverse_record_ref(self):
"""Set Source Document Reference"""
for record in self:
if record.record_ref:
res_id = record.record_ref.id
res_model = record.record_ref._name
else:
res_id, res_model = False, False
record.write({"res_id": res_id, "res_model": res_model})

def _check_activity_values(self):
"""Check activity values for helpdesk ticket"""
if not self.can_create_activity:
raise models.UserError(_("You cannot create activity!"))
if not (self.res_id and self.res_model):
raise models.UserError(_("Source Record is not set!"))
if not self.source_activity_type_id:
raise models.UserError(_("Activity Type is not set!"))
if not self.date_deadline:
raise models.UserError(_("Date Deadline is not set!"))

def perform_action(self):
self._check_activity_values()
self.ensure_one()
return {
"type": "ir.actions.act_window",
"name": "Helpdesk Ticket Action",
"view_mode": "form",
"res_model": "mail.activity",
"view_type": "form",
"context": {
"default_res_model_id": self.env["ir.model"]._get_id(self.res_model),
"default_res_id": self.res_id,
"default_activity_type_id": self.source_activity_type_id.id,
"default_date_deadline": self.date_deadline,
"default_note": self.description,
"default_ticket_id": self.id,
"default_summary": self.name,
"default_user_id": self.user_id.id,
},
"target": "new",
}
16 changes: 16 additions & 0 deletions helpdesk_mgmt_activity/models/helpdesk_ticket_team.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from odoo import fields, models


class HelpdeskTicketTeam(models.Model):
_inherit = "helpdesk.ticket.team"

is_set_activity = fields.Boolean(
string="Set Activities",
help="Available to set activity on source record from ticket",
)
activity_stage_id = fields.Many2one(
comodel_name="helpdesk.ticket.stage",
string="Done Activity Stage",
domain="['|', ('team_ids', 'in, []'), ('team_ids', 'in', [id])]",
help="Move the ticket when the activity in source record is done",
)
19 changes: 19 additions & 0 deletions helpdesk_mgmt_activity/models/mail_activity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from odoo import fields, models


class MailActivity(models.Model):
_inherit = "mail.activity"

ticket_id = fields.Many2one(
comodel_name="helpdesk.ticket",
help="Activity created from helpdesk ticket"
"After closing this activity, ticket is moved to done stage",
)

def _action_done(self, feedback=False, attachment_ids=None):
# Get closed stage for ticket
for ticket in self.mapped("ticket_id"):
if ticket.team_id and ticket.team_id.activity_stage_id:
# Change ticket stage
ticket.stage_id = ticket.team_id.activity_stage_id.id
return super()._action_done(feedback, attachment_ids)
38 changes: 38 additions & 0 deletions helpdesk_mgmt_activity/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import ast

from odoo import api, fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

helpdesk_available_model_ids = fields.Many2many(
comodel_name="ir.model",
domain="[('transient', '=', False)]",
string="Available Models",
help="Available models for set source record in helpdesk ticket",
)

def set_values(self):
super().set_values()
ICPSudo = self.env["ir.config_parameter"].sudo()
ICPSudo.set_param(

Check warning on line 19 in helpdesk_mgmt_activity/models/res_config_settings.py

View check run for this annotation

Codecov / codecov/patch

helpdesk_mgmt_activity/models/res_config_settings.py#L17-L19

Added lines #L17 - L19 were not covered by tests
"helpdesk_mgmt_activity.helpdesk_available_model_ids",
str(self.helpdesk_available_model_ids.ids),
)
return

Check warning on line 23 in helpdesk_mgmt_activity/models/res_config_settings.py

View check run for this annotation

Codecov / codecov/patch

helpdesk_mgmt_activity/models/res_config_settings.py#L23

Added line #L23 was not covered by tests

@api.model
def get_values(self):
res = super().get_values()
ICPSudo = self.env["ir.config_parameter"].sudo()
helpdesk_available_model_ids = ICPSudo.get_param(
"helpdesk_mgmt_activity.helpdesk_available_model_ids", False
)
if helpdesk_available_model_ids:
res.update(
helpdesk_available_model_ids=ast.literal_eval(
helpdesk_available_model_ids
)
)
return res
13 changes: 13 additions & 0 deletions helpdesk_mgmt_activity/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
**To Configure Available Odoo Models**
======================================

- Go to Helpdesk-->Configuration-->Settings
- In the Available Models field add models available for a Helpdesk

To Configure Ticket's Stage on Activity State**
===============================================

- Go to Helpdesk-->Configuration--Teams
- Create a "New" team or select an existing record
- Enable the "Set Activities" checkbox to enable the feature
- Select the "Done Activity Stage" to move the ticket when the activity is done
6 changes: 6 additions & 0 deletions helpdesk_mgmt_activity/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
* `Cetmix OÜ <https://cetmix.com>`_:

* Ivan Sokolov
* Mikhail Lapin
* Dessan Hemrayev
* Maksim Shurupov
7 changes: 7 additions & 0 deletions helpdesk_mgmt_activity/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
The module adds the following features:

- Refer a ticket to the Odoo model record
- Set the list of models available for a Helpdesk team
- Pre-configure ticket description template based on it's category
- Create an activity for the referring record right from the Ticket
- Change the Ticket's stage based on the activity state
15 changes: 15 additions & 0 deletions helpdesk_mgmt_activity/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
**Go to Helpdesk module**
=========================

- Select a Team
- Open a Ticket
- Create a new Ticket
- In the "Assign Activity" group

- Select a related model and record in the Source field
- Select Activity type and due date

- Enter the Description
- Click the "Perform Action" button
- Ticket will be moved to the next preset state and activity will be created in the related model
- If an activity is Done, the Ticket moves to the pre-defined stage
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit e7503f6

Please sign in to comment.