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

[17.0][MIG] helpdesk_mgmt_stage_server_action #650

Open
wants to merge 3 commits into
base: 17.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
Empty file.
92 changes: 92 additions & 0 deletions helpdesk_mgmt_stage_server_action/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
============================
Helpdesk Stage Server Action
============================

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

.. |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/17.0/helpdesk_mgmt_stage_server_action
:alt: OCA/helpdesk
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/helpdesk-17-0/helpdesk-17-0-helpdesk_mgmt_stage_server_action
: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=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows you to execute server actions when a Helpdesk ticket
enters a specific stage.

**Table of contents**

.. contents::
:local:

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

- Go to Helpdesk > Configuration > Stages
- Create or select a stage
- Select or create a server action

Usage
=====

- Go to Helpdesk
- Select or create a Helpdesk tickets
- Move it to the stage configured before to trigger the execution of
the server action

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_stage_server_action%0Aversion:%2017.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
-------

* Camptocamp

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

- Bojan Anchev <[email protected]>

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/17.0/helpdesk_mgmt_stage_server_action>`_ 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_stage_server_action/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
14 changes: 14 additions & 0 deletions helpdesk_mgmt_stage_server_action/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Helpdesk Stage Server Action",
"summary": "Execute server actions when reaching a Helpdesk ticket stage",
"version": "17.0.1.0.0",
"category": "HelpDesk Service",
"author": "Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/helpdesk",
"depends": ["helpdesk_mgmt"],
"data": ["views/helpdesk_ticket_stage.xml"],
"installable": True,
"license": "AGPL-3",
}
2 changes: 2 additions & 0 deletions helpdesk_mgmt_stage_server_action/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import helpdesk_ticket_stage
from . import helpdesk_ticket
43 changes: 43 additions & 0 deletions helpdesk_mgmt_stage_server_action/models/helpdesk_ticket.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, models


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

@api.model_create_multi
def create(self, vals_list):
records = super().create(vals_list)
for record in records:
action = record.stage_id.action_id
if not action:
continue
context = {
"active_model": self._name,
"active_id": record.id,
"active_ids": records.ids,
}
action.with_context(**context).run()
return records

def write(self, vals):
records = "stage_id" in vals and self.filtered(
lambda ticket: ticket.stage_id.id != vals.get("stage_id")
)
if records:
res = super().write(vals)
action = (
self.env["helpdesk.ticket.stage"].browse(vals["stage_id"]).action_id
)
if action:
context = {
"active_model": self._name,
"active_id": records.id,
"active_ids": records.ids,
}
action.with_context(**context).run()
else:
res = super().write(vals)
return res
17 changes: 17 additions & 0 deletions helpdesk_mgmt_stage_server_action/models/helpdesk_ticket_stage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


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

action_id = fields.Many2one(
"ir.actions.server",
string="Server Action",
domain="[('model_id', '=', 'helpdesk.ticket')]",
help="The assigned action will be executed when a ticket is assigned from a "
"different stage to this stage, the context values that will be passed "
"to the action are the model name helpdesk.ticket and the ids of the tickets.",
)
3 changes: 3 additions & 0 deletions helpdesk_mgmt_stage_server_action/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
3 changes: 3 additions & 0 deletions helpdesk_mgmt_stage_server_action/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Go to Helpdesk \> Configuration \> Stages
- Create or select a stage
- Select or create a server action
1 change: 1 addition & 0 deletions helpdesk_mgmt_stage_server_action/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Bojan Anchev \<<[email protected]>\>
2 changes: 2 additions & 0 deletions helpdesk_mgmt_stage_server_action/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module allows you to execute server actions when a Helpdesk ticket
enters a specific stage.
4 changes: 4 additions & 0 deletions helpdesk_mgmt_stage_server_action/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Go to Helpdesk
- Select or create a Helpdesk tickets
- Move it to the stage configured before to trigger the execution of the
server action
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading