Skip to content

Commit

Permalink
[ADD] helpdesk_mgmt_activity: new module
Browse files Browse the repository at this point in the history
  • Loading branch information
dessanhemrayev committed Oct 6, 2024
1 parent 79edc7b commit 0e19278
Show file tree
Hide file tree
Showing 21 changed files with 803 additions and 0 deletions.
114 changes: 114 additions & 0 deletions helpdesk_mgmt_activity/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
============================
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:/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
- 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 for a Team**

- Go to Helpdesk-->Configuration-->Teams
- Create a Team or select an existing record
- In the Binding Models field add models available for a team

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

- Go to Helpdesk-->Configuration-->Stages
- Create a New stage or select an existing record
- Enable the "Closed Activity Stage" checkbox

Usage
=====

**Go to Helpdesk module**

- Select a Team
- Open a Ticket
- Create a new Ticket
- Select a related model
- Select a record for a related model
- Select Activity type, user, and due date
- By moving the Ticket to an 'in progress' state activity will be created in the related model
- If an activity was closed, the Ticket moves to the pre-defined stage

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

Bugs are tracked on `GitHub Issues <https:/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:/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

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:/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:/OCA/helpdesk",
"depends": ["helpdesk_mgmt"],
"data": [
"views/helpdesk_ticket_stage_view.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 helpdesk_ticket
from . import helpdesk_ticket_stage
from . import helpdesk_ticket_team
from . import mail_activity
24 changes: 24 additions & 0 deletions helpdesk_mgmt_activity/models/helpdesk_ticket.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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"

source_document = fields.Reference(
selection="_select_target_model", string="Record"
)

@api.model
def _select_target_model(self):
team_id = self.env["helpdesk.ticket.team"].browse(
self.env.context.get("active_id")
)
model_ids = team_id.avaible_model_ids
models = self.env["ir.model"].search(
[("id", "in", model_ids.ids if model_ids else [])]
)
return [(model.model, model.name) for model in models]
10 changes: 10 additions & 0 deletions helpdesk_mgmt_activity/models/helpdesk_ticket_stage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from odoo import fields, models


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

is_closed_activity_stage = fields.Boolean(
string="Closed Activity Stage",
help="If checked, this stage will be set when a related activity is closed.",
)
7 changes: 7 additions & 0 deletions helpdesk_mgmt_activity/models/helpdesk_ticket_team.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from odoo import fields, models


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

avaible_model_ids = fields.Many2many("ir.model")
43 changes: 43 additions & 0 deletions helpdesk_mgmt_activity/models/mail_activity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from odoo import api, models


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

@api.model
def _get_closed_activity_stage(self):
stages = self.env["helpdesk.ticket.stage"].search(

Check warning on line 9 in helpdesk_mgmt_activity/models/mail_activity.py

View check run for this annotation

Codecov / codecov/patch

helpdesk_mgmt_activity/models/mail_activity.py#L9

Added line #L9 was not covered by tests
[("is_closed_activity_stage", "=", True)]
)
return stages[0] if stages else False

Check warning on line 12 in helpdesk_mgmt_activity/models/mail_activity.py

View check run for this annotation

Codecov / codecov/patch

helpdesk_mgmt_activity/models/mail_activity.py#L12

Added line #L12 was not covered by tests

def _action_done(self, feedback=False, attachment_ids=None):
related_tickets = self.env["helpdesk.ticket"].search(

Check warning on line 15 in helpdesk_mgmt_activity/models/mail_activity.py

View check run for this annotation

Codecov / codecov/patch

helpdesk_mgmt_activity/models/mail_activity.py#L15

Added line #L15 was not covered by tests
[("source_document", "=", f"{self.res_model},{self.res_id}")]
)
closed_activity_stage = self._get_closed_activity_stage()

Check warning on line 18 in helpdesk_mgmt_activity/models/mail_activity.py

View check run for this annotation

Codecov / codecov/patch

helpdesk_mgmt_activity/models/mail_activity.py#L18

Added line #L18 was not covered by tests
for ticket in related_tickets:
if closed_activity_stage:
ticket.stage_id = closed_activity_stage.id
return super()._action_done(feedback, attachment_ids)

Check warning on line 22 in helpdesk_mgmt_activity/models/mail_activity.py

View check run for this annotation

Codecov / codecov/patch

helpdesk_mgmt_activity/models/mail_activity.py#L21-L22

Added lines #L21 - L22 were not covered by tests

@api.model
def create(self, vals):
ticket_model = (

Check warning on line 26 in helpdesk_mgmt_activity/models/mail_activity.py

View check run for this annotation

Codecov / codecov/patch

helpdesk_mgmt_activity/models/mail_activity.py#L26

Added line #L26 was not covered by tests
self.env["ir.model"]
.sudo()
.search([("model", "=", "helpdesk.ticket")], limit=1)
)
ticket_obj = self.env["helpdesk.ticket"]

Check warning on line 31 in helpdesk_mgmt_activity/models/mail_activity.py

View check run for this annotation

Codecov / codecov/patch

helpdesk_mgmt_activity/models/mail_activity.py#L31

Added line #L31 was not covered by tests

if vals.get("res_model_id", 0) == ticket_model.id:
ticket = ticket_obj.browse(vals.get("res_id"))

Check warning on line 34 in helpdesk_mgmt_activity/models/mail_activity.py

View check run for this annotation

Codecov / codecov/patch

helpdesk_mgmt_activity/models/mail_activity.py#L34

Added line #L34 was not covered by tests
if ticket and ticket.source_document:
ticket.source_document.activity_schedule(

Check warning on line 36 in helpdesk_mgmt_activity/models/mail_activity.py

View check run for this annotation

Codecov / codecov/patch

helpdesk_mgmt_activity/models/mail_activity.py#L36

Added line #L36 was not covered by tests
activity_type_id=vals.get("activity_type_id"),
summary=vals.get("summary"),
note=vals.get("note"),
user_id=vals.get("user_id"),
)

return super().create(vals)

Check warning on line 43 in helpdesk_mgmt_activity/models/mail_activity.py

View check run for this annotation

Codecov / codecov/patch

helpdesk_mgmt_activity/models/mail_activity.py#L43

Added line #L43 was not covered by tests
11 changes: 11 additions & 0 deletions helpdesk_mgmt_activity/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
**To Configure Available Odoo Models for a Team**

- Go to Helpdesk-->Configuration-->Teams
- Create a Team or select an existing record
- In the Binding Models field add models available for a team

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

- Go to Helpdesk-->Configuration-->Stages
- Create a New stage or select an existing record
- Enable the "Closed Activity Stage" checkbox
5 changes: 5 additions & 0 deletions helpdesk_mgmt_activity/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* `Cetmix OÜ <https://cetmix.com>`_:

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

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

- Select a Team
- Open a Ticket
- Create a new Ticket
- Select a related model
- Select a record for a related model
- Select Activity type, user, and due date
- By moving the Ticket to an 'in progress' state activity will be created in the related model
- If an activity was closed, 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 0e19278

Please sign in to comment.