[ADD] helpdesk_create_task_from_ticket: this module enriches task information when creating it from a ticket form

This commit is contained in:
Quentin Mondot
2025-01-31 17:10:10 +01:00
committed by Laetitia Da Costa
parent e2c3737b90
commit 72a848477e
7 changed files with 134 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
*.*~
*pyc

View File

@@ -0,0 +1,53 @@
================================
helpdesk_create_task_from_ticket
================================
This module changes the behavior of the buttons "create" and "create and edit" of the field `task` in a ticket form.
It automatically fills up these tasks fields
```
Ticket (helpdesk.ticke) / Tâche (project.task)
Intitulé (name) --> Titre (name)
Utilisateur assigné (user_id) --> Assignés (user_ids)
Projet (project_id) --> Projet (project_id)
Contact (partner_id) --> Client (partner_id)
Catégorie (category_id) --> service (service_id)
Request Type (request_type_id) --> Type de demande (request_type_id)
Priorité (priority) --> Priorité (priority)
```
# Installation
Use Odoo normal module installation procedure to install
`helpdesk_create_task_from_ticket`.
# Known issues / Roadmap
A current limitation is that one task can be linked to many tickets.
Thus, the above task fields are filled up at the creation of the task from a ticket form
but are not updated when the linked tickets are updated.
# Bug Tracker
Bugs are tracked on `our issues website <https://github.com/elabore-coop/helpdesk-tools/issues>`\_. In case of
trouble, please check there if your issue has already been
reported. If you spotted it first, help us smashing it by providing a
detailed and welcomed feedback.
# Credits
## Contributors
- Quentin Mondot
## Funders
The development of this module has been financially supported by:
- Elabore (https://elabore.coop)
## Maintainer
This module is maintained by Elabore.

View File

@@ -0,0 +1 @@
from . import models

View File

@@ -0,0 +1,26 @@
# Copyright 2024 Quentin Mondot
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "helpdesk_create_task_from_ticket",
"version": "16.0.1.0.0",
"author": "Elabore",
"website": "https://elabore.coop",
"maintainer": "Quentin Mondot",
"license": "AGPL-3",
"category": "Tools",
"summary": "This module enriches task information when creating it from a ticket form.",
"depends": [
"base",
"helpdesk_mgmt",
"helpdesk_mgmt_project",
"helpdesk_request_type", # to create the helpdesk.request.type model and have the field request_type_id in the helpdesk.ticket model
"project_request_data", # to have the fields service_id and request_type_id in the project.task model
"project_task_add_very_high" # to have priority values 2 and 3 on tasks
],
"data": [
"views/helpdesk_create_task_from_ticket.xml",
],
"installable": True,
"auto_install": False,
"application": False,
}

View File

@@ -0,0 +1 @@
from . import project_task

View File

@@ -0,0 +1,28 @@
from odoo import models, api
class ProjectTask(models.Model):
"""
The function "create" is overloaded to adapt the field "user_ids" from the context of helpdesk.ticket to the one of project.task
This function is called when the user clicks on the button "create" in the task field of the ticket form
The function "onchange" is overloaded to adapt the field "user_ids" from the context of helpdesk.ticket to the one of project.task
This function is called when the user clicks on the button "create and modify" in the task field of the ticket form
"""
_inherit = "project.task"
@api.model
def create(self, vals_list):
user_ids = [self.env.context["default_user_ids"]]
result = super(ProjectTask, self.with_context(
default_user_ids=user_ids
)).create(vals_list)
return result
def onchange(self, values, field_name, field_onchange):
user_ids = [self.env.context["default_user_ids"]]
result = super(ProjectTask, self.with_context(
default_user_ids=user_ids
)).onchange(values, field_name, field_onchange)
return result

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="ticket_view_form_create_task_from_ticket" model="ir.ui.view">
<field name="name">helpdesk.ticket.form.task.from.ticket</field>
<field name="model">helpdesk.ticket</field>
<field name="inherit_id" ref="helpdesk_mgmt_project.ticket_view_form" />
<field name="priority" eval="99" />
<field name="arch" type="xml">
<xpath expr="//field[@name='task_id'][2]" position="attributes">
<attribute name="context">
{
'default_project_id': project_id,
'default_user_ids': user_id,
'default_partner_id': partner_id,
'default_service_id': category_id,
'default_request_type_id': request_type_id,
'default_priority': priority
}
</attribute>
</xpath>
</field>
</record>
</odoo>