Skip to content

Commit

Permalink
[MIG] helpdesk_mgmt_stage_server_action: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yankinmax committed Nov 12, 2024
1 parent 52c23da commit 72cbe20
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 38 deletions.
8 changes: 4 additions & 4 deletions helpdesk_mgmt_stage_server_action/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ Helpdesk Stage Server Action
: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_ticket_stage_server_action
: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_ticket_stage_server_action
: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
Expand Down Expand Up @@ -57,7 +57,7 @@ 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_ticket_stage_server_action%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`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.

Expand Down Expand Up @@ -87,6 +87,6 @@ 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_ticket_stage_server_action>`_ project on GitHub.
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.
3 changes: 0 additions & 3 deletions helpdesk_mgmt_stage_server_action/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
2 changes: 1 addition & 1 deletion helpdesk_mgmt_stage_server_action/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Helpdesk Stage Server Action",
"summary": "Execute server actions when reaching a Helpdesk ticket stage",
"version": "14.0.1.0.0",
"version": "17.0.1.0.0",
"category": "HelpDesk Service",
"author": "Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/helpdesk",
Expand Down
3 changes: 0 additions & 3 deletions helpdesk_mgmt_stage_server_action/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import helpdesk_ticket_stage
from . import helpdesk_ticket
15 changes: 8 additions & 7 deletions helpdesk_mgmt_stage_server_action/models/helpdesk_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@ def create(self, vals_list):
records = super().create(vals_list)
for record in records:
action = record.stage_id.action_id
if action:
context = {
"active_model": self._name,
"active_ids": [record.id],
}
action.with_context(**context).run()
if not action:
continue
context = {
"active_model": self._name,
"active_id": record.id,
}
action.with_context(**context).run()
return records

def write(self, vals):
records = "stage_id" in vals and self.filtered(
lambda l: l.stage_id.id != vals.get("stage_id")
lambda ticket: ticket.stage_id.id != vals.get("stage_id")
)
if records:
res = super().write(vals)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ <h1 class="title">Helpdesk Stage Server Action</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:5088a8a0de0750867808606407f0644523fd0ece3129431c36afeb51a3f2e4cd
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/helpdesk/tree/17.0/helpdesk_ticket_stage_server_action"><img alt="OCA/helpdesk" src="https://img.shields.io/badge/github-OCA%2Fhelpdesk-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/helpdesk-17-0/helpdesk-17-0-helpdesk_ticket_stage_server_action"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/helpdesk&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/helpdesk/tree/17.0/helpdesk_mgmt_stage_server_action"><img alt="OCA/helpdesk" src="https://img.shields.io/badge/github-OCA%2Fhelpdesk-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/helpdesk-17-0/helpdesk-17-0-helpdesk_mgmt_stage_server_action"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/helpdesk&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows you to execute server actions when a Helpdesk ticket
enters a specific stage.</p>
<p><strong>Table of contents</strong></p>
Expand Down Expand Up @@ -408,7 +408,7 @@ <h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/helpdesk/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/helpdesk/issues/new?body=module:%20helpdesk_ticket_stage_server_action%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="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**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -434,7 +434,7 @@ <h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/helpdesk/tree/17.0/helpdesk_ticket_stage_server_action">OCA/helpdesk</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/helpdesk/tree/17.0/helpdesk_mgmt_stage_server_action">OCA/helpdesk</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.tests.common import SavepointCase
from odoo.tests.common import RecordCapturer, TransactionCase

from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT

class HelpdeskTicketStageServerAction(SavepointCase):

class HelpdeskTicketStageServerAction(TransactionCase):
@classmethod
def setUpClass(cls):
super(HelpdeskTicketStageServerAction, cls).setUpClass()
cls.ServerAction = cls.env["ir.actions.server"]
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT))
cls.HelpdeskTicket = cls.env["helpdesk.ticket"]
cls.HelpdeskTicketStage = cls.env["helpdesk.ticket.stage"]
cls.field = cls.env["ir.model.fields"]._get(cls.HelpdeskTicket._name, "user_id")
cls.HelpdeskTicketTag = cls.env["helpdesk.ticket.tag"]
cls.ServerAction = cls.env["ir.actions.server"]
cls.server_action_helpdesk_ticket = cls.ServerAction.create(
{
"name": "Helpdesk Ticket Server Action",
"model_id": cls.env.ref("helpdesk_mgmt.model_helpdesk_ticket").id,
"model_id": cls.env["ir.model"]._get_id("helpdesk.ticket"),
"crud_model_id": cls.env["ir.model"]._get_id("helpdesk.ticket"),
"value": str(cls.env.user.id),
"update_path": "user_id",
"update_field_id": cls.env["ir.model.fields"]._get_ids(
"helpdesk.ticket"
)["user_id"],
"evaluation_type": "value",
"state": "object_write",
"fields_lines": [
(
0,
0,
{
"col1": cls.field.id,
"evaluation_type": "value",
"value": cls.env.user.id,
},
)
],
}
)
cls.helpdesk_ticket_stage_1 = cls.HelpdeskTicketStage.create(
Expand Down Expand Up @@ -94,3 +93,31 @@ def test_helpdesk_ticket_without_stage(self):
self.assertFalse(self.helpdesk_ticket_4.user_id)
self.helpdesk_ticket_4.write({"stage_id": self.helpdesk_ticket_stage_2.id})
self.assertEqual(self.helpdesk_ticket_4.user_id, self.env.user)

def test_helpdesk_ticket_run_action(self):
create_tag_action = self.ServerAction.create(
{
"model_id": self.env["ir.model"]._get_id("helpdesk.ticket.tag"),
"crud_model_id": self.env["ir.model"]._get_id("helpdesk.ticket.tag"),
"name": "Create new helpdesk tag",
"value": "New helpdesk tag",
"state": "object_create",
}
)
stage_1 = self.HelpdeskTicketStage.create(
{"name": "Stage 1", "sequence": 1, "action_id": create_tag_action.id}
)
ticket = self.HelpdeskTicket.create(
{
"name": "Create a tag ticket",
"description": "Ticket Description",
}
)
self.assertFalse(
self.HelpdeskTicketTag.search([("name", "=", "New helpdesk tag")]).exists()
)
with RecordCapturer(self.HelpdeskTicketTag, []) as capture:
ticket.write({"stage_id": stage_1.id})
tag = capture.records
self.assertEqual(1, len(tag))
self.assertEqual("New helpdesk tag", tag.name)

0 comments on commit 72cbe20

Please sign in to comment.