Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][ADD] helpdesk_mgmt_project_stage #673

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions helpdesk_mgmt_project_stage/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
======================================
Helpdesk/Project stage synchronization
======================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:d418c905a1cd1c8fd37099799394e99497e14b22f11df3eb0615da338d8d167d
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |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_project_stage
: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_project_stage
: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|

This module allows to transition tasks linked to helpdesk tickets to
other stages when the ticket's stage changes, and vice versa.

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

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

To configure this module, you need to:

1. Go to Helpdesk/Configuration/Stages and set a task stage in the field
``Task Stages``

Usage
=====

To use this module, you need to:

1. Link a ticket to a task
2. Move the ticket to a stage that is configured with a task stage
3. Observe the linked task has changed state too

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_project_stage%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
-------

* Hunki Enterprises BV

Contributors
------------

- Holger Brunn <[email protected]>
(https://hunki-enterprises.com)

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.

.. |maintainer-hbrunn| image:: https://github.com/hbrunn.png?size=40px
:target: https://github.com/hbrunn
:alt: hbrunn

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-hbrunn|

This module is part of the `OCA/helpdesk <https://github.com/OCA/helpdesk/tree/16.0/helpdesk_mgmt_project_stage>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions helpdesk_mgmt_project_stage/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
24 changes: 24 additions & 0 deletions helpdesk_mgmt_project_stage/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2024 Hunki Enterprises BV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)

{
"name": "Helpdesk/Project stage synchronization",
"summary": "Keeps the stages of tickets and tasks in sync",
"version": "16.0.1.0.0",
"development_status": "Alpha",
"category": "After-Sales",
"website": "https://github.com/OCA/helpdesk",
"author": "Hunki Enterprises BV, Odoo Community Association (OCA)",
"maintainers": ["hbrunn"],
"license": "AGPL-3",
"depends": [
"helpdesk_mgmt_project",
],
"data": [
"views/helpdesk_ticket_state.xml",
"views/project_task_type.xml",
],
"demo": [
"demo/project_task_type.xml",
],
}
29 changes: 29 additions & 0 deletions helpdesk_mgmt_project_stage/demo/project_task_type.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2024 Hunki Enterprises BV
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) -->
<data noupdate="1">
<record id="project.project_stage_0" model="project.task.type">
<field
name="ticket_stage_ids"
eval="[(4, ref('helpdesk_mgmt.helpdesk_ticket_stage_new'))]"
/>
</record>
<record id="project.project_stage_1" model="project.task.type">
<field
name="ticket_stage_ids"
eval="[(4, ref('helpdesk_mgmt.helpdesk_ticket_stage_in_progress'))]"
/>
</record>
<record id="project.project_stage_2" model="project.task.type">
<field
name="ticket_stage_ids"
eval="[(4, ref('helpdesk_mgmt.helpdesk_ticket_stage_done'))]"
/>
</record>
<record id="project.project_stage_3" model="project.task.type">
<field
name="ticket_stage_ids"
eval="[(4, ref('helpdesk_mgmt.helpdesk_ticket_stage_cancelled'))]"
/>
</record>
</data>
4 changes: 4 additions & 0 deletions helpdesk_mgmt_project_stage/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import helpdesk_ticket
from . import helpdesk_ticket_stage
from . import project_task
from . import project_task_type
25 changes: 25 additions & 0 deletions helpdesk_mgmt_project_stage/models/helpdesk_ticket.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2024 Hunki Enterprises BV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)

from odoo import models


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

def write(self, vals):
result = super().write(vals)
if "stage_id" in vals:
for this in self:
this.sudo()._set_stage_task()
return result

def _set_stage_task(self):
self.ensure_one()
if not self.task_id:
return
new_stage = (self.stage_id.task_stage_ids & self.task_id.project_id.type_ids)[
:1
]
if new_stage and self.task_id.stage_id != new_stage:
self.task_id.stage_id = new_stage
15 changes: 15 additions & 0 deletions helpdesk_mgmt_project_stage/models/helpdesk_ticket_stage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 Hunki Enterprises BV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)

from odoo import fields, models


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

task_stage_ids = fields.Many2many(
"project.task.type",
relation="project_task_type_helpdesk_ticket_stage_rel",
column1="helpdesk_ticket_stage_id",
column2="project_task_type_id",
)
24 changes: 24 additions & 0 deletions helpdesk_mgmt_project_stage/models/project_task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2024 Hunki Enterprises BV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)

from odoo import models


class ProjectTask(models.Model):
_inherit = "project.task"

def write(self, vals):
result = super().write(vals)
if "stage_id" in vals:
for this in self:
this.sudo()._set_stage_ticket()
return result

def _set_stage_ticket(self):
self.ensure_one()
for ticket in self.ticket_ids:
new_stage = (
self.stage_id.ticket_stage_ids & ticket.team_id._get_applicable_stages()
)[:1]
if new_stage and ticket.stage_id != new_stage:
ticket.stage_id = new_stage
15 changes: 15 additions & 0 deletions helpdesk_mgmt_project_stage/models/project_task_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 Hunki Enterprises BV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)

from odoo import fields, models


class ProjectTaskType(models.Model):
_inherit = "project.task.type"

ticket_stage_ids = fields.Many2many(
"helpdesk.ticket.stage",
relation="project_task_type_helpdesk_ticket_stage_rel",
column1="project_task_type_id",
column2="helpdesk_ticket_stage_id",
)
3 changes: 3 additions & 0 deletions helpdesk_mgmt_project_stage/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
To configure this module, you need to:

1. Go to Helpdesk/Configuration/Stages and set a task stage in the field `Task Stages`
1 change: 1 addition & 0 deletions helpdesk_mgmt_project_stage/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Holger Brunn \<[email protected]> (https://hunki-enterprises.com)
1 change: 1 addition & 0 deletions helpdesk_mgmt_project_stage/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module allows to transition tasks linked to helpdesk tickets to other stages when the ticket's stage changes, and vice versa.
5 changes: 5 additions & 0 deletions helpdesk_mgmt_project_stage/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
To use this module, you need to:

1. Link a ticket to a task
2. Move the ticket to a stage that is configured with a task stage
3. Observe the linked task has changed state too
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions helpdesk_mgmt_project_stage/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_helpdesk_mgmt_project_stage
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Copyright 2024 Hunki Enterprises BV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)

from odoo.fields import Command
from odoo.tests.common import TransactionCase


class TestHelpdeskMgmtProjectStage(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.ticket_stage_progress = cls.env.ref(
"helpdesk_mgmt.helpdesk_ticket_stage_in_progress"
)
cls.task_stage_progress = cls.env["project.task.type"].create(
{
"name": "stage in progress",
"ticket_stage_ids": [Command.link(cls.ticket_stage_progress.id)],
}
)
cls.ticket_stage_done = cls.env.ref("helpdesk_mgmt.helpdesk_ticket_stage_done")
cls.task_stage_done = cls.env["project.task.type"].create(
{
"name": "stage done",
"ticket_stage_ids": [Command.link(cls.ticket_stage_done.id)],
}
)
cls.project = cls.env["project.project"].create(
{
"name": "Helpdesk project",
"type_ids": [
Command.set((cls.task_stage_progress + cls.task_stage_done).ids)
],
}
)
cls.task = cls.env["project.task"].create(
{
"name": "Ticket task",
"project_id": cls.project.id,
"stage_id": cls.task_stage_progress.id,
}
)
cls.ticket = cls.env["helpdesk.ticket"].create(
{
"name": "Ticket",
"project_id": cls.project.id,
"description": "Change stage",
}
)
cls.user = cls.env.ref("base.user_demo")

def test_task_sync(self):
"""Test that configured stages stay in sync"""
ticket = self.ticket.with_user(self.user)
task = self.task.with_user(self.user)
task.stage_id = self.task_stage_progress
ticket.task_id = task
task.stage_id = self.task_stage_done
self.assertEqual(ticket.stage_id, self.ticket_stage_done)
ticket.stage_id = self.ticket_stage_done
self.assertEqual(task.stage_id, self.task_stage_done)
ticket.stage_id = self.ticket_stage_progress
self.assertEqual(task.stage_id, self.task_stage_progress)
task.stage_id = False
self.assertEqual(ticket.stage_id, self.ticket_stage_progress)
14 changes: 14 additions & 0 deletions helpdesk_mgmt_project_stage/views/helpdesk_ticket_state.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2024 Hunki Enterprises BV
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) -->
<data>
<record id="view_helpdesk_ticket_stage_form" model="ir.ui.view">
<field name="model">helpdesk.ticket.stage</field>
<field name="inherit_id" ref="helpdesk_mgmt.view_helpdesk_ticket_stage_form" />
<field name="arch" type="xml">
<group name="main_right" position="inside">
<field name="task_stage_ids" widget="many2many_tags" />
</group>
</field>
</record>
</data>
14 changes: 14 additions & 0 deletions helpdesk_mgmt_project_stage/views/project_task_type.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2024 Hunki Enterprises BV
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) -->
<data>
<record id="task_type_edit" model="ir.ui.view">
<field name="model">project.task.type</field>
<field name="inherit_id" ref="project.task_type_edit" />
<field name="arch" type="xml">
<field name="project_ids" position="after">
<field name="ticket_stage_ids" widget="many2many_tags" />
</field>
</field>
</record>
</data>
6 changes: 6 additions & 0 deletions setup/helpdesk_mgmt_project_stage/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
Loading