You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

44 lines
1.5 KiB

from odoo import http
from odoo.http import request
class TicketGroupBy(http.Controller):
@http.route(['/ticketgroupby'], type='json', auth="public", website=True)
def ticket_group_by(self,**kwargs):
context = []
group_value = kwargs.get("search_value")
if group_value == '0':
context = []
tickets = request.env["help.ticket"].search([])
if group_value == '1':
context = []
stage_ids = request.env['ticket.stage'].search([])
for stage in stage_ids:
ticket_ids = request.env['help.ticket'].search([
('stage_id', '=', stage.id)
])
if ticket_ids:
context.append({
'name': stage.name,
'data': ticket_ids
})
if group_value == '2':
context = []
type_ids = request.env['helpdesk.types'].search([])
for types in type_ids:
ticket_ids_1 = request.env['help.ticket'].search([
('ticket_type', '=', types.id)
])
if ticket_ids_1:
context.append({
'name': types.name,
'data': ticket_ids_1
})
values = {
'tickets': context,
}
response = http.Response(
template='odoo_website_helpdesk.ticket_group_by_table',
qcontext=values)
return response.render()