Compare commits
2 Commits
delete-unu
...
066b926432
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
066b926432 | ||
|
|
95a69671dd |
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_custom/.gitignore
vendored
Normal file
2
helpdesk_portal_ticket_custom/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
*.*~
|
||||||
|
*pyc
|
||||||
37
helpdesk_portal_ticket_custom/README.md
Normal file
37
helpdesk_portal_ticket_custom/README.md
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
====================================
|
||||||
|
helpdesk_portal_ticket_custom
|
||||||
|
====================================
|
||||||
|
|
||||||
|
Customization for ticket portal view.
|
||||||
|
|
||||||
|
# Installation
|
||||||
|
|
||||||
|
Use Odoo normal module installation procedure to install
|
||||||
|
`helpdesk_portal_ticket_custom`.
|
||||||
|
|
||||||
|
# Known issues / Roadmap
|
||||||
|
|
||||||
|
None yet.
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
- Joris Scampucci
|
||||||
|
|
||||||
|
## Funders
|
||||||
|
|
||||||
|
The development of this module has been financially supported by:
|
||||||
|
|
||||||
|
- Elabore (https://elabore.coop)
|
||||||
|
|
||||||
|
## Maintainer
|
||||||
|
|
||||||
|
This module is maintained by Elabore.
|
||||||
1
helpdesk_portal_ticket_custom/__init__.py
Normal file
1
helpdesk_portal_ticket_custom/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import models
|
||||||
35
helpdesk_portal_ticket_custom/__manifest__.py
Normal file
35
helpdesk_portal_ticket_custom/__manifest__.py
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# Copyright 2024 Joris Scampucci" (Elabore)
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
{
|
||||||
|
"name": "helpdesk_portal_ticket_custom",
|
||||||
|
"version": "16.0.1.0.0",
|
||||||
|
"author": "Elabore",
|
||||||
|
"website": "https://elabore.coop",
|
||||||
|
"maintainer": "Joris Scampucci",
|
||||||
|
"license": "AGPL-3",
|
||||||
|
"category": "Tools",
|
||||||
|
"summary": "Customization for ticket portal view.",
|
||||||
|
# any module necessary for this one to work correctly
|
||||||
|
"depends": [
|
||||||
|
"base",
|
||||||
|
"helpdesk_mgmt",
|
||||||
|
],
|
||||||
|
"qweb": [],
|
||||||
|
"external_dependencies": {
|
||||||
|
"python": [],
|
||||||
|
},
|
||||||
|
# always loaded
|
||||||
|
"data": [
|
||||||
|
"views/portal_ticket_views.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,
|
||||||
|
}
|
||||||
1
helpdesk_portal_ticket_custom/models/__init__.py
Normal file
1
helpdesk_portal_ticket_custom/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import myaccount
|
||||||
149
helpdesk_portal_ticket_custom/models/myaccount.py
Normal file
149
helpdesk_portal_ticket_custom/models/myaccount.py
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
from collections import OrderedDict
|
||||||
|
from operator import itemgetter
|
||||||
|
|
||||||
|
from odoo import _, http
|
||||||
|
from odoo.http import request
|
||||||
|
from odoo.osv.expression import AND
|
||||||
|
from odoo.tools import groupby as groupbyelem
|
||||||
|
|
||||||
|
from odoo.addons.portal.controllers.portal import CustomerPortal
|
||||||
|
from odoo.addons.portal.controllers.portal import pager as portal_pager
|
||||||
|
|
||||||
|
|
||||||
|
class CustomerPortalHelpdesk(CustomerPortal):
|
||||||
|
_inherit = "helpdesk_mgmt.myaccount"
|
||||||
|
|
||||||
|
@http.route(
|
||||||
|
["/my/tickets", "/my/tickets/page/<int:page>"],
|
||||||
|
type="http",
|
||||||
|
auth="user",
|
||||||
|
website=True,
|
||||||
|
)
|
||||||
|
def portal_my_tickets(
|
||||||
|
self,
|
||||||
|
page=1,
|
||||||
|
date_begin=None,
|
||||||
|
date_end=None,
|
||||||
|
sortby=None,
|
||||||
|
filterby=None,
|
||||||
|
search=None,
|
||||||
|
search_in=None,
|
||||||
|
groupby=None,
|
||||||
|
**kw,
|
||||||
|
):
|
||||||
|
HelpdeskTicket = request.env["helpdesk.ticket"]
|
||||||
|
# Avoid error if the user does not have access.
|
||||||
|
if not HelpdeskTicket.check_access_rights("read", raise_exception=False):
|
||||||
|
return request.redirect("/my")
|
||||||
|
|
||||||
|
values = self._prepare_portal_layout_values()
|
||||||
|
|
||||||
|
searchbar_sortings = self._ticket_get_searchbar_sortings()
|
||||||
|
searchbar_sortings = dict(
|
||||||
|
sorted(
|
||||||
|
self._ticket_get_searchbar_sortings().items(),
|
||||||
|
key=lambda item: item[1]["sequence"],
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
searchbar_filters = {
|
||||||
|
"all": {"label": _("All"), "domain": []},
|
||||||
|
"closed": {"label": _("Ouvert"), "domain": [("closed", "=", False)]},
|
||||||
|
}
|
||||||
|
for stage in request.env["helpdesk.ticket.stage"].search([]):
|
||||||
|
searchbar_filters[str(stage.id)] = {
|
||||||
|
"label": stage.name,
|
||||||
|
"domain": [("stage_id", "=", stage.id)],
|
||||||
|
}
|
||||||
|
|
||||||
|
searchbar_inputs = self._ticket_get_searchbar_inputs()
|
||||||
|
searchbar_groupby = self._ticket_get_searchbar_groupby()
|
||||||
|
|
||||||
|
if not sortby:
|
||||||
|
sortby = "date"
|
||||||
|
order = searchbar_sortings[sortby]["order"]
|
||||||
|
|
||||||
|
if not filterby:
|
||||||
|
filterby = "closed"
|
||||||
|
domain = searchbar_filters.get(filterby, searchbar_filters.get("all"))["domain"]
|
||||||
|
|
||||||
|
if not groupby:
|
||||||
|
groupby = "stage"
|
||||||
|
|
||||||
|
if date_begin and date_end:
|
||||||
|
domain += [
|
||||||
|
("create_date", ">", date_begin),
|
||||||
|
("create_date", "<=", date_end),
|
||||||
|
]
|
||||||
|
|
||||||
|
if not search_in:
|
||||||
|
search_in = "all"
|
||||||
|
if search:
|
||||||
|
domain += self._ticket_get_search_domain(search_in, search)
|
||||||
|
|
||||||
|
domain = AND(
|
||||||
|
[
|
||||||
|
domain,
|
||||||
|
request.env["ir.rule"]._compute_domain(HelpdeskTicket._name, "read"),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
# count for pager
|
||||||
|
ticket_count = HelpdeskTicket.search_count(domain)
|
||||||
|
# pager
|
||||||
|
pager = portal_pager(
|
||||||
|
url="/my/tickets",
|
||||||
|
url_args={
|
||||||
|
"date_begin": date_begin,
|
||||||
|
"date_end": date_end,
|
||||||
|
"sortby": sortby,
|
||||||
|
"filterby": filterby,
|
||||||
|
"groupby": groupby,
|
||||||
|
"search": search,
|
||||||
|
"search_in": search_in,
|
||||||
|
},
|
||||||
|
total=ticket_count,
|
||||||
|
page=page,
|
||||||
|
step=self._items_per_page,
|
||||||
|
)
|
||||||
|
|
||||||
|
order = self._ticket_get_order(order, groupby)
|
||||||
|
tickets = HelpdeskTicket.search(
|
||||||
|
domain,
|
||||||
|
order=order,
|
||||||
|
limit=self._items_per_page,
|
||||||
|
offset=pager["offset"],
|
||||||
|
)
|
||||||
|
request.session["my_tickets_history"] = tickets.ids[:100]
|
||||||
|
|
||||||
|
groupby_mapping = self._ticket_get_groupby_mapping()
|
||||||
|
group = groupby_mapping.get(groupby)
|
||||||
|
if group:
|
||||||
|
grouped_tickets = [
|
||||||
|
request.env["helpdesk.ticket"].concat(*g) for k, g in groupbyelem(tickets, itemgetter(group))
|
||||||
|
]
|
||||||
|
elif tickets:
|
||||||
|
grouped_tickets = [tickets]
|
||||||
|
else:
|
||||||
|
grouped_tickets = []
|
||||||
|
|
||||||
|
values.update(
|
||||||
|
{
|
||||||
|
"date": date_begin,
|
||||||
|
"date_end": date_end,
|
||||||
|
"grouped_tickets": grouped_tickets,
|
||||||
|
"page_name": "ticket",
|
||||||
|
"default_url": "/my/tickets",
|
||||||
|
"pager": pager,
|
||||||
|
"searchbar_sortings": searchbar_sortings,
|
||||||
|
"searchbar_groupby": searchbar_groupby,
|
||||||
|
"searchbar_inputs": searchbar_inputs,
|
||||||
|
"search_in": search_in,
|
||||||
|
"search": search,
|
||||||
|
"sortby": sortby,
|
||||||
|
"groupby": groupby,
|
||||||
|
"searchbar_filters": OrderedDict(sorted(searchbar_filters.items())),
|
||||||
|
"filterby": filterby,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return request.render("helpdesk_mgmt.portal_my_tickets", values)
|
||||||
29
helpdesk_portal_ticket_custom/views/portal_ticket_views.xml
Normal file
29
helpdesk_portal_ticket_custom/views/portal_ticket_views.xml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<template id="ticket_priority_widget_template" name="Priority Widget Template">
|
||||||
|
<span t-attf-class="o_priority_star fa fa-star#{'' if ticket.priority >= ticket_priority else '-o'}" t-attf-title="Priorité: {{'Très haute' if ticket.priority == '3' else 'Haute' if ticket.priority == '2' else 'Moyenne' if ticket.priority == '1' else 'Basse'}}" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- Ticket portal list -->
|
||||||
|
<template id="portal_ticket_list_inherit" inherit_id="helpdesk_mgmt.portal_ticket_list" priority="1">
|
||||||
|
<!-- Add priority field -->
|
||||||
|
<xpath expr="//thead/tr/th[2]" position="after">
|
||||||
|
<th>Priorité</th>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//tbody/t/tr/td[2]" position="after">
|
||||||
|
<td>
|
||||||
|
<t t-call="helpdesk_portal_ticket_custom.ticket_priority_widget_template">
|
||||||
|
<t t-set="ticket_priority" t-value="'1'"/>
|
||||||
|
</t>
|
||||||
|
<t t-call="helpdesk_portal_ticket_custom.ticket_priority_widget_template">
|
||||||
|
<t t-set="ticket_priority" t-value="'2'"/>
|
||||||
|
</t>
|
||||||
|
<t t-call="helpdesk_portal_ticket_custom.ticket_priority_widget_template">
|
||||||
|
<t t-set="ticket_priority" t-value="'3'"/>
|
||||||
|
</t>
|
||||||
|
</td>
|
||||||
|
</xpath>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
Reference in New Issue
Block a user