22 lines
942 B
Python
22 lines
942 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo.http import request
|
|
from odoo.addons.website_helpdesk.controllers.main import WebsiteHelpdesk
|
|
|
|
|
|
class WebsiteHelpdeskForum(WebsiteHelpdesk):
|
|
|
|
def _format_search_results(self, search_type, records, options):
|
|
if search_type != 'forum_posts_only':
|
|
return super()._format_search_results(search_type, records, options)
|
|
|
|
questions = records.mapped('parent_id') | records.filtered(lambda s: not s.parent_id)
|
|
return [{
|
|
'template': 'website_helpdesk_forum.search_result',
|
|
'record': question,
|
|
'score': question.views + question.vote_count + question.favourite_count,
|
|
'url': '/forum/%s/%s' % (request.env['ir.http']._slug(question.forum_id), request.env['ir.http']._slug(question)),
|
|
'icon': 'fa-comments',
|
|
} for question in questions]
|