[IMP] helpdesk_create_task_from_ticket: debug when used with timesheet module #4
2
helpdesk_create_task_from_ticket/.gitignore
vendored
Normal file
2
helpdesk_create_task_from_ticket/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
*.*~
|
||||||
|
*pyc
|
53
helpdesk_create_task_from_ticket/README.md
Normal file
53
helpdesk_create_task_from_ticket/README.md
Normal 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.
|
1
helpdesk_create_task_from_ticket/__init__.py
Normal file
1
helpdesk_create_task_from_ticket/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import models
|
26
helpdesk_create_task_from_ticket/__manifest__.py
Normal file
26
helpdesk_create_task_from_ticket/__manifest__.py
Normal 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,
|
||||||
|
}
|
1
helpdesk_create_task_from_ticket/models/__init__.py
Normal file
1
helpdesk_create_task_from_ticket/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import project_task
|
71
helpdesk_create_task_from_ticket/models/project_task.py
Normal file
71
helpdesk_create_task_from_ticket/models/project_task.py
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
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):
|
||||||
|
if all(key in self.env.context for key in (
|
||||||
|
"default_user_id",
|
||||||
|
"default_ticket_category_id",
|
||||||
|
"default_ticket_request_type_id"
|
||||||
|
)):
|
||||||
|
user_ids = [self.env.context["default_user_id"]]
|
||||||
|
task_service_id, request_type_id = self._match_task_service_and_request_type(
|
||||||
|
ticket_category_id=self.env.context["default_ticket_category_id"],
|
||||||
|
ticket_request_type_id=self.env.context["default_ticket_request_type_id"]
|
||||||
|
)
|
||||||
|
|
||||||
|
return super(ProjectTask, self.with_context(
|
||||||
|
default_user_ids=user_ids,
|
||||||
|
default_service_id=task_service_id,
|
||||||
|
default_request_type_id=request_type_id
|
||||||
|
)).create(vals_list)
|
||||||
|
|
||||||
|
return super(ProjectTask, self).create(vals_list)
|
||||||
|
|
||||||
|
def onchange(self, values, field_name, field_onchange):
|
||||||
|
if all(key in self.env.context for key in (
|
||||||
|
"default_user_id",
|
||||||
|
"default_ticket_category_id",
|
||||||
|
"default_ticket_request_type_id"
|
||||||
|
)):
|
||||||
|
user_ids = [self.env.context["default_user_id"]]
|
||||||
|
task_service_id, request_type_id = self._match_task_service_and_request_type(
|
||||||
|
ticket_category_id=self.env.context["default_ticket_category_id"],
|
||||||
|
ticket_request_type_id=self.env.context["default_ticket_request_type_id"]
|
||||||
|
)
|
||||||
|
|
||||||
|
return super(ProjectTask, self.with_context(
|
||||||
|
default_user_ids=user_ids,
|
||||||
|
default_service_id=task_service_id,
|
||||||
|
default_request_type_id=request_type_id
|
||||||
|
)).onchange(values, field_name, field_onchange)
|
||||||
|
|
||||||
|
return super(ProjectTask, self).onchange(values, field_name, field_onchange)
|
||||||
|
|
||||||
|
def _match_task_service_and_request_type(
|
||||||
|
self,
|
||||||
|
ticket_category_id: int,
|
||||||
|
ticket_request_type_id: int
|
||||||
|
) -> tuple[int, int]:
|
||||||
|
helpdesk_ticket_category = self.env["helpdesk.ticket.category"].search(
|
||||||
|
[("id", "=", ticket_category_id)],
|
||||||
|
limit=1
|
||||||
|
)
|
||||||
|
task_service = self.env["task.service"].search([("name", "=", helpdesk_ticket_category.name)])
|
||||||
|
|
||||||
|
helpdesk_ticket_request_type = self.env["helpdesk.request.type"].search(
|
||||||
|
[("id", "=", ticket_request_type_id)],
|
||||||
|
limit=1
|
||||||
|
)
|
||||||
|
task_request_type = self.env["request.type"].search([("name", "=", helpdesk_ticket_request_type.name)])
|
||||||
|
|
||||||
|
return task_service.id, task_request_type.id
|
@@ -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_id': user_id,
|
||||||
|
'default_partner_id': partner_id,
|
||||||
|
'default_ticket_category_id': category_id,
|
||||||
|
'default_ticket_request_type_id': request_type_id,
|
||||||
|
'default_priority': priority
|
||||||
|
}
|
||||||
|
</attribute>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
2
helpdesk_portal_ticket_list/.gitignore
vendored
Normal file
2
helpdesk_portal_ticket_list/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
*.*~
|
||||||
|
*pyc
|
50
helpdesk_portal_ticket_list/README.rst
Normal file
50
helpdesk_portal_ticket_list/README.rst
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
===========================
|
||||||
|
helpdesk_portal_ticket_list
|
||||||
|
===========================
|
||||||
|
|
||||||
|
Customize ticket portal view list
|
||||||
|
|
||||||
|
Installation
|
||||||
|
============
|
||||||
|
|
||||||
|
Use Odoo normal module installation procedure to install
|
||||||
|
``helpdesk_portal_ticket_list``.
|
||||||
|
|
||||||
|
|
||||||
|
Description
|
||||||
|
============
|
||||||
|
In ticket portal view list
|
||||||
|
- expand "name" column
|
||||||
|
- fix display bug on "Stage" column
|
||||||
|
|
||||||
|
Known issues / Roadmap
|
||||||
|
======================
|
||||||
|
|
||||||
|
None yet.
|
||||||
|
Bug Tracker
|
||||||
|
===========
|
||||||
|
|
||||||
|
Bugs are tracked on `our issues website <https://github.com/elabore-coop/project-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
|
||||||
|
------------
|
||||||
|
|
||||||
|
* Laetitia Da Costa
|
||||||
|
|
||||||
|
Funders
|
||||||
|
-------
|
||||||
|
|
||||||
|
The development of this module has been financially supported by:
|
||||||
|
* Elabore (https://elabore.coop)
|
||||||
|
|
||||||
|
|
||||||
|
Maintainer
|
||||||
|
----------
|
||||||
|
|
||||||
|
This module is maintained by Elabore.
|
2
helpdesk_portal_ticket_list/__init__.py
Normal file
2
helpdesk_portal_ticket_list/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
36
helpdesk_portal_ticket_list/__manifest__.py
Normal file
36
helpdesk_portal_ticket_list/__manifest__.py
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# Copyright 2022 Stéphan Sainléger (Elabore)
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
{
|
||||||
|
"name": "helpdesk_portal_ticket_list",
|
||||||
|
"version": "16.0.1.1.0",
|
||||||
|
"author": "Elabore",
|
||||||
|
"website": "https://elabore.coop",
|
||||||
|
"maintainer": "Laetitia Da Costa",
|
||||||
|
"license": "AGPL-3",
|
||||||
|
"category": "Helpdesk",
|
||||||
|
"summary": "Customize ticket portal view list",
|
||||||
|
"description": "",
|
||||||
|
# any module necessary for this one to work correctly
|
||||||
|
"depends": [
|
||||||
|
"base",
|
||||||
|
"helpdesk_mgmt",
|
||||||
|
],
|
||||||
|
"qweb": [],
|
||||||
|
"external_dependencies": {
|
||||||
|
"python": [],
|
||||||
|
},
|
||||||
|
# always loaded
|
||||||
|
"data": [
|
||||||
|
"views/portal_ticket_view.xml",
|
||||||
|
],
|
||||||
|
# only loaded in demonstration mode
|
||||||
|
"demo": [],
|
||||||
|
"js": [],
|
||||||
|
"css": [],
|
||||||
|
"installable": True,
|
||||||
|
# Install this module automatically if all dependency have been previously
|
||||||
|
# and independently installed. Used for synergetic or glue modules.
|
||||||
|
"auto_install": False,
|
||||||
|
"application": False,
|
||||||
|
}
|
90
helpdesk_portal_ticket_list/views/portal_ticket_view.xml
Normal file
90
helpdesk_portal_ticket_list/views/portal_ticket_view.xml
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<template id="portal_ticket_list_inherit" inherit_id="helpdesk_mgmt.portal_ticket_list">
|
||||||
|
<xpath expr="." position="replace">
|
||||||
|
<t t-if="grouped_tickets">
|
||||||
|
<t t-call="portal.portal_table">
|
||||||
|
<t t-foreach="grouped_tickets" t-as="tickets">
|
||||||
|
<thead>
|
||||||
|
<tr
|
||||||
|
t-attf-class="{{'thead-light' if not groupby == 'none' else ''}}"
|
||||||
|
>
|
||||||
|
<th class="text-left">By</th>
|
||||||
|
<th class="text-left">Number</th>
|
||||||
|
<th t-if="groupby == 'none'">Title</th>
|
||||||
|
<th t-if="groupby == 'category'">
|
||||||
|
<em
|
||||||
|
class="font-weight-normal text-muted"
|
||||||
|
>Tickets in category:</em>
|
||||||
|
<span
|
||||||
|
class="text-truncate"
|
||||||
|
t-field="tickets[0].sudo().category_id.name"
|
||||||
|
/>
|
||||||
|
</th>
|
||||||
|
<th t-if="groupby == 'stage'">
|
||||||
|
<em
|
||||||
|
class="font-weight-normal text-muted"
|
||||||
|
>Tickets in stage:</em>
|
||||||
|
<span
|
||||||
|
class="text-truncate"
|
||||||
|
t-field="tickets[0].sudo().stage_id.name"
|
||||||
|
/>
|
||||||
|
</th>
|
||||||
|
<th t-if="groupby != 'category'">Category</th>
|
||||||
|
<th t-if="groupby != 'stage'">Stage</th>
|
||||||
|
<th name="Create Date" style="display: none;" >Create Date</th>
|
||||||
|
<th name="Last Stage Update" style="display: none;">Last Stage Update</th>
|
||||||
|
<th name="Close Date" style="display: none;">Close Date</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<t t-foreach="tickets" t-as="ticket">
|
||||||
|
<tr>
|
||||||
|
<td class="text-left">
|
||||||
|
<span t-esc="ticket.partner_id.name" />
|
||||||
|
</td>
|
||||||
|
<td class="text-left">
|
||||||
|
<span t-esc="ticket.number" />
|
||||||
|
</td>
|
||||||
|
<td style="max-width: 30rem;">
|
||||||
|
<a
|
||||||
|
t-attf-href="/my/ticket/#{ticket.id}?{{ keep_query() }}"
|
||||||
|
>
|
||||||
|
<span t-field="ticket.name" />
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td t-if="groupby != 'category'">
|
||||||
|
<span t-esc="ticket.category_id.name" />
|
||||||
|
</td>
|
||||||
|
<td t-if="groupby != 'stage'">
|
||||||
|
<span
|
||||||
|
class="badge badge-pill badge-info"
|
||||||
|
title="Current stage of the ticket"
|
||||||
|
t-esc="ticket.stage_id.name"
|
||||||
|
t-attf-class="badge #{'text-bg-primary' if ticket.stage_id.fold else
|
||||||
|
'text-bg-light'}"
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
<td style="display: none;">
|
||||||
|
<span t-field="ticket.create_date"/>
|
||||||
|
</td>
|
||||||
|
<td style="display: none;">
|
||||||
|
<span t-field="ticket.last_stage_update"/>
|
||||||
|
</td>
|
||||||
|
<td style="display: none;">
|
||||||
|
<span t-field="ticket.closed_date"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</t>
|
||||||
|
</tbody>
|
||||||
|
</t>
|
||||||
|
</t>
|
||||||
|
</t>
|
||||||
|
</xpath>
|
||||||
|
</template>
|
||||||
|
<template id="portal_my_tickets_inherit" inherit_id="helpdesk_mgmt.portal_my_tickets">
|
||||||
|
<xpath expr="//form/button[@name='create_new_ticket']" position="attributes">
|
||||||
|
<attribute name="style">margin-right: 0px; margin-bottom: 5px; display: inline-block;</attribute>
|
||||||
|
</xpath>
|
||||||
|
</template>
|
||||||
|
</odoo>
|
@@ -5,22 +5,10 @@ class HelpdeskTicketControllerRequestType(HelpdeskTicketController):
|
|||||||
|
|
||||||
@http.route("/new/ticket", type="http", auth="user", website=True)
|
@http.route("/new/ticket", type="http", auth="user", website=True)
|
||||||
def create_new_ticket(self, **kw):
|
def create_new_ticket(self, **kw):
|
||||||
categories = http.request.env["helpdesk.ticket.category"].search(
|
res = super(HelpdeskTicketControllerRequestType, self).create_new_ticket(**kw)
|
||||||
[("active", "=", True)]
|
|
||||||
)
|
|
||||||
request_types = http.request.env["helpdesk.request.type"].search([])
|
request_types = http.request.env["helpdesk.request.type"].search([])
|
||||||
email = http.request.env.user.email
|
res.qcontext["request_types"] = request_types
|
||||||
name = http.request.env.user.name
|
return res
|
||||||
return http.request.render(
|
|
||||||
"helpdesk_mgmt.portal_create_ticket",
|
|
||||||
{
|
|
||||||
"categories": categories,
|
|
||||||
"teams": self._get_teams(),
|
|
||||||
"email": email,
|
|
||||||
"name": name,
|
|
||||||
"request_types": request_types
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
def _prepare_submit_ticket_vals(self, **kw):
|
def _prepare_submit_ticket_vals(self, **kw):
|
||||||
res = super()._prepare_submit_ticket_vals(**kw)
|
res = super()._prepare_submit_ticket_vals(**kw)
|
||||||
|
Reference in New Issue
Block a user