5 Commits

Author SHA1 Message Date
243603069e [ADD] helpdesk_ticket_task_domain 2025-10-21 15:18:26 +00:00
jscampucci
5df89b06cd [IMP] helpdesk_portal_ticket_custom: add default filter & group to portal ticket list
Some checks failed
pre-commit / pre-commit (pull_request) Failing after 1m33s
2025-10-21 08:34:12 +00:00
jscampucci
72faa3929a [IMP] helpdesk_portal_timesheet : correct sum from non billable timesheet from portal 2025-10-21 08:28:38 +00:00
jscampucci
b837c6b3c7 [IMP] helpdesk_portal_ticket_custom: add priority to portal ticket view
Some checks failed
pre-commit / pre-commit (pull_request) Failing after 1m28s
2025-10-21 08:13:36 +00:00
jscampucci
cb83dd954c [ADD] helpdesk_portal_ticket_custom: add priority to portal ticket list 2025-10-21 08:13:36 +00:00
14 changed files with 346 additions and 3 deletions

View File

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

View 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.

View File

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

View 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,
}

View File

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

View 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)

View File

@@ -0,0 +1,43 @@
<?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>
<template id="ticket_priority_3_stars_template" name="Priority 3 Stars Widget Template">
<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>
</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_3_stars_template">
</t>
</td>
</xpath>
</template>
<template id="portal_ticket_form_inherit" inherit_id="helpdesk_mgmt.portal_helpdesk_ticket_page">
<xpath expr="//div[@class='col-9']" position="before">
<div>
<t t-call="helpdesk_portal_ticket_custom.ticket_priority_3_stars_template">
</t>
</div>
</xpath>
</template>
</odoo>

View File

@@ -12,7 +12,8 @@
"summary": "Show ticket timesheets in portal view", "summary": "Show ticket timesheets in portal view",
# any module necessary for this one to work correctly # any module necessary for this one to work correctly
"depends": [ "depends": [
"helpdesk_mgmt_timesheet","sale_timesheet_line_exclude", "helpdesk_mgmt_timesheet",
"sale_timesheet_line_exclude",
], ],
"qweb": [], "qweb": [],
"external_dependencies": { "external_dependencies": {

View File

@@ -33,7 +33,7 @@
<tr> <tr>
<th colspan="3"></th> <th colspan="3"></th>
<th class="text-end"> <th class="text-end">
<t t-set="timesheets_amount" t-value="round(sum(timesheets.mapped('unit_amount')), 2) or 0.0"></t> <t t-set="timesheets_amount" t-value="round(sum(timesheets.filtered(lambda t: not t.exclude_from_sale_order).mapped('unit_amount')), 2) or 0.0"></t>
<div t-if="is_uom_day"> <div t-if="is_uom_day">
<strong>Days Spent:</strong> <strong>Days Spent:</strong>
<span t-esc="timesheets._convert_hours_to_days(timesheets_amount)" t-options='{"widget": "timesheet_uom"}'/> <span t-esc="timesheets._convert_hours_to_days(timesheets_amount)" t-options='{"widget": "timesheet_uom"}'/>

View File

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

View File

@@ -0,0 +1,36 @@
===========================
helpdesk_ticket_task_domain
===========================
This module adjusts the domain applied to task field in order to limit
selection to tasks in any of unfolded stages.
# Installation
Use Odoo normal module installation procedure to install
`helpdesk_ticket_task_domain`.
# Known issues / Roadmap
# 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

View File

@@ -0,0 +1,20 @@
# Copyright 2025 Quentin Mondot
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "helpdesk_ticket_task_domain",
"version": "16.0.1.0.0",
"author": "Elabore",
"website": "https://elabore.coop",
"maintainer": "Quentin Mondot",
"license": "AGPL-3",
"category": "Tools",
"summary": "This module adjusts the domain applied to task field in order to limit "
"selection to tasks in any of unfolded stages.",
"depends": ["helpdesk_mgmt_project"],
"data": [
"views/ticket_view_form_task_domain.xml"
],
"installable": True,
"auto_install": True,
"application": False,
}

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="ticket_view_form_task_domain" model="ir.ui.view">
<field name="name">helpdesk.ticket.form.task.domain</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' and @domain]" position="attributes">
<attribute
name="domain"
>[('project_id', '=', project_id),('stage_id.fold', '=', False)]</attribute>
</xpath>
</field>
</record>
</odoo>